docsig 0.82.0__tar.gz → 0.82.2__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.82.0 → docsig-0.82.2}/PKG-INFO +4 -4
- {docsig-0.82.0 → docsig-0.82.2}/README.rst +3 -3
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_config.py +1 -1
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_core.py +1 -1
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_decorators.py +2 -2
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_directives.py +2 -3
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_files.py +2 -3
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_module.py +18 -18
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_parsers.py +4 -7
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_report.py +14 -12
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_stub.py +33 -42
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_utils.py +1 -2
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_version.py +1 -1
- {docsig-0.82.0 → docsig-0.82.2}/docsig/messages.py +8 -3
- {docsig-0.82.0 → docsig-0.82.2}/docsig/plugin.py +1 -1
- {docsig-0.82.0 → docsig-0.82.2}/pyproject.toml +13 -2
- {docsig-0.82.0 → docsig-0.82.2}/LICENSE +0 -0
- {docsig-0.82.0 → docsig-0.82.2}/docsig/__init__.py +0 -0
- {docsig-0.82.0 → docsig-0.82.2}/docsig/__main__.py +0 -0
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_check.py +0 -0
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_hooks.py +0 -0
- {docsig-0.82.0 → docsig-0.82.2}/docsig/_main.py +0 -0
- {docsig-0.82.0 → docsig-0.82.2}/docsig/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: docsig
|
|
3
|
-
Version: 0.82.
|
|
3
|
+
Version: 0.82.2
|
|
4
4
|
Summary: Check signature params for proper documentation
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -184,7 +184,7 @@ ensure your installation has registered `docsig`
|
|
|
184
184
|
.. code-block:: console
|
|
185
185
|
|
|
186
186
|
$ flake8 --version
|
|
187
|
-
7.3.0 (docsig: 0.82.
|
|
187
|
+
7.3.0 (docsig: 0.82.2, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
|
|
188
188
|
|
|
189
189
|
And now use `flake8` to lint your files
|
|
190
190
|
|
|
@@ -270,7 +270,7 @@ Standalone
|
|
|
270
270
|
|
|
271
271
|
repos:
|
|
272
272
|
- repo: https://github.com/jshwi/docsig
|
|
273
|
-
rev: v0.82.
|
|
273
|
+
rev: v0.82.2
|
|
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.82.
|
|
292
|
+
- docsig==0.82.2
|
|
293
293
|
args:
|
|
294
294
|
- "--sig-check-class"
|
|
295
295
|
- "--sig-check-dunders"
|
|
@@ -155,7 +155,7 @@ ensure your installation has registered `docsig`
|
|
|
155
155
|
.. code-block:: console
|
|
156
156
|
|
|
157
157
|
$ flake8 --version
|
|
158
|
-
7.3.0 (docsig: 0.82.
|
|
158
|
+
7.3.0 (docsig: 0.82.2, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
|
|
159
159
|
|
|
160
160
|
And now use `flake8` to lint your files
|
|
161
161
|
|
|
@@ -241,7 +241,7 @@ Standalone
|
|
|
241
241
|
|
|
242
242
|
repos:
|
|
243
243
|
- repo: https://github.com/jshwi/docsig
|
|
244
|
-
rev: v0.82.
|
|
244
|
+
rev: v0.82.2
|
|
245
245
|
hooks:
|
|
246
246
|
- id: docsig
|
|
247
247
|
args:
|
|
@@ -260,7 +260,7 @@ or integrated with ``flake8``
|
|
|
260
260
|
hooks:
|
|
261
261
|
- id: flake8
|
|
262
262
|
additional_dependencies:
|
|
263
|
-
- docsig==0.82.
|
|
263
|
+
- docsig==0.82.2
|
|
264
264
|
args:
|
|
265
265
|
- "--sig-check-class"
|
|
266
266
|
- "--sig-check-dunders"
|
|
@@ -364,7 +364,7 @@ class Config:
|
|
|
364
364
|
target: _Messages = _field(default_factory=_Messages)
|
|
365
365
|
disable: _Messages = _field(default_factory=_Messages)
|
|
366
366
|
exclude: list[str] = _field(default_factory=list)
|
|
367
|
-
excludes: list[str]
|
|
367
|
+
excludes: list[str] = _field(default_factory=list)
|
|
368
368
|
list_checks: bool = False
|
|
369
369
|
include_ignored: bool = False
|
|
370
370
|
no_ansi: bool = False
|
|
@@ -199,7 +199,7 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
199
199
|
target=target or _Messages(),
|
|
200
200
|
disable=disable,
|
|
201
201
|
exclude=exclude_,
|
|
202
|
-
excludes=excludes,
|
|
202
|
+
excludes=excludes or [],
|
|
203
203
|
)
|
|
204
204
|
setup_logger(config.verbose)
|
|
205
205
|
if config.list_checks:
|
|
@@ -12,8 +12,8 @@ from pathlib import Path as _Path
|
|
|
12
12
|
|
|
13
13
|
from .messages import E as _E
|
|
14
14
|
|
|
15
|
-
_FuncType = _t.Callable[...,
|
|
16
|
-
_WrappedFuncType = _t.Callable[...,
|
|
15
|
+
_FuncType = _t.Callable[..., int]
|
|
16
|
+
_WrappedFuncType = _t.Callable[..., str | int]
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def parse_msgs(func: _WrappedFuncType) -> _WrappedFuncType:
|
|
@@ -8,14 +8,13 @@ Parsing and storage for docsig comment directives.
|
|
|
8
8
|
from __future__ import annotations as _
|
|
9
9
|
|
|
10
10
|
import tokenize as _tokenize
|
|
11
|
-
import typing as _t
|
|
12
11
|
from io import StringIO as _StringIO
|
|
13
12
|
|
|
14
13
|
from .messages import E as _E
|
|
15
14
|
from .messages import Messages as _Messages
|
|
16
15
|
|
|
17
16
|
|
|
18
|
-
class Comments(
|
|
17
|
+
class Comments(list["Comment"]):
|
|
19
18
|
"""List of comments."""
|
|
20
19
|
|
|
21
20
|
|
|
@@ -96,7 +95,7 @@ class Comment(_Messages):
|
|
|
96
95
|
return None
|
|
97
96
|
|
|
98
97
|
|
|
99
|
-
class Directives(
|
|
98
|
+
class Directives(dict[int, tuple[Comments, _Messages]]):
|
|
100
99
|
"""Map line number to comments and disabled messages for that line.
|
|
101
100
|
|
|
102
101
|
Keys are line numbers; values are tuples of comment directives and
|
|
@@ -10,7 +10,6 @@ from __future__ import annotations as _
|
|
|
10
10
|
import logging as _logging
|
|
11
11
|
import os as _os
|
|
12
12
|
import re as _re
|
|
13
|
-
import typing as _t
|
|
14
13
|
from pathlib import Path as _Path
|
|
15
14
|
|
|
16
15
|
from pathspec import PathSpec as _PathSpec
|
|
@@ -71,7 +70,7 @@ def _glob(path: _Path, pattern: str) -> bool:
|
|
|
71
70
|
return _WcPath(str(path)).globmatch(pattern) # type: ignore
|
|
72
71
|
|
|
73
72
|
|
|
74
|
-
class Files(
|
|
73
|
+
class Files(list[_Path]):
|
|
75
74
|
"""Collect paths to check (gitignore and exclude applied).
|
|
76
75
|
|
|
77
76
|
:param paths: Path(s) to collect (files or directories).
|
|
@@ -93,7 +92,7 @@ class Files(_t.List[_Path]):
|
|
|
93
92
|
for path in list(self):
|
|
94
93
|
if str(path) != "." and (
|
|
95
94
|
any(_re.match(i, str(path)) for i in config.exclude)
|
|
96
|
-
or any(_glob(path, i) for i in config.excludes
|
|
95
|
+
or any(_glob(path, i) for i in config.excludes)
|
|
97
96
|
):
|
|
98
97
|
logger.debug(FILE_INFO, path, "in exclude list, skipping")
|
|
99
98
|
self.remove(path)
|
|
@@ -9,7 +9,6 @@ from __future__ import annotations as _
|
|
|
9
9
|
|
|
10
10
|
import re as _re
|
|
11
11
|
import typing as _t
|
|
12
|
-
from enum import Enum as _Enum
|
|
13
12
|
from pathlib import Path as _Path
|
|
14
13
|
|
|
15
14
|
import astroid as _ast
|
|
@@ -23,24 +22,21 @@ from ._stub import Signature as _Signature
|
|
|
23
22
|
from .messages import Messages as _Messages
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
class _Imports(
|
|
27
|
-
"""Represents python imports."""
|
|
25
|
+
class _Imports(dict[str, str]): ...
|
|
28
26
|
|
|
29
27
|
|
|
30
|
-
class _Overloads(
|
|
31
|
-
"""Represents overloaded methods."""
|
|
28
|
+
class _Overloads(dict[str, "Function"]): ...
|
|
32
29
|
|
|
33
30
|
|
|
34
|
-
class _Children(
|
|
35
|
-
"""Represents children of an object."""
|
|
31
|
+
class _Children(list[_t.Union["Parent", "Function"]]): ...
|
|
36
32
|
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
ERRORS = (
|
|
35
|
+
_ast.AstroidSyntaxError,
|
|
36
|
+
UnicodeDecodeError,
|
|
37
|
+
RecursionError,
|
|
38
|
+
_ast.DuplicateBasesError,
|
|
39
|
+
)
|
|
44
40
|
|
|
45
41
|
|
|
46
42
|
class Parent: # pylint: disable=too-many-instance-attributes
|
|
@@ -68,7 +64,7 @@ class Parent: # pylint: disable=too-many-instance-attributes
|
|
|
68
64
|
file: _Path | None = None,
|
|
69
65
|
config: _Config | None = None,
|
|
70
66
|
imports: _Imports | None = None,
|
|
71
|
-
error:
|
|
67
|
+
error: type[BaseException] | None = None,
|
|
72
68
|
) -> None:
|
|
73
69
|
super().__init__()
|
|
74
70
|
self._error = error
|
|
@@ -130,14 +126,18 @@ class Parent: # pylint: disable=too-many-instance-attributes
|
|
|
130
126
|
if func.isoverloaded:
|
|
131
127
|
if (
|
|
132
128
|
func.name not in self._overloads
|
|
133
|
-
or self._overloads[
|
|
129
|
+
or self._overloads[
|
|
130
|
+
func.name
|
|
131
|
+
].signature.returns.type
|
|
134
132
|
== _RetType.NONE
|
|
135
133
|
):
|
|
136
134
|
self._overloads[func.name] = func
|
|
137
135
|
else:
|
|
138
136
|
if func.name in self._overloads:
|
|
139
137
|
func.overload(
|
|
140
|
-
self._overloads[
|
|
138
|
+
self._overloads[
|
|
139
|
+
func.name
|
|
140
|
+
].signature.returns.type,
|
|
141
141
|
)
|
|
142
142
|
|
|
143
143
|
self._children.append(func)
|
|
@@ -160,7 +160,7 @@ class Parent: # pylint: disable=too-many-instance-attributes
|
|
|
160
160
|
return self._name.startswith("_")
|
|
161
161
|
|
|
162
162
|
@property
|
|
163
|
-
def error(self) ->
|
|
163
|
+
def error(self) -> type[BaseException] | None:
|
|
164
164
|
"""Unrecoverable error for this scope, if any."""
|
|
165
165
|
return self._error
|
|
166
166
|
|
|
@@ -193,7 +193,7 @@ class Function(Parent): # pylint: disable=too-many-instance-attributes
|
|
|
193
193
|
file: _Path | None = None,
|
|
194
194
|
config: _Config | None = None,
|
|
195
195
|
imports: _Imports | None = None,
|
|
196
|
-
error:
|
|
196
|
+
error: type[BaseException] | None = None,
|
|
197
197
|
) -> None:
|
|
198
198
|
super().__init__(
|
|
199
199
|
node,
|
|
@@ -15,7 +15,7 @@ import astroid as _ast
|
|
|
15
15
|
from ._config import Config as _Config
|
|
16
16
|
from ._directives import Directives as _Directives
|
|
17
17
|
from ._files import FILE_INFO as _FILE_INFO
|
|
18
|
-
from ._module import
|
|
18
|
+
from ._module import ERRORS as _ERRORS
|
|
19
19
|
from ._module import Parent as _Parent
|
|
20
20
|
|
|
21
21
|
|
|
@@ -53,12 +53,9 @@ def parse_from_string(
|
|
|
53
53
|
|
|
54
54
|
parent = _Parent(node, directives, file, config)
|
|
55
55
|
logger.debug(_FILE_INFO, source_name, "Parsing Python code successful")
|
|
56
|
-
except
|
|
56
|
+
except _ERRORS as err:
|
|
57
57
|
logger.debug(_FILE_INFO, source_name, str(err).replace("\n", " "))
|
|
58
|
-
parent = _Parent(error=
|
|
59
|
-
except RecursionError as err:
|
|
60
|
-
logger.debug(_FILE_INFO, source_name, str(err).replace("\n", " "))
|
|
61
|
-
parent = _Parent(error=_Error.RECURSION)
|
|
58
|
+
parent = _Parent(error=type(err))
|
|
62
59
|
|
|
63
60
|
return parent
|
|
64
61
|
|
|
@@ -81,7 +78,7 @@ def parse_from_file(file: _Path, config: _Config) -> _Parent:
|
|
|
81
78
|
except UnicodeDecodeError as err:
|
|
82
79
|
logger = _logging.getLogger(__package__)
|
|
83
80
|
logger.debug(_FILE_INFO, file, str(err).replace("\n", " "))
|
|
84
|
-
parent = _Parent(error=
|
|
81
|
+
parent = _Parent(error=type(err))
|
|
85
82
|
|
|
86
83
|
if parent.error is not None and not file.name.endswith(".py"):
|
|
87
84
|
parent = _Parent()
|
|
@@ -15,10 +15,10 @@ import sys as _sys
|
|
|
15
15
|
import typing as _t
|
|
16
16
|
from warnings import warn as _warn
|
|
17
17
|
|
|
18
|
+
import astroid as _ast
|
|
18
19
|
from astroid.nodes.scoped_nodes import scoped_nodes as _scoped_nodes
|
|
19
20
|
|
|
20
21
|
from ._config import Config as _Config
|
|
21
|
-
from ._module import Error as _Error
|
|
22
22
|
from ._module import Function as _Function
|
|
23
23
|
from ._stub import UNNAMED as _UNNAMED
|
|
24
24
|
from ._stub import VALID_DESCRIPTION as _VALID_DESCRIPTION
|
|
@@ -36,7 +36,7 @@ _MIN_MATCH = 0.8
|
|
|
36
36
|
_MAX_MATCH = 1.0
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
class Failures(
|
|
39
|
+
class Failures(list["Failure"]):
|
|
40
40
|
"""Sequence of Failure instances (one per function checked)."""
|
|
41
41
|
|
|
42
42
|
|
|
@@ -52,7 +52,7 @@ class Failed(_t.NamedTuple):
|
|
|
52
52
|
new: bool = False
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
class Failure(
|
|
55
|
+
class Failure(list[Failed]):
|
|
56
56
|
"""Collect docstring and signature failures for one function.
|
|
57
57
|
|
|
58
58
|
Runs configured checks and appends Failed entries for each
|
|
@@ -288,18 +288,18 @@ class Failure(_t.List[Failed]):
|
|
|
288
288
|
self._func.isproperty and not check_property_returns
|
|
289
289
|
):
|
|
290
290
|
# no types, cannot know either way
|
|
291
|
-
if self._func.signature.
|
|
291
|
+
if self._func.signature.returns.type == _RetType.UNTYPED:
|
|
292
292
|
# confirm-return-needed
|
|
293
293
|
self._add(_E[501], hint=True)
|
|
294
294
|
# return-type is none, so no return should be documented
|
|
295
|
-
elif self._func.docstring.returns:
|
|
296
|
-
if self._func.signature.
|
|
295
|
+
elif self._func.docstring.returns.returns:
|
|
296
|
+
if self._func.signature.returns.type == _RetType.NONE:
|
|
297
297
|
# return-documented-for-none
|
|
298
298
|
self._add(_E[502])
|
|
299
|
-
if self._func.docstring.
|
|
299
|
+
if self._func.docstring.returns.description_missing:
|
|
300
300
|
self._add(_E[506])
|
|
301
301
|
# return-type is some, so return should be documented
|
|
302
|
-
elif self._func.signature.returns:
|
|
302
|
+
elif self._func.signature.returns.returns:
|
|
303
303
|
# return-missing
|
|
304
304
|
lines = str(self._func.docstring.string).splitlines()
|
|
305
305
|
self._add(
|
|
@@ -310,7 +310,7 @@ class Failure(_t.List[Failed]):
|
|
|
310
310
|
and ":param" not in lines[-1]
|
|
311
311
|
),
|
|
312
312
|
)
|
|
313
|
-
elif self._func.docstring.returns:
|
|
313
|
+
elif self._func.docstring.returns.returns:
|
|
314
314
|
# this method is init, so no return should be documented
|
|
315
315
|
if self._func.isinit:
|
|
316
316
|
# class-return-documented
|
|
@@ -322,13 +322,15 @@ class Failure(_t.List[Failed]):
|
|
|
322
322
|
|
|
323
323
|
def _sig9xx_error(self) -> None:
|
|
324
324
|
# invalid-syntax
|
|
325
|
-
if self._func.error
|
|
325
|
+
if self._func.error is _ast.AstroidSyntaxError:
|
|
326
326
|
self._add(_E[901])
|
|
327
327
|
self._retcode = 123
|
|
328
|
-
if self._func.error
|
|
328
|
+
if self._func.error is UnicodeDecodeError:
|
|
329
329
|
self._add(_E[902])
|
|
330
|
-
if self._func.error
|
|
330
|
+
if self._func.error is RecursionError:
|
|
331
331
|
self._add(_E[903])
|
|
332
|
+
if self._func.error is _ast.DuplicateBasesError:
|
|
333
|
+
self._add(_E[904])
|
|
332
334
|
|
|
333
335
|
@property
|
|
334
336
|
def name(self) -> str:
|
|
@@ -81,8 +81,6 @@ class DocType(_Enum):
|
|
|
81
81
|
return cls.UNKNOWN
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
# todo: consider a parent object that can be used for returns that do
|
|
85
|
-
# todo: not include the name attribute
|
|
86
84
|
class Param:
|
|
87
85
|
"""Single parameter from a docstring or function signature.
|
|
88
86
|
|
|
@@ -153,7 +151,14 @@ class Param:
|
|
|
153
151
|
return self._closing_token
|
|
154
152
|
|
|
155
153
|
|
|
156
|
-
|
|
154
|
+
# single return from a docstring or function signature
|
|
155
|
+
class _Return(_t.NamedTuple):
|
|
156
|
+
returns: bool = False
|
|
157
|
+
type: RetType = RetType.UNTYPED
|
|
158
|
+
description_missing: bool = False
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class Params(list[Param]):
|
|
157
162
|
"""A list-like collection of params.
|
|
158
163
|
|
|
159
164
|
:param ignore: Configuration object for what to ignore.
|
|
@@ -219,9 +224,13 @@ class Params(_t.List[Param]):
|
|
|
219
224
|
|
|
220
225
|
|
|
221
226
|
class _Stub:
|
|
222
|
-
def __init__(
|
|
227
|
+
def __init__(
|
|
228
|
+
self,
|
|
229
|
+
returns: _Return | None = None,
|
|
230
|
+
ignore: _Ignore | None = None,
|
|
231
|
+
) -> None:
|
|
223
232
|
self._args = Params(ignore or _Ignore())
|
|
224
|
-
self._returns =
|
|
233
|
+
self._returns = returns or _Return()
|
|
225
234
|
|
|
226
235
|
@property
|
|
227
236
|
def args(self) -> Params:
|
|
@@ -229,7 +238,7 @@ class _Stub:
|
|
|
229
238
|
return self._args
|
|
230
239
|
|
|
231
240
|
@property
|
|
232
|
-
def returns(self) ->
|
|
241
|
+
def returns(self) -> _Return:
|
|
233
242
|
"""True if a return (or yield) is declared or documented."""
|
|
234
243
|
return self._returns
|
|
235
244
|
|
|
@@ -237,20 +246,16 @@ class _Stub:
|
|
|
237
246
|
class Signature(_Stub):
|
|
238
247
|
"""Parsed function signature (args and return type).
|
|
239
248
|
|
|
240
|
-
:param rettype: Kind of return (none, some, untyped).
|
|
241
249
|
:param returns: True if return is declared in the signature.
|
|
242
250
|
:param ignore: Configuration object for what to ignore.
|
|
243
251
|
"""
|
|
244
252
|
|
|
245
253
|
def __init__(
|
|
246
254
|
self,
|
|
247
|
-
|
|
248
|
-
returns: bool = False,
|
|
255
|
+
returns: _Return | None = None,
|
|
249
256
|
ignore: _Ignore | None = None,
|
|
250
257
|
) -> None:
|
|
251
|
-
super().__init__(ignore or _Ignore())
|
|
252
|
-
self._rettype = rettype
|
|
253
|
-
self._returns = returns
|
|
258
|
+
super().__init__(returns, ignore or _Ignore())
|
|
254
259
|
|
|
255
260
|
@classmethod
|
|
256
261
|
def from_ast(
|
|
@@ -265,8 +270,8 @@ class Signature(_Stub):
|
|
|
265
270
|
:return: Signature with args and return type.
|
|
266
271
|
"""
|
|
267
272
|
rettype = RetType.from_ast(node.returns)
|
|
268
|
-
returns = rettype == RetType.SOME
|
|
269
|
-
signature = cls(
|
|
273
|
+
returns = _Return(rettype == RetType.SOME, rettype)
|
|
274
|
+
signature = cls(returns, ignore)
|
|
270
275
|
# noinspection PyUnresolvedReferences
|
|
271
276
|
for i in [
|
|
272
277
|
a if isinstance(a, Param) else Param(name=a.name)
|
|
@@ -283,18 +288,12 @@ class Signature(_Stub):
|
|
|
283
288
|
|
|
284
289
|
return signature
|
|
285
290
|
|
|
286
|
-
@property
|
|
287
|
-
def rettype(self) -> RetType:
|
|
288
|
-
"""Return annotation kind (none, some, or untyped)."""
|
|
289
|
-
return self._rettype
|
|
290
|
-
|
|
291
291
|
def overload(self, rettype: RetType) -> None:
|
|
292
292
|
"""Set this signature's return type (for overloads).
|
|
293
293
|
|
|
294
294
|
:param rettype: Return type for the overloaded variant.
|
|
295
295
|
"""
|
|
296
|
-
self.
|
|
297
|
-
self._returns = rettype != RetType.NONE
|
|
296
|
+
self._returns = _Return(rettype != RetType.NONE, rettype)
|
|
298
297
|
|
|
299
298
|
|
|
300
299
|
class Docstring(_Stub):
|
|
@@ -302,7 +301,6 @@ class Docstring(_Stub):
|
|
|
302
301
|
|
|
303
302
|
:param string: Raw docstring text after normalization.
|
|
304
303
|
:param returns: True if a return or yield section is present.
|
|
305
|
-
:param ret_description_missing: True if return has no description.
|
|
306
304
|
"""
|
|
307
305
|
|
|
308
306
|
@staticmethod
|
|
@@ -346,13 +344,10 @@ class Docstring(_Stub):
|
|
|
346
344
|
def __init__(
|
|
347
345
|
self,
|
|
348
346
|
string: str | None = None,
|
|
349
|
-
returns:
|
|
350
|
-
ret_description_missing: bool = False,
|
|
347
|
+
returns: _Return | None = None,
|
|
351
348
|
) -> None:
|
|
352
|
-
super().__init__()
|
|
349
|
+
super().__init__(returns)
|
|
353
350
|
self._string = string
|
|
354
|
-
self._returns = returns
|
|
355
|
-
self._ret_description_missing = ret_description_missing
|
|
356
351
|
|
|
357
352
|
@classmethod
|
|
358
353
|
def from_ast(cls, node: _ast.Const) -> Docstring:
|
|
@@ -363,19 +358,16 @@ class Docstring(_Stub):
|
|
|
363
358
|
"""
|
|
364
359
|
indent_anomaly = cls._indent_anomaly(node.value)
|
|
365
360
|
string = cls._normalize_docstring(node.value)
|
|
366
|
-
# todo: we can start building return objects for more detailed
|
|
367
|
-
# todo: checks that are in common with the params class
|
|
368
361
|
match = _re.search(
|
|
369
|
-
":(?:returns?|yields?)
|
|
362
|
+
r":(?:returns?|yields?):\s*(.*)",
|
|
370
363
|
string,
|
|
371
364
|
_re.IGNORECASE,
|
|
372
365
|
)
|
|
373
|
-
returns =
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
docstring = cls(string, returns, ret_description_missing)
|
|
366
|
+
returns = _Return(
|
|
367
|
+
bool(match),
|
|
368
|
+
description_missing=not match or not match.group(1),
|
|
369
|
+
)
|
|
370
|
+
docstring = cls(string, returns)
|
|
379
371
|
for match in _re.findall(
|
|
380
372
|
r":([\w\s]+(?:\s\|\s[\w\s]+|\w+))([^\w\s])((?:.|\n)*?)(?=\n:|$)",
|
|
381
373
|
string,
|
|
@@ -406,9 +398,8 @@ class Docstring(_Stub):
|
|
|
406
398
|
|
|
407
399
|
Used when the function has a docstring but documents nothing.
|
|
408
400
|
"""
|
|
409
|
-
return
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return self._ret_description_missing
|
|
401
|
+
return (
|
|
402
|
+
self._string is not None
|
|
403
|
+
and not self._args
|
|
404
|
+
and not self.returns.returns
|
|
405
|
+
)
|
|
@@ -9,7 +9,6 @@ from __future__ import annotations as _
|
|
|
9
9
|
|
|
10
10
|
import re as _re
|
|
11
11
|
import sys as _sys
|
|
12
|
-
import typing as _t
|
|
13
12
|
from difflib import SequenceMatcher as _SequenceMatcher
|
|
14
13
|
|
|
15
14
|
from .messages import TEMPLATE as _TEMPLATE
|
|
@@ -34,7 +33,7 @@ def almost_equal(str1: str, str2: str, mini: float, maxi: float) -> bool:
|
|
|
34
33
|
|
|
35
34
|
|
|
36
35
|
def pretty_print_error(
|
|
37
|
-
exception_type:
|
|
36
|
+
exception_type: type[BaseException],
|
|
38
37
|
msg: str,
|
|
39
38
|
no_ansi: bool,
|
|
40
39
|
) -> None:
|
|
@@ -24,7 +24,7 @@ NEW = """\
|
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
class Messages(
|
|
27
|
+
class Messages(list["Message"]):
|
|
28
28
|
"""Sequence of Message instances, typically for one failure."""
|
|
29
29
|
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ class Message(_t.NamedTuple):
|
|
|
41
41
|
symbolic: str = ""
|
|
42
42
|
|
|
43
43
|
#: A hint, if any, suggesting why the error may have occurred.
|
|
44
|
-
hint:
|
|
44
|
+
hint: str | None = None
|
|
45
45
|
|
|
46
46
|
#: Whether this message is a new addition.
|
|
47
47
|
new: bool = False
|
|
@@ -67,7 +67,7 @@ class Message(_t.NamedTuple):
|
|
|
67
67
|
)
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
class MessageMap(
|
|
70
|
+
class MessageMap(dict[int, Message]):
|
|
71
71
|
"""Mapping from integer key to Message (used for the E registry)."""
|
|
72
72
|
|
|
73
73
|
def from_ref(self, ref: str) -> Message:
|
|
@@ -267,5 +267,10 @@ E = MessageMap(
|
|
|
267
267
|
"maximum recursion depth exceeded",
|
|
268
268
|
"recursion-error",
|
|
269
269
|
),
|
|
270
|
+
904: Message(
|
|
271
|
+
"SIG904",
|
|
272
|
+
"duplicates found in mros",
|
|
273
|
+
"duplicates-found-in-mros",
|
|
274
|
+
),
|
|
270
275
|
},
|
|
271
276
|
)
|
|
@@ -22,7 +22,7 @@ from ._core import handle_deprecations, runner, setup_logger
|
|
|
22
22
|
from ._version import __version__
|
|
23
23
|
from .messages import FLAKE8, E
|
|
24
24
|
|
|
25
|
-
Flake8Error =
|
|
25
|
+
Flake8Error = tuple[int, int, str, type[t.Any]]
|
|
26
26
|
sys.path.append(os.path.abspath(os.getcwd()))
|
|
27
27
|
|
|
28
28
|
|
|
@@ -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.82.
|
|
14
|
+
current_version = "0.82.2"
|
|
15
15
|
message = "bump: version {current_version} → {new_version}"
|
|
16
16
|
sign_tags = true
|
|
17
17
|
tag = true
|
|
@@ -122,7 +122,7 @@ maintainers = [
|
|
|
122
122
|
name = "docsig"
|
|
123
123
|
readme = "README.rst"
|
|
124
124
|
repository = "https://github.com/jshwi/docsig"
|
|
125
|
-
version = "0.82.
|
|
125
|
+
version = "0.82.2"
|
|
126
126
|
|
|
127
127
|
[tool.poetry.dependencies]
|
|
128
128
|
Sphinx = ">=7,<9"
|
|
@@ -236,3 +236,14 @@ name = "Removed"
|
|
|
236
236
|
|
|
237
237
|
[tool.towncrier.fragment.security]
|
|
238
238
|
name = "Security"
|
|
239
|
+
|
|
240
|
+
[tool.vulture]
|
|
241
|
+
exclude = [
|
|
242
|
+
"tests/base_test.py",
|
|
243
|
+
"tests/conftest.py"
|
|
244
|
+
]
|
|
245
|
+
make_whitelist = true
|
|
246
|
+
paths = [
|
|
247
|
+
"docsig",
|
|
248
|
+
"tests"
|
|
249
|
+
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|