docsig 0.87.0__tar.gz → 0.88.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.
Files changed (27) hide show
  1. {docsig-0.87.0 → docsig-0.88.0}/LICENSE +5 -0
  2. docsig-0.88.0/LICENSES/SPHINX_LICENSE +39 -0
  3. {docsig-0.87.0 → docsig-0.88.0}/PKG-INFO +16 -11
  4. {docsig-0.87.0 → docsig-0.88.0}/README.rst +12 -6
  5. {docsig-0.87.0 → docsig-0.88.0}/docsig/_check.py +2 -2
  6. {docsig-0.87.0 → docsig-0.88.0}/docsig/_config.py +6 -0
  7. {docsig-0.87.0 → docsig-0.88.0}/docsig/_core.py +4 -3
  8. {docsig-0.87.0 → docsig-0.88.0}/docsig/_decorators.py +4 -3
  9. {docsig-0.87.0 → docsig-0.88.0}/docsig/_main.py +1 -0
  10. {docsig-0.87.0 → docsig-0.88.0}/docsig/_report.py +40 -8
  11. {docsig-0.87.0 → docsig-0.88.0}/docsig/_stub.py +3 -3
  12. docsig-0.88.0/docsig/_vendor/sphinx/ext/napoleon.py +1373 -0
  13. {docsig-0.87.0 → docsig-0.88.0}/docsig/_version.py +1 -1
  14. {docsig-0.87.0 → docsig-0.88.0}/pyproject.toml +52 -44
  15. {docsig-0.87.0 → docsig-0.88.0}/docsig/__init__.py +0 -0
  16. {docsig-0.87.0 → docsig-0.88.0}/docsig/__main__.py +0 -0
  17. {docsig-0.87.0 → docsig-0.88.0}/docsig/_directives.py +0 -0
  18. {docsig-0.87.0 → docsig-0.88.0}/docsig/_files.py +0 -0
  19. {docsig-0.87.0 → docsig-0.88.0}/docsig/_hooks.py +0 -0
  20. {docsig-0.87.0 → docsig-0.88.0}/docsig/_module.py +0 -0
  21. {docsig-0.87.0 → docsig-0.88.0}/docsig/_parsers.py +0 -0
  22. {docsig-0.87.0 → docsig-0.88.0}/docsig/_utils.py +0 -0
  23. {docsig-0.87.0 → docsig-0.88.0}/docsig/messages.py +0 -0
  24. {docsig-0.87.0 → docsig-0.88.0}/docsig/plugin/__init__.py +0 -0
  25. {docsig-0.87.0 → docsig-0.88.0}/docsig/plugin/_flake8.py +0 -0
  26. {docsig-0.87.0 → docsig-0.88.0}/docsig/plugin/_validate_pyproject.py +0 -0
  27. {docsig-0.87.0 → docsig-0.88.0}/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.0
3
+ Version: 0.88.0
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,<4.0
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)
@@ -36,7 +35,7 @@ Description-Content-Type: text/x-rst
36
35
 
37
36
  |
38
37
 
39
- |License| |PyPI| |Jetbrains Plugin| |CI| |Jetbrains Build| |CodeQL| |pre-commit.ci status| |codecov.io| |readthedocs.org| |python3.10| |Black| |isort| |pylint| |Security Status|
38
+ |License| |PyPI| |Jetbrains Plugin| |VS Code Extension| |CI| |Jetbrains Build| |VS Code Build| |CodeQL| |pre-commit.ci status| |codecov.io| |readthedocs.org| |python3.10| |Black| |isort| |pylint| |Security Status|
40
39
 
41
40
  .. |License| image:: https://img.shields.io/badge/License-MIT-yellow.svg
42
41
  :target: https://opensource.org/licenses/MIT
@@ -80,6 +79,12 @@ Description-Content-Type: text/x-rst
80
79
  .. |Jetbrains Build| image:: https://github.com/jshwi/docsig/actions/workflows/build-intellij-plugin.yaml/badge.svg
