docsig 0.55.0__tar.gz → 0.56.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {docsig-0.55.0 → docsig-0.56.0}/PKG-INFO +12 -9
- {docsig-0.55.0 → docsig-0.56.0}/README.rst +11 -8
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_report.py +21 -21
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_version.py +1 -1
- {docsig-0.55.0 → docsig-0.56.0}/docsig/messages.py +39 -29
- {docsig-0.55.0 → docsig-0.56.0}/pyproject.toml +1 -1
- {docsig-0.55.0 → docsig-0.56.0}/LICENSE +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/__init__.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/__main__.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_config.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_core.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_decorators.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_directives.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_hooks.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_main.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_module.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_stub.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/_utils.py +0 -0
- {docsig-0.55.0 → docsig-0.56.0}/docsig/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: docsig
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.56.0
|
|
4
4
|
Summary: Check signature params for proper documentation
|
|
5
5
|
Home-page: https://pypi.org/project/docsig/
|
|
6
6
|
License: MIT
|
|
@@ -152,14 +152,14 @@ Options can also be configured with the pyproject.toml file
|
|
|
152
152
|
check-overridden = false
|
|
153
153
|
check-protected = false
|
|
154
154
|
disable = [
|
|
155
|
-
"
|
|
156
|
-
"
|
|
157
|
-
"
|
|
155
|
+
"SIG101",
|
|
156
|
+
"SIG102",
|
|
157
|
+
"SIG402",
|
|
158
158
|
]
|
|
159
159
|
target = [
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"
|
|
160
|
+
"SIG202",
|
|
161
|
+
"SIG203",
|
|
162
|
+
"SIG201",
|
|
163
163
|
]
|
|
164
164
|
|
|
165
165
|
API
|
|
@@ -196,7 +196,7 @@ API
|
|
|
196
196
|
... """
|
|
197
197
|
>>> docsig(string=string, no_ansi=True)
|
|
198
198
|
2 in function
|
|
199
|
-
|
|
199
|
+
SIG202: includes parameters that do not exist (params-do-not-exist)
|
|
200
200
|
1
|
|
201
201
|
|
|
202
202
|
A full list of checks can be found `here <https://docsig.readthedocs.io/en/latest/usage/messages.html>`__
|
|
@@ -204,6 +204,9 @@ A full list of checks can be found `here <https://docsig.readthedocs.io/en/lates
|
|
|
204
204
|
Message Control
|
|
205
205
|
***************
|
|
206
206
|
|
|
207
|
+
If you have been using ``docsig`` prior to ``v0.56.0``, please see
|
|
208
|
+
`updated messages <https://docsig.readthedocs.io/en/latest/deprecated/messages.html>`_
|
|
209
|
+
|
|
207
210
|
`Documentation on message control <https://docsig.readthedocs.io/en/latest/usage/message-control.html>`_
|
|
208
211
|
|
|
209
212
|
Classes
|
|
@@ -222,7 +225,7 @@ It can be added to your .pre-commit-config.yaml as follows:
|
|
|
222
225
|
|
|
223
226
|
repos:
|
|
224
227
|
- repo: https://github.com/jshwi/docsig
|
|
225
|
-
rev: v0.
|
|
228
|
+
rev: v0.56.0
|
|
226
229
|
hooks:
|
|
227
230
|
- id: docsig
|
|
228
231
|
args:
|
|
@@ -124,14 +124,14 @@ Options can also be configured with the pyproject.toml file
|
|
|
124
124
|
check-overridden = false
|
|
125
125
|
check-protected = false
|
|
126
126
|
disable = [
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
127
|
+
"SIG101",
|
|
128
|
+
"SIG102",
|
|
129
|
+
"SIG402",
|
|
130
130
|
]
|
|
131
131
|
target = [
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
132
|
+
"SIG202",
|
|
133
|
+
"SIG203",
|
|
134
|
+
"SIG201",
|
|
135
135
|
]
|
|
136
136
|
|
|
137
137
|
API
|
|
@@ -168,7 +168,7 @@ API
|
|
|
168
168
|
... """
|
|
169
169
|
>>> docsig(string=string, no_ansi=True)
|
|
170
170
|
2 in function
|
|
171
|
-
|
|
171
|
+
SIG202: includes parameters that do not exist (params-do-not-exist)
|
|
172
172
|
1
|
|
173
173
|
|
|
174
174
|
A full list of checks can be found `here <https://docsig.readthedocs.io/en/latest/usage/messages.html>`__
|
|
@@ -176,6 +176,9 @@ A full list of checks can be found `here <https://docsig.readthedocs.io/en/lates
|
|
|
176
176
|
Message Control
|
|
177
177
|
***************
|
|
178
178
|
|
|
179
|
+
If you have been using ``docsig`` prior to ``v0.56.0``, please see
|
|
180
|
+
`updated messages <https://docsig.readthedocs.io/en/latest/deprecated/messages.html>`_
|
|
181
|
+
|
|
179
182
|
`Documentation on message control <https://docsig.readthedocs.io/en/latest/usage/message-control.html>`_
|
|
180
183
|
|
|
181
184
|
Classes
|
|
@@ -194,7 +197,7 @@ It can be added to your .pre-commit-config.yaml as follows:
|
|
|
194
197
|
|
|
195
198
|
repos:
|
|
196
199
|
- repo: https://github.com/jshwi/docsig
|
|
197
|
-
rev: v0.
|
|
200
|
+
rev: v0.56.0
|
|
198
201
|
hooks:
|
|
199
202
|
- id: docsig
|
|
200
203
|
args:
|
|
@@ -80,24 +80,24 @@ class Failure(_t.List[str]):
|
|
|
80
80
|
if not comment.isvalid:
|
|
81
81
|
if comment.ismodule:
|
|
82
82
|
# unknown-module-directive
|
|
83
|
-
self._add(_E[
|
|
83
|
+
self._add(_E[1], directive=comment.kind)
|
|
84
84
|
else:
|
|
85
85
|
# unknown-inline-directive
|
|
86
|
-
self._add(_E[
|
|
86
|
+
self._add(_E[2], directive=comment.kind)
|
|
87
87
|
else:
|
|
88
88
|
for rule in comment:
|
|
89
89
|
if not rule.isknown:
|
|
90
90
|
if comment.ismodule:
|
|
91
91
|
# unknown-module-directive-option
|
|
92
92
|
self._add(
|
|
93
|
-
_E[
|
|
93
|
+
_E[3],
|
|
94
94
|
directive=comment.kind,
|
|
95
95
|
option=rule.description,
|
|
96
96
|
)
|
|
97
97
|
else:
|
|
98
98
|
# unknown-inline-directive-option
|
|
99
99
|
self._add(
|
|
100
|
-
_E[
|
|
100
|
+
_E[4],
|
|
101
101
|
directive=comment.kind,
|
|
102
102
|
option=rule.description,
|
|
103
103
|
)
|
|
@@ -105,10 +105,10 @@ class Failure(_t.List[str]):
|
|
|
105
105
|
def _sig1xx_missing(self) -> None:
|
|
106
106
|
if not self._func.isinit:
|
|
107
107
|
# function-doc-missing
|
|
108
|
-
self._add(_E[
|
|
108
|
+
self._add(_E[101])
|
|
109
109
|
else:
|
|
110
110
|
# class-doc-missing
|
|
111
|
-
self._add(_E[
|
|
111
|
+
self._add(_E[102])
|
|
112
112
|
|
|
113
113
|
def _sig2xx_signature(self) -> None:
|
|
114
114
|
if self._func.docstring.args.duplicated:
|
|
@@ -120,7 +120,7 @@ class Failure(_t.List[str]):
|
|
|
120
120
|
self._func.docstring.args.pop(count)
|
|
121
121
|
|
|
122
122
|
# duplicate-params-found
|
|
123
|
-
self._add(_E[
|
|
123
|
+
self._add(_E[201])
|
|
124
124
|
# there are non-existing params in the docstring
|
|
125
125
|
elif len(self._func.docstring.args) > len(self._func.signature.args):
|
|
126
126
|
# pop the parameters that do not exist so that they are
|
|
@@ -133,7 +133,7 @@ class Failure(_t.List[str]):
|
|
|
133
133
|
if count > len(self._func.signature.args):
|
|
134
134
|
self._func.docstring.args.pop(count - 1)
|
|
135
135
|
# params-do-not-exist
|
|
136
|
-
self._add(_E[
|
|
136
|
+
self._add(_E[202])
|
|
137
137
|
# there are more args in sig than doc, so doc params missing
|
|
138
138
|
elif len(self._func.signature.args) > len(self._func.docstring.args):
|
|
139
139
|
# append the parameters that are missing so that they are
|
|
@@ -148,33 +148,33 @@ class Failure(_t.List[str]):
|
|
|
148
148
|
_Param(arg.kind, arg.name, _VALID_DESCRIPTION, 0)
|
|
149
149
|
)
|
|
150
150
|
# params-missing
|
|
151
|
-
self._add(_E[
|
|
151
|
+
self._add(_E[203])
|
|
152
152
|
|
|
153
153
|
def _sig3xx_description(self, doc: _Param) -> None:
|
|
154
154
|
if doc.description is None:
|
|
155
|
-
self._add(_E[
|
|
155
|
+
self._add(_E[301])
|
|
156
156
|
elif doc.description is not None and not doc.description.startswith(
|
|
157
157
|
" "
|
|
158
158
|
):
|
|
159
159
|
# syntax-error-in-description
|
|
160
|
-
self._add(_E[
|
|
160
|
+
self._add(_E[302])
|
|
161
161
|
# if the parameter does not have a name, but exists, then it
|
|
162
162
|
# must be incorrectly documented
|
|
163
163
|
elif doc.name == _UNNAMED:
|
|
164
164
|
# param-incorrectly-documented
|
|
165
|
-
self._add(_E[
|
|
165
|
+
self._add(_E[303])
|
|
166
166
|
|
|
167
167
|
def _sig4xx_parameters(self, doc: _Param, sig: _Param) -> None:
|
|
168
168
|
if doc.indent > 0:
|
|
169
169
|
# incorrect-indent
|
|
170
|
-
self._add(_E[
|
|
170
|
+
self._add(_E[401])
|
|
171
171
|
elif doc != sig:
|
|
172
172
|
if (
|
|
173
173
|
sig.name in self._func.docstring.args.names
|
|
174
174
|
or doc.name in self.func.signature.args.names
|
|
175
175
|
):
|
|
176
176
|
# params-out-of-order
|
|
177
|
-
self._add(_E[
|
|
177
|
+
self._add(_E[402])
|
|
178
178
|
elif (
|
|
179
179
|
doc.name != _UNNAMED
|
|
180
180
|
and sig.name is not None
|
|
@@ -182,10 +182,10 @@ class Failure(_t.List[str]):
|
|
|
182
182
|
):
|
|
183
183
|
if _almost_equal(sig.name, doc.name, _MIN_MATCH, _MAX_MATCH):
|
|
184
184
|
# spelling-error
|
|
185
|
-
self._add(_E[
|
|
185
|
+
self._add(_E[403])
|
|
186
186
|
else:
|
|
187
187
|
# param-not-equal-to-arg
|
|
188
|
-
self._add(_E[
|
|
188
|
+
self._add(_E[404])
|
|
189
189
|
|
|
190
190
|
def _sig5xx_returns(self) -> None:
|
|
191
191
|
if not self._func.isinit and not (
|
|
@@ -194,28 +194,28 @@ class Failure(_t.List[str]):
|
|
|
194
194
|
# no types, cannot know either way
|
|
195
195
|
if self._func.signature.rettype == _RetType.UNTYPED:
|
|
196
196
|
# confirm-return-needed
|
|
197
|
-
self._add(_E[
|
|
197
|
+
self._add(_E[501], hint=True)
|
|
198
198
|
# return type is none, so no return should be documented
|
|
199
199
|
elif self._func.docstring.returns:
|
|
200
200
|
if self._func.signature.rettype == _RetType.NONE:
|
|
201
201
|
# return-documented-for-none
|
|
202
|
-
self._add(_E[
|
|
202
|
+
self._add(_E[502])
|
|
203
203
|
# return type is some, so return should be documented
|
|
204
204
|
elif self._func.signature.returns:
|
|
205
205
|
# return-missing
|
|
206
206
|
self._add(
|
|
207
|
-
_E[
|
|
207
|
+
_E[503],
|
|
208
208
|
hint=_has_bad_return(str(self._func.docstring.string)),
|
|
209
209
|
)
|
|
210
210
|
elif self._func.docstring.returns:
|
|
211
211
|
# method is init, so no return should be documented
|
|
212
212
|
if self._func.isinit:
|
|
213
213
|
# class-return-documented
|
|
214
|
-
self._add(_E[
|
|
214
|
+
self._add(_E[504], hint=True)
|
|
215
215
|
# method is property and not set to document property
|
|
216
216
|
elif self._func.isproperty and not self._check_property_returns:
|
|
217
217
|
# return-documented-for-property
|
|
218
|
-
self._add(_E[
|
|
218
|
+
self._add(_E[505], hint=True)
|
|
219
219
|
|
|
220
220
|
@property
|
|
221
221
|
def func(self) -> _Function:
|
|
@@ -6,12 +6,13 @@ docsig.messages
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import typing as _t
|
|
9
|
+
from warnings import warn as _warn
|
|
9
10
|
|
|
10
11
|
#: Error code for unknown errors.
|
|
11
|
-
UNKNOWN = "
|
|
12
|
+
UNKNOWN = "SIG000"
|
|
12
13
|
|
|
13
14
|
#: Default template to format message strings.
|
|
14
|
-
TEMPLATE = "{
|
|
15
|
+
TEMPLATE = "{ref}: {description} ({symbolic})"
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
class Message(_t.NamedTuple):
|
|
@@ -39,7 +40,7 @@ class Message(_t.NamedTuple):
|
|
|
39
40
|
This might exist due to a typo or an attempt to retrieve an
|
|
40
41
|
error that does not exist.
|
|
41
42
|
"""
|
|
42
|
-
return self.
|
|
43
|
+
return self.ref != UNKNOWN
|
|
43
44
|
|
|
44
45
|
def fstring(self, template: str) -> str:
|
|
45
46
|
"""Return message values as a string.
|
|
@@ -48,7 +49,7 @@ class Message(_t.NamedTuple):
|
|
|
48
49
|
:return: Formatted string.
|
|
49
50
|
"""
|
|
50
51
|
return template.format(
|
|
51
|
-
|
|
52
|
+
ref=self.ref,
|
|
52
53
|
description=self.description,
|
|
53
54
|
symbolic=self.symbolic,
|
|
54
55
|
)
|
|
@@ -68,7 +69,18 @@ class MessageMap(_t.Dict[int, Message]):
|
|
|
68
69
|
:return: Message if valid ref else an unknown message type.
|
|
69
70
|
"""
|
|
70
71
|
for value in self.values():
|
|
71
|
-
if ref
|
|
72
|
+
if ref == value.code:
|
|
73
|
+
_warn(
|
|
74
|
+
"Exxx errors are deprecated and might not be supported in "
|
|
75
|
+
"a future version, see "
|
|
76
|
+
"https://docsig.readthedocs.io/en/latest/deprecated/"
|
|
77
|
+
"messages.html",
|
|
78
|
+
category=DeprecationWarning,
|
|
79
|
+
stacklevel=6,
|
|
80
|
+
)
|
|
81
|
+
return value
|
|
82
|
+
|
|
83
|
+
if ref in (value.ref, value.symbolic):
|
|
72
84
|
return value
|
|
73
85
|
|
|
74
86
|
return Message(UNKNOWN, UNKNOWN, ref)
|
|
@@ -84,144 +96,142 @@ class MessageMap(_t.Dict[int, Message]):
|
|
|
84
96
|
@property
|
|
85
97
|
def all(self) -> Messages:
|
|
86
98
|
"""Get all messages that aren't a config error."""
|
|
87
|
-
return Messages(
|
|
88
|
-
v for k, v in self.items() if str(k).startswith(str(1))
|
|
89
|
-
)
|
|
99
|
+
return Messages(v for k, v in self.items() if len(str(k)) > 1)
|
|
90
100
|
|
|
91
101
|
|
|
92
102
|
# SIGxxx: Error
|
|
93
103
|
E = MessageMap(
|
|
94
104
|
{
|
|
95
105
|
#: SIG0xx Config
|
|
96
|
-
|
|
106
|
+
1: Message(
|
|
97
107
|
"SIG001",
|
|
98
108
|
"E201",
|
|
99
109
|
"unknown module comment directive '{directive}'",
|
|
100
110
|
"unknown-module-directive",
|
|
101
111
|
),
|
|
102
|
-
|
|
112
|
+
2: Message(
|
|
103
113
|
"SIG002",
|
|
104
114
|
"E202",
|
|
105
115
|
"unknown inline comment directive '{directive}'",
|
|
106
116
|
"unknown-inline-directive",
|
|
107
117
|
),
|
|
108
|
-
|
|
118
|
+
3: Message(
|
|
109
119
|
"SIG003",
|
|
110
120
|
"E203",
|
|
111
121
|
"unknown module comment option for {directive} '{option}'",
|
|
112
122
|
"unknown-module-directive-option",
|
|
113
123
|
),
|
|
114
|
-
|
|
124
|
+
4: Message(
|
|
115
125
|
"SIG004",
|
|
116
126
|
"E204",
|
|
117
127
|
"unknown inline comment option for {directive} '{option}'",
|
|
118
128
|
"unknown-inline-directive-option",
|
|
119
129
|
),
|
|
120
130
|
#: SIG1xx Missing
|
|
121
|
-
|
|
131
|
+
101: Message(
|
|
122
132
|
"SIG101",
|
|
123
133
|
"E113",
|
|
124
134
|
"function is missing a docstring",
|
|
125
135
|
"function-doc-missing",
|
|
126
136
|
),
|
|
127
|
-
|
|
137
|
+
102: Message(
|
|
128
138
|
"SIG102",
|
|
129
139
|
"E114",
|
|
130
140
|
"class is missing a docstring",
|
|
131
141
|
"class-doc-missing",
|
|
132
142
|
),
|
|
133
143
|
#: SIG2xx Signature
|
|
134
|
-
|
|
144
|
+
201: Message(
|
|
135
145
|
"SIG201",
|
|
136
146
|
"E106",
|
|
137
147
|
"duplicate parameters found",
|
|
138
148
|
"duplicate-params-found",
|
|
139
149
|
),
|
|
140
|
-
|
|
150
|
+
202: Message(
|
|
141
151
|
"SIG202",
|
|
142
152
|
"E102",
|
|
143
153
|
"includes parameters that do not exist",
|
|
144
154
|
"params-do-not-exist",
|
|
145
155
|
),
|
|
146
|
-
|
|
156
|
+
203: Message(
|
|
147
157
|
"SIG203",
|
|
148
158
|
"E103",
|
|
149
159
|
"parameters missing",
|
|
150
160
|
"params-missing",
|
|
151
161
|
),
|
|
152
162
|
#: SIG3xx Parameters
|
|
153
|
-
|
|
163
|
+
301: Message(
|
|
154
164
|
"SIG301",
|
|
155
165
|
"E117",
|
|
156
166
|
"description missing from parameter",
|
|
157
167
|
"description-missing",
|
|
158
168
|
),
|
|
159
|
-
|
|
169
|
+
302: Message(
|
|
160
170
|
"SIG302",
|
|
161
171
|
"E115",
|
|
162
172
|
"syntax error in description",
|
|
163
173
|
"syntax-error-in-description",
|
|
164
174
|
),
|
|
165
|
-
|
|
175
|
+
303: Message(
|
|
166
176
|
"SIG303",
|
|
167
177
|
"E107",
|
|
168
178
|
"parameter appears to be incorrectly documented",
|
|
169
179
|
"param-incorrectly-documented",
|
|
170
180
|
),
|
|
171
181
|
#: SIG4xx Description
|
|
172
|
-
|
|
182
|
+
401: Message(
|
|
173
183
|
"SIG401",
|
|
174
184
|
"E116",
|
|
175
185
|
"param not indented correctly",
|
|
176
186
|
"incorrect-indent",
|
|
177
187
|
),
|
|
178
|
-
|
|
188
|
+
402: Message(
|
|
179
189
|
"SIG402",
|
|
180
190
|
"E101",
|
|
181
191
|
"parameters out of order",
|
|
182
192
|
"params-out-of-order",
|
|
183
193
|
),
|
|
184
|
-
|
|
194
|
+
403: Message(
|
|
185
195
|
"SIG403",
|
|
186
196
|
"E112",
|
|
187
197
|
"spelling error found in documented parameter",
|
|
188
198
|
"spelling-error",
|
|
189
199
|
),
|
|
190
|
-
|
|
200
|
+
404: Message(
|
|
191
201
|
"SIG404",
|
|
192
202
|
"E110",
|
|
193
203
|
"documented parameter not equal to its respective argument",
|
|
194
204
|
"param-not-equal-to-arg",
|
|
195
205
|
),
|
|
196
206
|
#: SIG5xx Returns
|
|
197
|
-
|
|
207
|
+
501: Message(
|
|
198
208
|
"SIG501",
|
|
199
209
|
"E109",
|
|
200
210
|
"cannot determine whether a return statement should exist",
|
|
201
211
|
"confirm-return-needed",
|
|
202
212
|
"annotate type to indicate whether return documentation needed",
|
|
203
213
|
),
|
|
204
|
-
|
|
214
|
+
502: Message(
|
|
205
215
|
"SIG502",
|
|
206
216
|
"E104",
|
|
207
217
|
"return statement documented for None",
|
|
208
218
|
"return-documented-for-none",
|
|
209
219
|
),
|
|
210
|
-
|
|
220
|
+
503: Message(
|
|
211
221
|
"SIG503",
|
|
212
222
|
"E105",
|
|
213
223
|
"return missing from docstring",
|
|
214
224
|
"return-missing",
|
|
215
225
|
"it is possible a syntax error could be causing this",
|
|
216
226
|
),
|
|
217
|
-
|
|
227
|
+
504: Message(
|
|
218
228
|
"SIG504",
|
|
219
229
|
"E111",
|
|
220
230
|
"return statement documented for class",
|
|
221
231
|
"class-return-documented",
|
|
222
232
|
"a class does not return a value during instantiation",
|
|
223
233
|
),
|
|
224
|
-
|
|
234
|
+
505: Message(
|
|
225
235
|
"SIG505",
|
|
226
236
|
"E108",
|
|
227
237
|
"return statement documented for property",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|