docsig 0.64.1__tar.gz → 0.66.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.64.1 → docsig-0.66.0}/PKG-INFO +4 -4
- {docsig-0.64.1 → docsig-0.66.0}/README.rst +3 -3
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_config.py +0 -9
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_core.py +22 -23
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_decorators.py +0 -23
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_files.py +1 -1
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_main.py +0 -1
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_module.py +16 -6
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_report.py +7 -0
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_stub.py +6 -2
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_version.py +1 -1
- {docsig-0.64.1 → docsig-0.66.0}/docsig/messages.py +7 -0
- {docsig-0.64.1 → docsig-0.66.0}/docsig/plugin.py +2 -1
- {docsig-0.64.1 → docsig-0.66.0}/pyproject.toml +3 -3
- {docsig-0.64.1 → docsig-0.66.0}/LICENSE +0 -0
- {docsig-0.64.1 → docsig-0.66.0}/docsig/__init__.py +0 -0
- {docsig-0.64.1 → docsig-0.66.0}/docsig/__main__.py +0 -0
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_directives.py +0 -0
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_hooks.py +0 -0
- {docsig-0.64.1 → docsig-0.66.0}/docsig/_utils.py +0 -0
- {docsig-0.64.1 → docsig-0.66.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.66.0
|
|
4
4
|
Summary: Check signature params for proper documentation
|
|
5
5
|
Home-page: https://pypi.org/project/docsig/
|
|
6
6
|
License: MIT
|
|
@@ -181,7 +181,7 @@ ensure your installation has registered `docsig`
|
|
|
181
181
|
.. code-block:: console
|
|
182
182
|
|
|
183
183
|
$ flake8 --version
|
|
184
|
-
7.1.0 (docsig: 0.
|
|
184
|
+
7.1.0 (docsig: 0.66.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
|
|
185
185
|
|
|
186
186
|
And now use `flake8` to lint your files
|
|
187
187
|
|
|
@@ -270,7 +270,7 @@ Standalone
|
|
|
270
270
|
|
|
271
271
|
repos:
|
|
272
272
|
- repo: https://github.com/jshwi/docsig
|
|
273
|
-
rev: v0.
|
|
273
|
+
rev: v0.66.0
|
|
274
274
|
hooks:
|
|
275
275
|
- id: docsig
|
|
276
276
|
args:
|
|
@@ -289,7 +289,7 @@ or integrated with ``flake8``
|
|
|
289
289
|
hooks:
|
|
290
290
|
- id: flake8
|
|
291
291
|
additional_dependencies:
|
|
292
|
-
- docsig==0.
|
|
292
|
+
- docsig==0.66.0
|
|
293
293
|
args:
|
|
294
294
|
- "--sig-check-class"
|
|
295
295
|
- "--sig-check-dunders"
|
|
@@ -153,7 +153,7 @@ ensure your installation has registered `docsig`
|
|
|
153
153
|
.. code-block:: console
|
|
154
154
|
|
|
155
155
|
$ flake8 --version
|
|
156
|
-
7.1.0 (docsig: 0.
|
|
156
|
+
7.1.0 (docsig: 0.66.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
|
|
157
157
|
|
|
158
158
|
And now use `flake8` to lint your files
|
|
159
159
|
|
|
@@ -242,7 +242,7 @@ Standalone
|
|
|
242
242
|
|
|
243
243
|
repos:
|
|
244
244
|
- repo: https://github.com/jshwi/docsig
|
|
245
|
-
rev: v0.
|
|
245
|
+
rev: v0.66.0
|
|
246
246
|
hooks:
|
|
247
247
|
- id: docsig
|
|
248
248
|
args:
|
|
@@ -261,7 +261,7 @@ or integrated with ``flake8``
|
|
|
261
261
|
hooks:
|
|
262
262
|
- id: flake8
|
|
263
263
|
additional_dependencies:
|
|
264
|
-
- docsig==0.
|
|
264
|
+
- docsig==0.66.0
|
|
265
265
|
args:
|
|
266
266
|
- "--sig-check-class"
|
|
267
267
|
- "--sig-check-dunders"
|
|
@@ -254,13 +254,4 @@ def parse_args(args: _t.Sequence[str] | None = None) -> _a.Namespace:
|
|
|
254
254
|
metavar="PATH",
|
|
255
255
|
help="path glob patterns to exclude from checks",
|
|
256
256
|
)
|
|
257
|
-
|
|
258
|
-
# deprecated
|
|
259
|
-
parser.add_argument(
|
|
260
|
-
"-S",
|
|
261
|
-
"--summary",
|
|
262
|
-
action="store_true",
|
|
263
|
-
help=_a.SUPPRESS,
|
|
264
|
-
)
|
|
265
|
-
|
|
266
257
|
return parser.parse_args(args)
|
|
@@ -95,7 +95,7 @@ def _run_check( # pylint: disable=too-many-arguments,too-many-locals
|
|
|
95
95
|
failures.append(failure)
|
|
96
96
|
|
|
97
97
|
if check_nested:
|
|
98
|
-
for func in child:
|
|
98
|
+
for func in child.children:
|
|
99
99
|
_run_check(
|
|
100
100
|
func,
|
|
101
101
|
child,
|
|
@@ -114,7 +114,7 @@ def _run_check( # pylint: disable=too-many-arguments,too-many-locals
|
|
|
114
114
|
)
|
|
115
115
|
else:
|
|
116
116
|
# this is a class
|
|
117
|
-
for func in child:
|
|
117
|
+
for func in child.children:
|
|
118
118
|
_run_check(
|
|
119
119
|
func,
|
|
120
120
|
child,
|
|
@@ -134,28 +134,28 @@ def _run_check( # pylint: disable=too-many-arguments,too-many-locals
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
def _from_file(
|
|
137
|
-
|
|
137
|
+
path: _Path,
|
|
138
138
|
messages: _Messages,
|
|
139
139
|
ignore_args: bool,
|
|
140
140
|
ignore_kwargs: bool,
|
|
141
141
|
check_class_constructor,
|
|
142
142
|
) -> _Parent:
|
|
143
143
|
try:
|
|
144
|
-
string =
|
|
144
|
+
string = path.read_text(encoding="utf-8")
|
|
145
145
|
parent = _from_str(
|
|
146
146
|
messages=messages,
|
|
147
147
|
string=string,
|
|
148
|
-
|
|
148
|
+
path=path,
|
|
149
149
|
ignore_args=ignore_args,
|
|
150
150
|
ignore_kwargs=ignore_kwargs,
|
|
151
151
|
check_class_constructor=check_class_constructor,
|
|
152
152
|
)
|
|
153
153
|
except UnicodeDecodeError as err:
|
|
154
154
|
logger = _logging.getLogger(__package__)
|
|
155
|
-
logger.debug(_FILE_INFO,
|
|
155
|
+
logger.debug(_FILE_INFO, path, str(err).replace("\n", " "))
|
|
156
156
|
parent = _Parent(error=_Error.UNICODE)
|
|
157
157
|
|
|
158
|
-
if parent.error is not None and not
|
|
158
|
+
if parent.error is not None and not path.name.endswith(".py"):
|
|
159
159
|
parent = _Parent()
|
|
160
160
|
|
|
161
161
|
return parent
|
|
@@ -167,23 +167,23 @@ def _from_str( # pylint: disable=too-many-arguments
|
|
|
167
167
|
ignore_args: bool,
|
|
168
168
|
ignore_kwargs: bool,
|
|
169
169
|
check_class_constructor,
|
|
170
|
-
|
|
170
|
+
path: _Path | None = None,
|
|
171
171
|
) -> _Parent:
|
|
172
172
|
logger = _logging.getLogger(__package__)
|
|
173
173
|
try:
|
|
174
174
|
parent = _Parent(
|
|
175
175
|
_ast.parse(string),
|
|
176
176
|
_Directives.from_text(string, messages),
|
|
177
|
-
|
|
177
|
+
path,
|
|
178
178
|
ignore_args,
|
|
179
179
|
ignore_kwargs,
|
|
180
180
|
check_class_constructor,
|
|
181
181
|
)
|
|
182
182
|
logger.debug(
|
|
183
|
-
_FILE_INFO,
|
|
183
|
+
_FILE_INFO, path or "stdin", "Parsing Python code successful"
|
|
184
184
|
)
|
|
185
185
|
except _ast.AstroidSyntaxError as err:
|
|
186
|
-
logger.debug(_FILE_INFO,
|
|
186
|
+
logger.debug(_FILE_INFO, path or "stdin", str(err).replace("\n", " "))
|
|
187
187
|
parent = _Parent(error=_Error.SYNTAX)
|
|
188
188
|
|
|
189
189
|
return parent
|
|
@@ -205,7 +205,7 @@ def _get_failures( # pylint: disable=too-many-arguments
|
|
|
205
205
|
target: _Messages,
|
|
206
206
|
) -> _Failures:
|
|
207
207
|
failures = _Failures()
|
|
208
|
-
for top_level in module:
|
|
208
|
+
for top_level in module.children:
|
|
209
209
|
if (
|
|
210
210
|
not top_level.isprotected
|
|
211
211
|
or check_protected
|
|
@@ -259,7 +259,7 @@ def _report(
|
|
|
259
259
|
|
|
260
260
|
|
|
261
261
|
def runner( # pylint: disable=too-many-locals,too-many-arguments
|
|
262
|
-
|
|
262
|
+
path: _Path,
|
|
263
263
|
disable: _Messages | None = None,
|
|
264
264
|
check_class: bool = False,
|
|
265
265
|
check_class_constructor: bool = False,
|
|
@@ -278,7 +278,7 @@ def runner( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
278
278
|
) -> _Failures:
|
|
279
279
|
"""Per path runner.
|
|
280
280
|
|
|
281
|
-
:param
|
|
281
|
+
:param path: Path to check.
|
|
282
282
|
:param disable: Messages to disable.
|
|
283
283
|
:param check_class: Check class docstrings.
|
|
284
284
|
:param check_class_constructor: Check ``__init__`` methods. Note
|
|
@@ -300,7 +300,7 @@ def runner( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
300
300
|
:return: Exit status for whether test failed or not.
|
|
301
301
|
"""
|
|
302
302
|
module = _from_file(
|
|
303
|
-
|
|
303
|
+
path,
|
|
304
304
|
disable or _Messages(),
|
|
305
305
|
ignore_args,
|
|
306
306
|
ignore_kwargs,
|
|
@@ -324,7 +324,6 @@ def runner( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
@_decorators.parse_msgs
|
|
327
|
-
@_decorators.handle_deprecations
|
|
328
327
|
@_decorators.validate_args
|
|
329
328
|
def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
330
329
|
*path: str | _Path,
|
|
@@ -392,21 +391,21 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
392
391
|
if list_checks:
|
|
393
392
|
return int(bool(_print_checks())) # type: ignore
|
|
394
393
|
|
|
395
|
-
|
|
394
|
+
exclude_ = [_DEFAULT_EXCLUDES]
|
|
396
395
|
if exclude is not None:
|
|
397
|
-
|
|
396
|
+
exclude_.append(exclude)
|
|
398
397
|
|
|
399
398
|
if string is None:
|
|
400
399
|
retcodes = [0]
|
|
401
400
|
paths = _Paths(
|
|
402
401
|
*path,
|
|
403
|
-
patterns=
|
|
404
|
-
excludes=excludes
|
|
402
|
+
patterns=exclude_,
|
|
403
|
+
excludes=excludes,
|
|
405
404
|
include_ignored=include_ignored,
|
|
406
405
|
)
|
|
407
|
-
for
|
|
406
|
+
for path_ in paths:
|
|
408
407
|
failures = runner(
|
|
409
|
-
|
|
408
|
+
path_,
|
|
410
409
|
disable,
|
|
411
410
|
check_class,
|
|
412
411
|
check_class_constructor,
|
|
@@ -423,7 +422,7 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
423
422
|
no_ansi,
|
|
424
423
|
target,
|
|
425
424
|
)
|
|
426
|
-
retcodes.append(_report(failures, str(
|
|
425
|
+
retcodes.append(_report(failures, str(path_), no_ansi))
|
|
427
426
|
|
|
428
427
|
return max(retcodes)
|
|
429
428
|
|
|
@@ -9,7 +9,6 @@ import functools as _functools
|
|
|
9
9
|
import sys as _sys
|
|
10
10
|
import typing as _t
|
|
11
11
|
from pathlib import Path as _Path
|
|
12
|
-
from warnings import warn as _warn
|
|
13
12
|
|
|
14
13
|
from .messages import E as _E
|
|
15
14
|
|
|
@@ -35,28 +34,6 @@ def parse_msgs(func: _WrappedFuncType) -> _WrappedFuncType:
|
|
|
35
34
|
return _wrapper
|
|
36
35
|
|
|
37
36
|
|
|
38
|
-
def handle_deprecations(func: _WrappedFuncType) -> _WrappedFuncType:
|
|
39
|
-
"""Allow, but warn, of deprecated arguments.
|
|
40
|
-
|
|
41
|
-
:param func: Function to wrap.
|
|
42
|
-
:return: Wrapped function.
|
|
43
|
-
"""
|
|
44
|
-
|
|
45
|
-
@_functools.wraps(func)
|
|
46
|
-
def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> str | int:
|
|
47
|
-
if kwargs.pop("summary", None):
|
|
48
|
-
_warn(
|
|
49
|
-
"summary is deprecated and will be removed in a future"
|
|
50
|
-
" version",
|
|
51
|
-
category=DeprecationWarning,
|
|
52
|
-
stacklevel=4,
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
return func(*args, **kwargs)
|
|
56
|
-
|
|
57
|
-
return _wrapper
|
|
58
|
-
|
|
59
|
-
|
|
60
37
|
def validate_args(func: _FuncType) -> _WrappedFuncType:
|
|
61
38
|
"""Confirm args passed to function are valid.
|
|
62
39
|
|
|
@@ -31,7 +31,7 @@ class _Imports(_t.Dict[str, str]):
|
|
|
31
31
|
"""Represents python imports."""
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
class Parent
|
|
34
|
+
class Parent: # pylint: disable=too-many-instance-attributes
|
|
35
35
|
"""Represents an object that contains functions or methods.
|
|
36
36
|
|
|
37
37
|
:param node: Parent's abstract syntax tree.
|
|
@@ -64,13 +64,14 @@ class Parent(_t.List["Parent"]):
|
|
|
64
64
|
self._ignore_args = ignore_args
|
|
65
65
|
self._ignore_kwargs = ignore_kwargs
|
|
66
66
|
self._check_class_constructor = check_class_constructor
|
|
67
|
+
self._children = _Children()
|
|
68
|
+
self._imports = imports or _Imports()
|
|
69
|
+
self._overloads = _Overloads()
|
|
67
70
|
if node is None:
|
|
68
71
|
if not isinstance(self, Function) and error is not None:
|
|
69
|
-
self.append(Function(path, error=error))
|
|
72
|
+
self._children.append(Function(path, error=error))
|
|
70
73
|
else:
|
|
71
74
|
self._name = node.name
|
|
72
|
-
self._overloads = _Overloads()
|
|
73
|
-
self._imports = imports or _Imports()
|
|
74
75
|
self._parse_ast(node, directives or _Directives(), path)
|
|
75
76
|
|
|
76
77
|
def _parse_ast(
|
|
@@ -121,9 +122,9 @@ class Parent(_t.List["Parent"]):
|
|
|
121
122
|
self._overloads[func.name].signature.rettype
|
|
122
123
|
)
|
|
123
124
|
|
|
124
|
-
self.append(func)
|
|
125
|
+
self._children.append(func)
|
|
125
126
|
elif isinstance(subnode, _ast.ClassDef):
|
|
126
|
-
self.append(
|
|
127
|
+
self._children.append(
|
|
127
128
|
Parent(
|
|
128
129
|
subnode,
|
|
129
130
|
directives,
|
|
@@ -147,6 +148,11 @@ class Parent(_t.List["Parent"]):
|
|
|
147
148
|
"""Represents an unrecoverable error, if any."""
|
|
148
149
|
return self._error
|
|
149
150
|
|
|
151
|
+
@property
|
|
152
|
+
def children(self) -> _Children:
|
|
153
|
+
"""Children of this parent."""
|
|
154
|
+
return self._children
|
|
155
|
+
|
|
150
156
|
|
|
151
157
|
class Function(Parent):
|
|
152
158
|
"""Represents a function with signature and docstring parameters.
|
|
@@ -337,3 +343,7 @@ class Function(Parent):
|
|
|
337
343
|
|
|
338
344
|
class _Overloads(_t.Dict[str, Function]):
|
|
339
345
|
"""Represents overloaded methods."""
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
class _Children(_t.List[_t.Union[Parent, Function]]):
|
|
349
|
+
"""Represents children of object."""
|
|
@@ -180,6 +180,13 @@ class Failure(_t.List[Failed]):
|
|
|
180
180
|
elif doc.name == _UNNAMED:
|
|
181
181
|
# param-incorrectly-documented
|
|
182
182
|
self._add(_E[303])
|
|
183
|
+
elif doc.closing_token != ":":
|
|
184
|
+
# bad-closing-token
|
|
185
|
+
self._add(
|
|
186
|
+
_E[304],
|
|
187
|
+
token=doc.closing_token,
|
|
188
|
+
hint=True,
|
|
189
|
+
)
|
|
183
190
|
|
|
184
191
|
def _sig4xx_parameters(self, doc: _Param, sig: _Param) -> None:
|
|
185
192
|
if doc.indent > 0:
|
|
@@ -84,6 +84,7 @@ class Param(_t.NamedTuple):
|
|
|
84
84
|
name: str | None = None
|
|
85
85
|
description: str | None = None
|
|
86
86
|
indent: int = 0
|
|
87
|
+
closing_token: str = ":"
|
|
87
88
|
|
|
88
89
|
def __eq__(self, other: object) -> bool:
|
|
89
90
|
if not isinstance(other, Param):
|
|
@@ -314,7 +315,9 @@ class Docstring(_Stub):
|
|
|
314
315
|
string = cls._normalize_docstring(node.value)
|
|
315
316
|
returns = bool(_re.search(r":returns?:", string))
|
|
316
317
|
docstring = cls(string, returns)
|
|
317
|
-
for match in _re.findall(
|
|
318
|
+
for match in _re.findall(
|
|
319
|
+
r":(.*?)([^\w\s])((?:.|\n)*?)(?=\n:|$)", string
|
|
320
|
+
):
|
|
318
321
|
if match:
|
|
319
322
|
kinds = match[0].split()
|
|
320
323
|
if kinds:
|
|
@@ -322,8 +325,9 @@ class Docstring(_Stub):
|
|
|
322
325
|
Param(
|
|
323
326
|
DocType.from_str(kinds[0]),
|
|
324
327
|
UNNAMED if len(kinds) == 1 else kinds[1],
|
|
325
|
-
match[
|
|
328
|
+
match[2] or None,
|
|
326
329
|
int(indent_anomaly),
|
|
330
|
+
match[1],
|
|
327
331
|
)
|
|
328
332
|
)
|
|
329
333
|
|
|
@@ -187,6 +187,13 @@ E = MessageMap(
|
|
|
187
187
|
"parameter appears to be incorrectly documented",
|
|
188
188
|
"param-incorrectly-documented",
|
|
189
189
|
),
|
|
190
|
+
304: Message(
|
|
191
|
+
"SIG304",
|
|
192
|
+
"SIG304",
|
|
193
|
+
"bad token used to close parameter declaration '{token}'",
|
|
194
|
+
"bad-closing-token",
|
|
195
|
+
"close a parameter declaration with ':'",
|
|
196
|
+
),
|
|
190
197
|
#: SIG4xx Description
|
|
191
198
|
401: Message(
|
|
192
199
|
"SIG401",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import ast
|
|
4
4
|
import typing as t
|
|
5
5
|
from argparse import Namespace
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
|
|
7
8
|
from ._config import get_config as _get_config
|
|
8
9
|
from ._config import merge_configs as _merge_configs
|
|
@@ -147,7 +148,7 @@ class Docsig:
|
|
|
147
148
|
else:
|
|
148
149
|
setup_logger(self.a.verbose)
|
|
149
150
|
results = runner(
|
|
150
|
-
self.filename,
|
|
151
|
+
Path(self.filename),
|
|
151
152
|
check_class=self.a.check_class,
|
|
152
153
|
check_class_constructor=self.a.check_class_constructor,
|
|
153
154
|
check_dunders=self.a.check_dunders,
|
|
@@ -11,7 +11,7 @@ line-length = 79
|
|
|
11
11
|
allow_dirty = true
|
|
12
12
|
commit = true
|
|
13
13
|
commit_args = "-sS"
|
|
14
|
-
current_version = "0.
|
|
14
|
+
current_version = "0.66.0"
|
|
15
15
|
message = "bump: version {current_version} → {new_version}"
|
|
16
16
|
sign_tags = true
|
|
17
17
|
tag = true
|
|
@@ -131,7 +131,7 @@ maintainers = [
|
|
|
131
131
|
name = "docsig"
|
|
132
132
|
readme = "README.rst"
|
|
133
133
|
repository = "https://github.com/jshwi/docsig"
|
|
134
|
-
version = "0.
|
|
134
|
+
version = "0.66.0"
|
|
135
135
|
|
|
136
136
|
[tool.poetry.dependencies]
|
|
137
137
|
Sphinx = "^7.0.0"
|
|
@@ -143,7 +143,7 @@ wcmatch = ">=8.5.2,<11.0.0"
|
|
|
143
143
|
|
|
144
144
|
[tool.poetry.group.dev.dependencies]
|
|
145
145
|
black = "^24.4.2"
|
|
146
|
-
bump-my-version = ">=0.24.1,<0.
|
|
146
|
+
bump-my-version = ">=0.24.1,<0.30.0"
|
|
147
147
|
deptry = ">=0.16.1,<0.21.0"
|
|
148
148
|
docformatter = "^1.7.5"
|
|
149
149
|
flynt = "^1.0.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|