81
80
  :target: https://github.com/jshwi/docsig/actions/workflows/build-intellij-plugin.yaml
82
81
  :alt: Build
82
+ .. |VS Code Build| image:: https://github.com/jshwi/docsig/actions/workflows/build-vscode-extension.yaml/badge.svg
83
+ :target: https://github.com/jshwi/docsig/actions/workflows/build-vscode-extension.yaml.yaml
84
+ :alt: Build
85
+ .. |VS Code Extension| image:: https://img.shields.io/badge/vscode%20extension-v1.0.0-007ACC
86
+ :target: https://marketplace.visualstudio.com/items?itemName=jshwi.docsig
87
+ :alt: VS Code Extension Version
83
88
 
84
89
  Check Python signature params for proper documentation
85
90
  -------------------------------------------------------
@@ -119,7 +124,7 @@ Commandline
119
124
  [--check-property-returns] [--check-protected]
120
125
  [--check-protected-class-methods] [--ignore-args] [--ignore-kwargs]
121
126
  [--ignore-no-params] [-d LIST] [-t LIST] [-e PATTERN] [-E PATH [PATH ...]]
122
- [-I] [-s STR]
127
+ [-i] [-s STR]
123
128
  [path [path ...]]
124
129
 
125
130
  Check signature params for proper documentation
@@ -155,7 +160,7 @@ Commandline
155
160
  regular expression of files or dirs to exclude from checks
156
161
  -E PATH [PATH ...], --excludes PATH [PATH ...]
157
162
  path glob patterns to exclude from checks
158
- -I, --include-ignored
163
+ -i, --include-ignored
159
164
  check files even if they match a gitignore pattern
160
165
  -s STR, --string STR string to parse instead of files
161
166
 
@@ -201,7 +206,7 @@ ensure your installation has registered `docsig`
201
206
  .. code-block:: console
202
207
 
203
208
  $ flake8 --version
