docsig 0.87.0__tar.gz → 0.87.1__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.87.0 → docsig-0.87.1}/LICENSE +5 -0
- docsig-0.87.1/LICENSES/SPHINX_LICENSE +39 -0
- {docsig-0.87.0 → docsig-0.87.1}/PKG-INFO +7 -8
- {docsig-0.87.0 → docsig-0.87.1}/README.rst +3 -3
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_check.py +2 -2
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_core.py +4 -3
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_decorators.py +4 -3
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_report.py +40 -8
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_stub.py +3 -3
- docsig-0.87.1/docsig/_vendor/sphinx/ext/napoleon.py +1373 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_version.py +1 -1
- {docsig-0.87.0 → docsig-0.87.1}/pyproject.toml +41 -38
- {docsig-0.87.0 → docsig-0.87.1}/docsig/__init__.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/__main__.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_config.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_directives.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_files.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_hooks.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_main.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_module.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_parsers.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/_utils.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/messages.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/plugin/__init__.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/plugin/_flake8.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/plugin/_validate_pyproject.py +0 -0
- {docsig-0.87.0 → docsig-0.87.1}/docsig/py.typed +0 -0
|
@@ -19,3 +19,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
This project includes code derived from Sphinx (sphinx.ext.napoleon),
|
|
24
|
+
licensed under the BSD 2-Clause License.
|
|
25
|
+
|
|
26
|
+
See licenses/SPHINX_LICENSE for details.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
This project includes code derived from Sphinx (sphinx.ext.napoleon).
|
|
2
|
+
|
|
3
|
+
Sphinx is a documentation generator: https://www.sphinx-doc.org/
|
|
4
|
+
|
|
5
|
+
The original code is licensed under the BSD 2-Clause License.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
License for Sphinx
|
|
10
|
+
==================
|
|
11
|
+
|
|
12
|
+
Unless otherwise indicated, all code in the Sphinx project is licenced under the
|
|
13
|
+
two clause BSD licence below.
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2007-2025 by the Sphinx team (see AUTHORS file).
|
|
16
|
+
All rights reserved.
|
|
17
|
+
|
|
18
|
+
Redistribution and use in source and binary forms, with or without
|
|
19
|
+
modification, are permitted provided that the following conditions are
|
|
20
|
+
met:
|
|
21
|
+
|
|
22
|
+
* Redistributions of source code must retain the above copyright
|
|
23
|
+
notice, this list of conditions and the following disclaimer.
|
|
24
|
+
|
|
25
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
26
|
+
notice, this list of conditions and the following disclaimer in the
|
|
27
|
+
documentation and/or other materials provided with the distribution.
|
|
28
|
+
|
|
29
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
30
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
31
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
32
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
33
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
34
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
35
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
36
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
37
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
38
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
39
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: docsig
|
|
3
|
-
Version: 0.87.
|
|
3
|
+
Version: 0.87.1
|
|
4
4
|
Summary: Check signature params for proper documentation
|
|
5
|
-
License: MIT
|
|
5
|
+
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
|
+
License-File: LICENSES/SPHINX_LICENSE
|
|
7
8
|
Keywords: check,docs,docstring,params,signature
|
|
8
9
|
Author: jshwi
|
|
9
10
|
Author-email: s.whitlock@live.com
|
|
10
11
|
Maintainer: jshwi
|
|
11
12
|
Maintainer-email: s.whitlock@live.com
|
|
12
|
-
Requires-Python: >=3.10
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
-
Requires-Dist: Sphinx (>=7,<8.2)
|
|
21
20
|
Requires-Dist: astroid (>=4.0.2,<5.0.0)
|
|
22
21
|
Requires-Dist: pathspec (>=0.12.1,<1.2.0)
|
|
23
22
|
Requires-Dist: tomli (>=2.0.1,<3.0.0)
|
|
@@ -201,7 +200,7 @@ ensure your installation has registered `docsig`
|
|
|
201
200
|
.. code-block:: console
|
|
202
201
|
|
|
203
202
|
$ flake8 --version
|
|
204
|
-
7.3.0 (docsig: 0.87.
|
|
203
|
+
7.3.0 (docsig: 0.87.1, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
|
|
205
204
|
|
|
206
205
|
And now use `flake8` to lint your files
|
|
207
206
|
|
|
@@ -287,7 +286,7 @@ Standalone
|
|
|
287
286
|
|
|
288
287
|
repos:
|
|
289
288
|
- repo: https://github.com/jshwi/docsig
|
|
290
|
-
rev: v0.87.
|
|
289
|
+
rev: v0.87.1
|
|
291
290
|
hooks:
|
|
292
291
|
- id: docsig
|
|
293
292
|
args:
|
|
@@ -306,7 +305,7 @@ or integrated with ``flake8``
|
|
|
306
305
|
hooks:
|
|
307
306
|
- id: flake8
|
|
308
307
|
additional_dependencies:
|
|
309
|
-
- docsig==0.87.
|
|
308
|
+
- docsig==0.87.1
|
|
310
309
|
args:
|
|
311
310
|
- "--sig-check-class"
|
|
312
311
|
- "--sig-check-dunders"
|
|
@@ -172,7 +172,7 @@ ensure your installation has registered `docsig`
|
|
|
172
172
|
.. code-block:: console
|
|
173
173
|
|
|
174
174
|
$ flake8 --version
|
|
175
|
-
7.3.0 (docsig: 0.87.
|
|
175
|
+
7.3.0 (docsig: 0.87.1, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
|
|
176
176
|
|
|
177
177
|
And now use `flake8` to lint your files
|
|
178
178
|
|
|
@@ -258,7 +258,7 @@ Standalone
|
|
|
258
258
|
|
|
259
259
|
repos:
|
|
260
260
|
- repo: https://github.com/jshwi/docsig
|
|
261
|
-
rev: v0.87.
|
|
261
|
+
rev: v0.87.1
|
|
262
262
|
hooks:
|
|
263
263
|
- id: docsig
|
|
264
264
|
args:
|
|
@@ -277,7 +277,7 @@ or integrated with ``flake8``
|
|
|
277
277
|
hooks:
|
|
278
278
|
- id: flake8
|
|
279
279
|
additional_dependencies:
|
|
280
|
-
- docsig==0.87.
|
|
280
|
+
- docsig==0.87.1
|
|
281
281
|
args:
|
|
282
282
|
- "--sig-check-class"
|
|
283
283
|
- "--sig-check-dunders"
|
|
@@ -6,8 +6,8 @@ docsig._check
|
|
|
6
6
|
from ._config import Config as _Config
|
|
7
7
|
from ._module import Function as _Function
|
|
8
8
|
from ._module import Parent as _Parent
|
|
9
|
-
from ._report import Failure as _Failure
|
|
10
9
|
from ._report import Failures as _Failures
|
|
10
|
+
from ._report import check_function as _check_function
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def _should_check_function(
|
|
@@ -47,7 +47,7 @@ def _run_check(
|
|
|
47
47
|
parent,
|
|
48
48
|
config,
|
|
49
49
|
):
|
|
50
|
-
failure =
|
|
50
|
+
failure = _check_function(child, config)
|
|
51
51
|
if failure:
|
|
52
52
|
failures.append(failure)
|
|
53
53
|
|
|
@@ -21,6 +21,7 @@ from ._files import Files as _Files
|
|
|
21
21
|
from ._parsers import parse_from_file as _parse_from_file
|
|
22
22
|
from ._parsers import parse_from_string as _parse_from_string
|
|
23
23
|
from ._report import Failures as _Failures
|
|
24
|
+
from ._report import RetCode as _RetCode
|
|
24
25
|
from ._report import report as _report
|
|
25
26
|
from ._utils import get_parent_that_has as _get_parent_that_has
|
|
26
27
|
from ._utils import print_checks as _print_checks
|
|
@@ -220,12 +221,12 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
220
221
|
failures = _run_checks(module, config)
|
|
221
222
|
return _report(failures, config)
|
|
222
223
|
|
|
223
|
-
retcodes =
|
|
224
|
+
retcodes = _RetCode()
|
|
224
225
|
repo = _get_parent_that_has(".git/HEAD")
|
|
225
226
|
files = _Files(path, config.filters, repo)
|
|
226
227
|
for file in files:
|
|
227
228
|
failures = runner(file, config)
|
|
228
229
|
retcode = _report(failures, config, str(file))
|
|
229
|
-
retcodes.
|
|
230
|
+
retcodes.add(retcode)
|
|
230
231
|
|
|
231
|
-
return
|
|
232
|
+
return retcodes.result
|
|
@@ -10,6 +10,7 @@ import sys as _sys
|
|
|
10
10
|
import typing as _t
|
|
11
11
|
from pathlib import Path as _Path
|
|
12
12
|
|
|
13
|
+
from ._report import RetCode as _RetCode
|
|
13
14
|
from .messages import E as _E
|
|
14
15
|
|
|
15
16
|
_FuncType = _t.Callable[..., int]
|
|
@@ -55,7 +56,7 @@ def validate_args(func: _FuncType) -> _WrappedFuncType:
|
|
|
55
56
|
@_functools.wraps(func)
|
|
56
57
|
def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> int:
|
|
57
58
|
format_json = _os.getenv("_DOCSIG_FORMAT_JSON") is not None
|
|
58
|
-
retcode = 2
|
|
59
|
+
retcode = _RetCode(2)
|
|
59
60
|
errors = []
|
|
60
61
|
if not kwargs.get("list_checks", False):
|
|
61
62
|
if not args and not kwargs.get("string"):
|
|
@@ -96,7 +97,7 @@ def validate_args(func: _FuncType) -> _WrappedFuncType:
|
|
|
96
97
|
message = "\n".join(errors)
|
|
97
98
|
if format_json:
|
|
98
99
|
obj = [ # pragma: no cover
|
|
99
|
-
{"line": None, "message": message, "exit": retcode},
|
|
100
|
+
{"line": None, "message": message, "exit": retcode.result},
|
|
100
101
|
]
|
|
101
102
|
if format_json: # pragma: no cover
|
|
102
103
|
print(_json.dumps(obj).strip()) # pragma: no cover
|
|
@@ -104,7 +105,7 @@ def validate_args(func: _FuncType) -> _WrappedFuncType:
|
|
|
104
105
|
else:
|
|
105
106
|
print(message, file=_sys.stderr)
|
|
106
107
|
|
|
107
|
-
return retcode
|
|
108
|
+
return retcode.result
|
|
108
109
|
|
|
109
110
|
return func(*args, **kwargs)
|
|
110
111
|
|
|
@@ -35,6 +35,38 @@ _MIN_MATCH = 0.8
|
|
|
35
35
|
_MAX_MATCH = 1.0
|
|
36
36
|
|
|
37
37
|
|
|
38
|
+
def check_function(func: _Function, config: _Config) -> "Failure":
|
|
39
|
+
"""Run configured checks for one function and return the result.
|
|
40
|
+
|
|
41
|
+
:param func: Function under check.
|
|
42
|
+
:param config: Configuration object.
|
|
43
|
+
:return: Collected diagnostics for the function.
|
|
44
|
+
"""
|
|
45
|
+
return Failure(func, config)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class RetCode:
|
|
49
|
+
"""RetCode object.
|
|
50
|
+
|
|
51
|
+
:param code: Initial return code, if any, otherwise zero.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
def __init__(self, code: int = 0) -> None:
|
|
55
|
+
self._data = [code]
|
|
56
|
+
|
|
57
|
+
def add(self, code: int) -> None:
|
|
58
|
+
"""Add a return code.
|
|
59
|
+
|
|
60
|
+
:param code: Return code to add.
|
|
61
|
+
"""
|
|
62
|
+
self._data.append(code)
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def result(self) -> int:
|
|
66
|
+
"""Maximum return code."""
|
|
67
|
+
return max(self._data)
|
|
68
|
+
|
|
69
|
+
|
|
38
70
|
class Failures(list["Failure"]):
|
|
39
71
|
"""Sequence of Failure instances (one per function checked)."""
|
|
40
72
|
|
|
@@ -63,7 +95,7 @@ class Failure(list[Failed]):
|
|
|
63
95
|
|
|
64
96
|
def __init__(self, func: _Function, config: _Config) -> None:
|
|
65
97
|
super().__init__()
|
|
66
|
-
self._retcode =
|
|
98
|
+
self._retcode = RetCode()
|
|
67
99
|
self._func = func
|
|
68
100
|
if config.target:
|
|
69
101
|
self._func.messages.extend(
|
|
@@ -80,7 +112,7 @@ class Failure(list[Failed]):
|
|
|
80
112
|
self._name = f"{self._func.parent.name}.{self._name}"
|
|
81
113
|
|
|
82
114
|
if self._func.error is not None:
|
|
83
|
-
self._retcode.
|
|
115
|
+
self._retcode.add(2)
|
|
84
116
|
self._sig9xx_error()
|
|
85
117
|
else:
|
|
86
118
|
self._sig0xx_config()
|
|
@@ -104,7 +136,7 @@ class Failure(list[Failed]):
|
|
|
104
136
|
include_hint: bool = False,
|
|
105
137
|
**kwargs: _t.Any,
|
|
106
138
|
) -> None:
|
|
107
|
-
self._retcode.
|
|
139
|
+
self._retcode.add(int(not value.new))
|
|
108
140
|
failed = Failed(
|
|
109
141
|
self._name,
|
|
110
142
|
value.ref,
|
|
@@ -337,7 +369,7 @@ class Failure(list[Failed]):
|
|
|
337
369
|
# invalid-syntax
|
|
338
370
|
if self._func.error is _ast.AstroidSyntaxError:
|
|
339
371
|
self._add(_E[901])
|
|
340
|
-
self._retcode.
|
|
372
|
+
self._retcode.add(123)
|
|
341
373
|
# unicode-decode-error
|
|
342
374
|
if self._func.error is UnicodeDecodeError:
|
|
343
375
|
self._add(_E[902])
|
|
@@ -361,7 +393,7 @@ class Failure(list[Failed]):
|
|
|
361
393
|
@property
|
|
362
394
|
def retcode(self) -> int:
|
|
363
395
|
"""Exit code (non-zero if any check failed)."""
|
|
364
|
-
return
|
|
396
|
+
return self._retcode.result
|
|
365
397
|
|
|
366
398
|
|
|
367
399
|
# TODO: make report json by default and wrap with a reporter for cli
|
|
@@ -381,11 +413,11 @@ def report(
|
|
|
381
413
|
:return: Exit code (non-zero if any check failed).
|
|
382
414
|
"""
|
|
383
415
|
format_json = _os.getenv("_DOCSIG_FORMAT_JSON") is not None
|
|
384
|
-
retcodes =
|
|
416
|
+
retcodes = RetCode()
|
|
385
417
|
output = []
|
|
386
418
|
obj = []
|
|
387
419
|
for failure in failures:
|
|
388
|
-
retcodes.
|
|
420
|
+
retcodes.add(failure.retcode)
|
|
389
421
|
path_prefix = f"{file}:" if file is not None else ""
|
|
390
422
|
header = f"{path_prefix}{failure.lineno} in {failure.name}"
|
|
391
423
|
if not config.no_ansi and _sys.stdout.isatty():
|
|
@@ -424,4 +456,4 @@ def report(
|
|
|
424
456
|
elif output:
|
|
425
457
|
print("\n".join(output))
|
|
426
458
|
|
|
427
|
-
return
|
|
459
|
+
return retcodes.result
|
|
@@ -14,9 +14,9 @@ from collections import Counter as _Counter
|
|
|
14
14
|
from enum import Enum as _Enum
|
|
15
15
|
|
|
16
16
|
import astroid as _ast
|
|
17
|
-
import sphinx.ext.napoleon as _s
|
|
18
17
|
|
|
19
18
|
from ._config import Ignore as _Ignore
|
|
19
|
+
from ._vendor.sphinx.ext import napoleon as _s
|
|
20
20
|
|
|
21
21
|
# no function will accidentally have this name
|
|
22
22
|
UNNAMED = "-1000"
|
|
@@ -330,9 +330,9 @@ class Docstring(_Stub):
|
|
|
330
330
|
# convert Google and numpy style docstrings to parse docstrings
|
|
331
331
|
# as restructured text
|
|
332
332
|
return str(
|
|
333
|
-
_s.NumpyDocstring(
|
|
333
|
+
_s.NumpyDocstring( # type: ignore
|
|
334
334
|
str(
|
|
335
|
-
_s.GoogleDocstring(
|
|
335
|
+
_s.GoogleDocstring( # type: ignore
|
|
336
336
|
_textwrap.dedent(
|
|
337
337
|
"\n".join(string.splitlines()[1:]),
|
|
338
338
|
).replace("*", ""),
|