docsig 0.43.0__tar.gz → 0.44.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.43.0 → docsig-0.44.1}/PKG-INFO +3 -3
- {docsig-0.43.0 → docsig-0.44.1}/README.rst +1 -1
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_core.py +7 -42
- docsig-0.44.1/docsig/_decorators.py +81 -0
- docsig-0.44.1/docsig/_hooks.py +16 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_main.py +5 -3
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_module.py +5 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_version.py +1 -1
- {docsig-0.43.0 → docsig-0.44.1}/pyproject.toml +5 -3
- {docsig-0.43.0 → docsig-0.44.1}/LICENSE +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/__init__.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/__main__.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_config.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_directives.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_display.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_function.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_message.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_report.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/_utils.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/docsig/messages.py +0 -0
- {docsig-0.43.0 → docsig-0.44.1}/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.44.1
|
|
4
4
|
Summary: Check signature params for proper documentation
|
|
5
5
|
Home-page: https://pypi.org/project/docsig/
|
|
6
6
|
License: MIT
|
|
@@ -17,7 +17,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Requires-Dist: Pygments (>=2.13.0,<3.0.0)
|
|
20
|
-
Requires-Dist: Sphinx (>=
|
|
20
|
+
Requires-Dist: Sphinx (>=7.0.0,<8.0.0)
|
|
21
21
|
Requires-Dist: arcon (>=0.3.1,<0.4.0)
|
|
22
22
|
Requires-Dist: astroid (>=3.0.1,<4.0.0)
|
|
23
23
|
Requires-Dist: object-colors (>=2.1.0,<3.0.0)
|
|
@@ -540,7 +540,7 @@ It can be added to your .pre-commit-config.yaml as follows:
|
|
|
540
540
|
|
|
541
541
|
repos:
|
|
542
542
|
- repo: https://github.com/jshwi/docsig
|
|
543
|
-
rev: v0.
|
|
543
|
+
rev: v0.44.1
|
|
544
544
|
hooks:
|
|
545
545
|
- id: docsig
|
|
546
546
|
args:
|
|
@@ -4,15 +4,13 @@ docsig._core
|
|
|
4
4
|
"""
|
|
5
5
|
from __future__ import annotations as _
|
|
6
6
|
|
|
7
|
-
import sys as _sys
|
|
8
|
-
from os import environ as _e
|
|
9
7
|
from pathlib import Path as _Path
|
|
10
8
|
|
|
9
|
+
from . import _decorators
|
|
11
10
|
from ._display import Display as _Display
|
|
12
11
|
from ._display import Failure as _Failure
|
|
13
12
|
from ._display import Failures as _Failures
|
|
14
13
|
from ._display import FuncStr as _FuncStr
|
|
15
|
-
from ._display import color as _color
|
|
16
14
|
from ._message import Message as _Message
|
|
17
15
|
from ._module import Modules as _Modules
|
|
18
16
|
from ._module import Parent as _Parent
|
|
@@ -21,42 +19,11 @@ from .messages import TEMPLATE as _TEMPLATE
|
|
|
21
19
|
from .messages import E as _E
|
|
22
20
|
|
|
23
21
|
|
|
24
|
-
def pretty_print_error() -> None:
|
|
25
|
-
"""Print user friendly commandline error if debug not enabled."""
|
|
26
|
-
if _e.get("DOCSIG_DEBUG", None) != "1":
|
|
27
|
-
_sys.excepthook = lambda x, y, _: print(
|
|
28
|
-
f"{_color.red.bold.get(x.__name__)}: {y}"
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
22
|
def _print_checks() -> None:
|
|
33
23
|
for msg in _E.values():
|
|
34
24
|
print(msg.fstring(_TEMPLATE))
|
|
35
25
|
|
|
36
26
|
|
|
37
|
-
def _check_required_args(path: tuple[str | _Path, ...], string: str | None):
|
|
38
|
-
if not path and not string:
|
|
39
|
-
raise ValueError(
|
|
40
|
-
"the following arguments are required: path(s) or string",
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def _check_provided_lists(
|
|
45
|
-
disabled_args: list[_Message], target_args: list[_Message]
|
|
46
|
-
) -> None:
|
|
47
|
-
for message in disabled_args:
|
|
48
|
-
if not message.isknown:
|
|
49
|
-
raise ValueError(
|
|
50
|
-
f"unknown option to disable '{message.description}'",
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
for message in target_args:
|
|
54
|
-
if not message.isknown:
|
|
55
|
-
raise ValueError(
|
|
56
|
-
f"unknown option to target '{message.description}'",
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
|
|
60
27
|
def _run_check( # pylint: disable=too-many-arguments
|
|
61
28
|
parent: _Parent,
|
|
62
29
|
check_class: bool,
|
|
@@ -94,6 +61,8 @@ def _run_check( # pylint: disable=too-many-arguments
|
|
|
94
61
|
return failures
|
|
95
62
|
|
|
96
63
|
|
|
64
|
+
@_decorators.parse_msgs
|
|
65
|
+
@_decorators.validate_args
|
|
97
66
|
def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
98
67
|
*path: str | _Path,
|
|
99
68
|
string: str | None = None,
|
|
@@ -110,8 +79,8 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
110
79
|
ignore_kwargs: bool = False,
|
|
111
80
|
no_ansi: bool = False,
|
|
112
81
|
summary: bool = False,
|
|
113
|
-
targets: list[
|
|
114
|
-
disable: list[
|
|
82
|
+
targets: list[_Message] | None = None,
|
|
83
|
+
disable: list[_Message] | None = None,
|
|
115
84
|
) -> int:
|
|
116
85
|
"""Package's core functionality.
|
|
117
86
|
|
|
@@ -147,13 +116,9 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
147
116
|
if list_checks:
|
|
148
117
|
return int(bool(_print_checks())) # type: ignore
|
|
149
118
|
|
|
150
|
-
_check_required_args(path, string)
|
|
151
|
-
disabled_args = list(_E.fromcodes(disable or []))
|
|
152
|
-
target_args = list(_E.fromcodes(targets or []))
|
|
153
|
-
_check_provided_lists(disabled_args, target_args)
|
|
154
119
|
modules = _Modules(
|
|
155
120
|
*tuple(_Path(i) for i in path),
|
|
156
|
-
disable=
|
|
121
|
+
disable=disable or [],
|
|
157
122
|
string=string,
|
|
158
123
|
ignore_args=ignore_args,
|
|
159
124
|
ignore_kwargs=ignore_kwargs,
|
|
@@ -177,7 +142,7 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
|
|
|
177
142
|
check_property_returns,
|
|
178
143
|
ignore_no_params,
|
|
179
144
|
no_ansi,
|
|
180
|
-
|
|
145
|
+
targets or [],
|
|
181
146
|
)
|
|
182
147
|
if failures:
|
|
183
148
|
display[top_level.path].append(failures)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""
|
|
2
|
+
docsig._decorators
|
|
3
|
+
==================
|
|
4
|
+
"""
|
|
5
|
+
from __future__ import annotations as _
|
|
6
|
+
|
|
7
|
+
import sys as _sys
|
|
8
|
+
import typing as _t
|
|
9
|
+
from pathlib import Path as _Path
|
|
10
|
+
|
|
11
|
+
from .messages import E as _E
|
|
12
|
+
|
|
13
|
+
_FuncType = _t.Callable[..., _t.Union[int]]
|
|
14
|
+
_WrappedFuncType = _t.Callable[..., _t.Union[str, int]]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def parse_msgs(func: _WrappedFuncType) -> _WrappedFuncType:
|
|
18
|
+
"""Parse error codes or symbolic messages into message objects.
|
|
19
|
+
|
|
20
|
+
:param func: Function to wrap.
|
|
21
|
+
:return: Wrapped function.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> str | int:
|
|
25
|
+
disable = list(_E.fromcodes(kwargs.get("disable", []))) or None
|
|
26
|
+
targets = list(_E.fromcodes(kwargs.get("targets", []))) or None
|
|
27
|
+
kwargs["disable"] = disable
|
|
28
|
+
kwargs["targets"] = targets
|
|
29
|
+
return func(*args, **kwargs)
|
|
30
|
+
|
|
31
|
+
return _wrapper
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def validate_args(func: _FuncType) -> _WrappedFuncType:
|
|
35
|
+
"""Confirm args passed to function are valid.
|
|
36
|
+
|
|
37
|
+
:param func: Function to wrap.
|
|
38
|
+
:return: Wrapped function.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> str | int:
|
|
42
|
+
stderr = []
|
|
43
|
+
if not kwargs.get("list_checks", False):
|
|
44
|
+
if not args and not kwargs.get("string"):
|
|
45
|
+
stderr.append(
|
|
46
|
+
"the following arguments are required: path(s) or string"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
for message in kwargs.get("disable") or []:
|
|
50
|
+
if not message.isknown:
|
|
51
|
+
stderr.append(
|
|
52
|
+
f"unknown option to disable '{message.description}'"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
for message in kwargs.get("targets") or []:
|
|
56
|
+
if not message.isknown:
|
|
57
|
+
stderr.append(
|
|
58
|
+
f"unknown option to target '{message.description}'",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
if kwargs.get("check_class") and kwargs.get(
|
|
62
|
+
"check_class_constructor"
|
|
63
|
+
):
|
|
64
|
+
stderr.append(
|
|
65
|
+
"argument to check class constructor not allowed with"
|
|
66
|
+
" argument to check class"
|
|
67
|
+
)
|
|
68
|
+
# if we don't make it past this condition then we are
|
|
69
|
+
# running this using the python interpreter
|
|
70
|
+
if _sys.stdin and _sys.stdin.isatty():
|
|
71
|
+
# otherwise, it is impossible to reach here by
|
|
72
|
+
# passing both commandline args as argparse won't
|
|
73
|
+
# allow it, therefore, this must be an issue with
|
|
74
|
+
# the pyproject.toml configuration
|
|
75
|
+
stderr.append(
|
|
76
|
+
"please check your pyproject.toml configuration"
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return "\n".join(stderr) if stderr else func(*args, **kwargs)
|
|
80
|
+
|
|
81
|
+
return _wrapper
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
docsig._hooks
|
|
3
|
+
=============
|
|
4
|
+
"""
|
|
5
|
+
import sys as _sys
|
|
6
|
+
from os import environ as _e
|
|
7
|
+
|
|
8
|
+
from ._display import color as _color
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def pretty_print_error() -> None:
|
|
12
|
+
"""Print user friendly commandline error if debug not enabled."""
|
|
13
|
+
if _e.get("DOCSIG_DEBUG", None) != "1":
|
|
14
|
+
_sys.excepthook = lambda x, y, _: print(
|
|
15
|
+
f"{_color.red.bold.get(x.__name__)}: {y}"
|
|
16
|
+
)
|
|
@@ -4,12 +4,14 @@ docsig._main
|
|
|
4
4
|
|
|
5
5
|
Contains package entry point.
|
|
6
6
|
"""
|
|
7
|
+
from __future__ import annotations as _
|
|
8
|
+
|
|
7
9
|
from ._config import Parser as _Parser
|
|
8
10
|
from ._core import docsig as _docsig
|
|
9
|
-
from .
|
|
11
|
+
from ._hooks import pretty_print_error as _pretty_print_error
|
|
10
12
|
|
|
11
13
|
|
|
12
|
-
def main() -> int:
|
|
14
|
+
def main() -> str | int:
|
|
13
15
|
"""Main function for package.
|
|
14
16
|
|
|
15
17
|
Collect config and arguments for the commandline.
|
|
@@ -37,5 +39,5 @@ def main() -> int:
|
|
|
37
39
|
no_ansi=parser.args.no_ansi,
|
|
38
40
|
summary=parser.args.summary,
|
|
39
41
|
targets=parser.args.target,
|
|
40
|
-
disable=parser.args.disable
|
|
42
|
+
disable=parser.args.disable,
|
|
41
43
|
)
|
|
@@ -43,8 +43,13 @@ class Parent(_t.List[_Function]):
|
|
|
43
43
|
self._path = f"{path}:" if path is not None else ""
|
|
44
44
|
overloads = []
|
|
45
45
|
returns = None
|
|
46
|
+
parent_comments, parent_disabled = directives.get(
|
|
47
|
+
node.lineno, ([], [])
|
|
48
|
+
)
|
|
46
49
|
for subnode in node.body:
|
|
47
50
|
comments, disabled = directives.get(subnode.lineno, ([], []))
|
|
51
|
+
comments.extend(parent_comments)
|
|
52
|
+
disabled.extend(parent_disabled)
|
|
48
53
|
if isinstance(subnode, _ast.FunctionDef):
|
|
49
54
|
func = _Function(
|
|
50
55
|
subnode,
|
|
@@ -18,8 +18,10 @@ line-length = 79
|
|
|
18
18
|
|
|
19
19
|
[tool.constcheck]
|
|
20
20
|
ignore_strings = [
|
|
21
|
+
"disable",
|
|
21
22
|
"store",
|
|
22
23
|
"store_true",
|
|
24
|
+
"targets",
|
|
23
25
|
"utf-8"
|
|
24
26
|
]
|
|
25
27
|
|
|
@@ -70,11 +72,11 @@ maintainers = [
|
|
|
70
72
|
name = "docsig"
|
|
71
73
|
readme = "README.rst"
|
|
72
74
|
repository = "https://github.com/jshwi/docsig"
|
|
73
|
-
version = "0.
|
|
75
|
+
version = "0.44.1"
|
|
74
76
|
|
|
75
77
|
[tool.poetry.dependencies]
|
|
76
78
|
Pygments = "^2.13.0"
|
|
77
|
-
Sphinx = "
|
|
79
|
+
Sphinx = "^7.0.0"
|
|
78
80
|
arcon = "^0.3.1"
|
|
79
81
|
astroid = "^3.0.1"
|
|
80
82
|
object-colors = "^2.1.0"
|
|
@@ -86,7 +88,7 @@ bump2version = "^1.0.1"
|
|
|
86
88
|
deptry = "^0.12.0"
|
|
87
89
|
ipython = "^8.12.0"
|
|
88
90
|
pre-commit = "^3.3.3"
|
|
89
|
-
pyaud = "^7.
|
|
91
|
+
pyaud = "^7.3.0"
|
|
90
92
|
pytest = "^7.4.0"
|
|
91
93
|
pytest-randomly = "^3.13.0"
|
|
92
94
|
pytest-sugar = "^0.9.6"
|
|
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
|