204
- 7.3.0 (docsig: 0.87.0, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
209
+ 7.3.0 (docsig: 0.88.0, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
205
210
 
206
211
  And now use `flake8` to lint your files
207
212
 
@@ -287,7 +292,7 @@ Standalone
287
292
 
288
293
  repos:
289
294
  - repo: https://github.com/jshwi/docsig
290
- rev: v0.87.0
295
+ rev: v0.88.0
291
296
  hooks:
292
297
  - id: docsig
293
298
  args:
@@ -306,7 +311,7 @@ or integrated with ``flake8``
306
311
  hooks:
307
312
  - id: flake8
308
313
  additional_dependencies:
309
- - docsig==0.87.0
314
+ - docsig==0.88.0
310
315
  args:
311
316
  - "--sig-check-class"
312
317
  - "--sig-check-dunders"
@@ -7,7 +7,7 @@
7
7
 
8
8
  |
9
9
 
10
- |License| |PyPI| |Jetbrains Plugin| |CI| |Jetbrains Build| |CodeQL| |pre-commit.ci status| |codecov.io| |readthedocs.org| |python3.10| |Black| |isort| |pylint| |Security Status|
10
+ |License| |PyPI| |Jetbrains Plugin| |VS Code Extension| |CI| |Jetbrains Build| |VS Code Build| |CodeQL| |pre-commit.ci status| |codecov.io| |readthedocs.org| |python3.10| |Black| |isort| |pylint| |Security Status|
11
11
 
12
12
  .. |License| image:: https://img.shields.io/badge/License-MIT-yellow.svg
13
13
  :target: https://opensource.org/licenses/MIT
@@ -51,6 +51,12 @@
51
51
  .. |Jetbrains Build| image:: https://github.com/jshwi/docsig/actions/workflows/build-intellij-plugin.yaml/badge.svg
52
52
  :target: https://github.com/jshwi/docsig/actions/workflows/build-intellij-plugin.yaml
53
53
  :alt: Build
54
+ .. |VS Code Build| image:: https://github.com/jshwi/docsig/actions/workflows/build-vscode-extension.yaml/badge.svg
55
+ :target: https://github.com/jshwi/docsig/actions/workflows/build-vscode-extension.yaml.yaml
56
+ :alt: Build
57
+ .. |VS Code Extension| image:: https://img.shields.io/badge/vscode%20extension-v1.0.0-007ACC
58
+ :target: https://marketplace.visualstudio.com/items?itemName=jshwi.docsig
59
+ :alt: VS Code Extension Version
54
60
 
55
61
  Check Python signature params for proper documentation
56
62
  -------------------------------------------------------
@@ -90,7 +96,7 @@ Commandline
90
96
  [--check-property-returns] [--check-protected]
91
97
  [--check-protected-class-methods] [--ignore-args] [--ignore-kwargs]
92
98
  [--ignore-no-params] [-d LIST] [-t LIST] [-e PATTERN] [-E PATH [PATH ...]]
93
- [-I] [-s STR]
99
+ [-i] [-s STR]
94
100
  [path [path ...]]
95
101
 
96
102
  Check signature params for proper documentation
@@ -126,7 +132,7 @@ Commandline
126
132
  regular expression of files or dirs to exclude from checks
127
133
  -E PATH [PATH ...], --excludes PATH [PATH ...]
128
134
  path glob patterns to exclude from checks
129
- -I, --include-ignored
135
+ -i, --include-ignored
130
136
  check files even if they match a gitignore pattern
131
137
  -s STR, --string STR string to parse instead of files
132
138
 
@@ -172,7 +178,7 @@ ensure your installation has registered `docsig`
172
178
  .. code-block:: console
173
179
 
174
180
  $ flake8 --version
175
- 7.3.0 (docsig: 0.87.0, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
181
+ 7.3.0 (docsig: 0.88.0, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
176
182
 
177
183
  And now use `flake8` to lint your files
178
184
 
@@ -258,7 +264,7 @@ Standalone
258
264
 
259
265
  repos:
260
266
  - repo: https://github.com/jshwi/docsig
261
- rev: v0.87.0
267
+ rev: v0.88.0
262
268
  hooks:
263
269
  - id: docsig
264
270
  args:
@@ -277,7 +283,7 @@ or integrated with ``flake8``
277
283
  hooks:
278
284
  - id: flake8
279
285
  additional_dependencies:
280
- - docsig==0.87.0
286
+ - docsig==0.88.0
281
287
  args:
282
288
  - "--sig-check-class"
283
289
  - "--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 = _Failure(child, config)
50
+ failure = _check_function(child, config)
51
51
  if failure:
52
52
  failures.append(failure)
53
53
 
@@ -250,6 +250,12 @@ def build_parser() -> _ArgumentParser:
250
250
  )
251
251
  parser.add_argument(
252
252
  "-I",
253
+ action="store_true",
254
+ help=_argparse.SUPPRESS,
255
+ dest="include_ignored",
256
+ )
257
+ parser.add_argument(
258
+ "-i",
253
259
  "--include-ignored",
254
260
  action="store_true",
255
261
  help="check files even if they match a gitignore pattern",
@@ -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 = [0]
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.append(retcode)
230
+ retcodes.add(retcode)
230
231
 
231
- return max(retcodes)
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
 
@@ -16,6 +16,7 @@ from ._hooks import excepthook as _excepthook
16
16
 
17
17
  def _warn_on_deprecated_short_flags() -> None:
18
18
  deprecated_short_flags = {
19
+ "-I": "--include-ignored",
19
20
  "-c": "--check-class",
20
21
  "-D": "--check-dunders",
21
22
  "-o": "--check-overridden",
@@ -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 = [0]
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.append(2)
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.append(int(not value.new))
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.append(123)
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 max(self._retcode)
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 = [0]
416
+ retcodes = RetCode()
385
417
  output = []
386
418
  obj = []
387
419
  for failure in failures:
388
- retcodes.append(failure.retcode)
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 max(retcodes)
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("*", ""),