docsig 0.56.0__tar.gz → 0.57.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: docsig
3
- Version: 0.56.0
3
+ Version: 0.57.0
4
4
  Summary: Check signature params for proper documentation
5
5
  Home-page: https://pypi.org/project/docsig/
6
6
  License: MIT
@@ -9,10 +9,9 @@ Author: jshwi
9
9
  Author-email: stephen@jshwisolutions.com
10
10
  Maintainer: jshwi
11
11
  Maintainer-email: stephen@jshwisolutions.com
12
- Requires-Python: >=3.8,<4.0
12
+ Requires-Python: >=3.8.1,<4.0.0
13
13
  Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.8
16
15
  Classifier: Programming Language :: Python :: 3.9
17
16
  Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
@@ -162,6 +161,39 @@ Options can also be configured with the pyproject.toml file
162
161
  "SIG201",
163
162
  ]
164
163
 
164
+ Flake8
165
+ ******
166
+
167
+ ``docsig`` can also be used as a ``flake8`` plugin. Install ``flake8`` and
168
+ ensure your installation has registered `docsig`
169
+
170
+ .. code-block:: console
171
+
172
+ $ flake8 --version
173
+ 7.1.0 (docsig: 0.57.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
174
+
175
+ And now use `flake8` to lint your files
176
+
177
+ .. code-block:: console
178
+
179
+ $ flake8 example.py
180
+ example.py:1:1: SIG202 includes parameters that do not exist (params-do-not-exist) 'function'
181
+
182
+ With ``flake8`` the pyproject.toml config will still be the base config, though the
183
+ `ini files <https://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations>`_ ``flake8`` gets it config from will override the pyproject.toml config.
184
+ For ``flake8`` all args and config options are prefixed with ``sig`` to
185
+ avoid any potential conflicts with other plugins
186
+
187
+ .. code-block:: ini
188
+
189
+ [flake8]
190
+ sig-check-dunders = True
191
+ sig-check-overridden = True
192
+ sig-check-protected = True
193
+
194
+ ..
195
+ end flake8
196
+
165
197
  API
166
198
  ***
167
199
 
@@ -225,7 +257,7 @@ It can be added to your .pre-commit-config.yaml as follows:
225
257
 
226
258
  repos:
227
259
  - repo: https://github.com/jshwi/docsig
228
- rev: v0.56.0
260
+ rev: v0.57.0
229
261
  hooks:
230
262
  - id: docsig
231
263
  args:
@@ -134,6 +134,39 @@ Options can also be configured with the pyproject.toml file
134
134
  "SIG201",
135
135
  ]
136
136
 
137
+ Flake8
138
+ ******
139
+
140
+ ``docsig`` can also be used as a ``flake8`` plugin. Install ``flake8`` and
141
+ ensure your installation has registered `docsig`
142
+
143
+ .. code-block:: console
144
+
145
+ $ flake8 --version
146
+ 7.1.0 (docsig: 0.57.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
147
+
148
+ And now use `flake8` to lint your files
149
+
150
+ .. code-block:: console
151
+
152
+ $ flake8 example.py
153
+ example.py:1:1: SIG202 includes parameters that do not exist (params-do-not-exist) 'function'
154
+
155
+ With ``flake8`` the pyproject.toml config will still be the base config, though the
156
+ `ini files <https://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations>`_ ``flake8`` gets it config from will override the pyproject.toml config.
157
+ For ``flake8`` all args and config options are prefixed with ``sig`` to
158
+ avoid any potential conflicts with other plugins
159
+
160
+ .. code-block:: ini
161
+
162
+ [flake8]
163
+ sig-check-dunders = True
164
+ sig-check-overridden = True
165
+ sig-check-protected = True
166
+
167
+ ..
168
+ end flake8
169
+
137
170
  API
138
171
  ***
139
172
 
@@ -197,7 +230,7 @@ It can be added to your .pre-commit-config.yaml as follows:
197
230
 
198
231
  repos:
199
232
  - repo: https://github.com/jshwi/docsig
200
- rev: v0.56.0
233
+ rev: v0.57.0
201
234
  hooks:
202
235
  - id: docsig
203
236
  args:
@@ -14,7 +14,7 @@ def excepthook(no_ansi: bool = False) -> None:
14
14
 
15
15
  :param no_ansi: Disable ANSI output.
16
16
  """
17
- if _e.get("DOCSIG_DEBUG", None) != "1":
17
+ if _e.get("DOCSIG_DEBUG") != "1":
18
18
  _sys.excepthook = lambda x, y, _: _pretty_print_error(
19
19
  x, str(y), no_ansi
20
20
  )
@@ -8,4 +8,4 @@ Allows for access to the version internally without cyclic imports
8
8
  caused by accessing it through __init__.
9
9
  """
10
10
 
11
- __version__ = "0.56.0"
11
+ __version__ = "0.57.0"
@@ -14,6 +14,9 @@ UNKNOWN = "SIG000"
14
14
  #: Default template to format message strings.
15
15
  TEMPLATE = "{ref}: {description} ({symbolic})"
16
16
 
17
+ #: Flake8 template to format message strings.
18
+ FLAKE8 = "{ref} {description} ({symbolic})"
19
+
17
20
 
18
21
  class Message(_t.NamedTuple):
19
22
  """Represents an error message."""
@@ -0,0 +1,165 @@
1
+ """Flake8 implementation of docsig."""
2
+
3
+ import ast
4
+ import contextlib
5
+ import io
6
+ import re
7
+ import sys
8
+ import typing as t
9
+ from argparse import Namespace
10
+
11
+ import docsig
12
+
13
+ Flake8Error = t.Tuple[int, int, str, t.Type]
14
+
15
+
16
+ class Docsig:
17
+ """Flake8 implementation of docsig class.
18
+
19
+ :param tree: Ast module, which will not be used by flake8 will
20
+ provide.
21
+ :param filename: Filename to pass to docsig.
22
+ """
23
+
24
+ off_by_default = False
25
+ name = docsig.__name__
26
+ version = docsig.__version__
27
+ options_dict: t.Dict[str, bool] = {}
28
+
29
+ def __init__(self, tree: ast.Module, filename: str) -> None:
30
+ _tree = tree # noqa
31
+ self.filename = filename
32
+
33
+ # won't import flake8 type
34
+ # conflicts with this module name
35
+ # might require that flake8 actually be installed, which is not a
36
+ # requirement for this package
37
+ @classmethod
38
+ def add_options(cls, parser) -> None:
39
+ """Add flake8 commandline and config options.sig_
40
+
41
+ :param parser: Flake8 option manager.
42
+ """
43
+ parser.add_option(
44
+ "--sig-check-class",
45
+ action="store_true",
46
+ parse_from_config=True,
47
+ help="check class docstrings",
48
+ )
49
+ parser.add_option(
50
+ "--sig-check-class-constructor",
51
+ action="store_true",
52
+ parse_from_config=True,
53
+ help="check __init__ methods. Note: mutually incompatible with -c",
54
+ )
55
+ parser.add_option(
56
+ "--sig-check-dunders",
57
+ action="store_true",
58
+ parse_from_config=True,
59
+ help="check dunder methods",
60
+ )
61
+ parser.add_option(
62
+ "--sig-check-protected-class-methods",
63
+ action="store_true",
64
+ parse_from_config=True,
65
+ help="check public methods belonging to protected classes",
66
+ )
67
+ parser.add_option(
68
+ "--sig-check-nested",
69
+ action="store_true",
70
+ parse_from_config=True,
71
+ help="check nested functions and classes",
72
+ )
73
+ parser.add_option(
74
+ "--sig-check-overridden",
75
+ action="store_true",
76
+ parse_from_config=True,
77
+ help="check overridden methods",
78
+ )
79
+ parser.add_option(
80
+ "--sig-check-protected",
81
+ action="store_true",
82
+ parse_from_config=True,
83
+ help="check protected functions and classes",
84
+ )
85
+ parser.add_option(
86
+ "--sig-check-property-returns",
87
+ action="store_true",
88
+ parse_from_config=True,
89
+ help="check property return values",
90
+ )
91
+ parser.add_option(
92
+ "--sig-ignore-no-params",
93
+ action="store_true",
94
+ parse_from_config=True,
95
+ help="ignore docstrings where parameters are not documented",
96
+ )
97
+ parser.add_option(
98
+ "--sig-ignore-args",
99
+ action="store_true",
100
+ parse_from_config=True,
101
+ help="ignore args prefixed with an asterisk",
102
+ )
103
+ parser.add_option(
104
+ "--sig-ignore-kwargs",
105
+ action="store_true",
106
+ parse_from_config=True,
107
+ help="ignore kwargs prefixed with two asterisks",
108
+ )
109
+ parser.add_option(
110
+ "--sig-ignore-typechecker",
111
+ action="store_true",
112
+ parse_from_config=True,
113
+ help="ignore checking return values",
114
+ )
115
+
116
+ @classmethod
117
+ def parse_options(cls, options: Namespace) -> None:
118
+ """Parse flake8 options into am instance accessible dict.
119
+
120
+ :param options: Argparse namespace.
121
+ """
122
+ cls.options_dict = {
123
+ "check_class": options.sig_check_class,
124
+ "check_class_constructor": options.sig_check_class_constructor,
125
+ "check_dunders": options.sig_check_dunders,
126
+ "check_protected_class_methods": (
127
+ options.sig_check_protected_class_methods
128
+ ),
129
+ "check_nested": options.sig_check_nested,
130
+ "check_overridden": options.sig_check_overridden,
131
+ "check_protected": options.sig_check_protected,
132
+ "check_property_returns": options.sig_check_property_returns,
133
+ "ignore_no_params": options.sig_ignore_no_params,
134
+ "ignore_args": options.sig_ignore_args,
135
+ "ignore_kwargs": options.sig_ignore_kwargs,
136
+ "ignore_typechecker": options.sig_ignore_typechecker,
137
+ }
138
+
139
+ def run(self) -> t.Generator[Flake8Error, None, None]:
140
+ """Run docsig and possibly yield a flake8 error.
141
+
142
+ :return: Flake8 error, if there is one.
143
+ """
144
+ buffer = io.StringIO()
145
+ with contextlib.redirect_stdout(buffer):
146
+ sys.argv = [
147
+ __package__,
148
+ self.filename,
149
+ *[
150
+ f"--{k.replace('_', '-')}"
151
+ for k, v in self.options_dict.items()
152
+ if v
153
+ ],
154
+ ]
155
+ docsig.main()
156
+
157
+ results = re.split(r"^(?!\s)", buffer.getvalue(), flags=re.MULTILINE)
158
+ for result in results:
159
+ if not result:
160
+ continue
161
+
162
+ header, remainder = result.splitlines()[:2]
163
+ lineno, func_name = header.split(":", 1)[1].split(" in ", 1)
164
+ line = f"{remainder.lstrip().replace(':', '')} '{func_name}'"
165
+ yield int(lineno), 0, line, self.__class__
@@ -7,12 +7,56 @@ requires = [
7
7
  [tool.black]
8
8
  line-length = 79
9
9
 
10
+ [tool.bumpversion]
11
+ allow_dirty = true
12
+ commit = true
13
+ commit_args = "-sS"
14
+ current_version = "0.57.0"
15
+ message = "bump: version {current_version} → {new_version}"
16
+ sign_tags = true
17
+ tag = true
18
+
19
+ [[tool.bumpversion.files]]
20
+ filename = "docs/conf.py"
21
+
22
+ [[tool.bumpversion.files]]
23
+ filename = "docsig/_version.py"
24
+
25
+ [[tool.bumpversion.files]]
26
+ filename = "pyproject.toml"
27
+ replace = 'version = "{new_version}"'
28
+ search = 'version = "{current_version}"'
29
+
30
+ [[tool.bumpversion.files]]
31
+ filename = "package.json"
32
+ replace = '"version": "{new_version}"'
33
+ search = '"version": "{current_version}"'
34
+
35
+ [[tool.bumpversion.files]]
36
+ filename = "README.rst"
37
+ replace = "rev: v{new_version}"
38
+ search = "rev: v{current_version}"
39
+
40
+ [[tool.bumpversion.files]]
41
+ filename = "README.rst"
42
+ replace = "docsig: {new_version}"
43
+ search = "docsig: {current_version}"
44
+
45
+ [[tool.bumpversion.files]]
46
+ filename = "SECURITY.md"
47
+
48
+ [[tool.bumpversion.files]]
49
+ filename = "Makefile"
50
+ replace = "VERSION := {new_version}"
51
+ search = "VERSION := {current_version}"
52
+
10
53
  [tool.codespell]
11
54
  ignore-words-list = "astroid"
12
55
 
13
56
  [tool.coverage.report]
14
57
  exclude_lines = [
15
- "@_t.overload"
58
+ "@_t.overload",
59
+ "if __name__ == .__main__.:"
16
60
  ]
17
61
  fail_under = 100
18
62
 
@@ -24,7 +68,14 @@ omit = [
24
68
  ]
25
69
 
26
70
  [tool.deptry.per_rule_ignores]
27
- DEP004 = ["yaml"]
71
+ DEP004 = [
72
+ "flake8",
73
+ "git",
74
+ "pytest",
75
+ "tomli",
76
+ "tomli_w",
77
+ "yaml"
78
+ ]
28
79
 
29
80
  [tool.docformatter]
30
81
  in-place = true
@@ -76,7 +127,7 @@ maintainers = [
76
127
  name = "docsig"
77
128
  readme = "README.rst"
78
129
  repository = "https://github.com/jshwi/docsig"
79
- version = "0.56.0"
130
+ version = "0.57.0"
80
131
 
81
132
  [tool.poetry.dependencies]
82
133
  Sphinx = "^7.0.0"
@@ -84,18 +135,22 @@ arcon = ">=0.4.0"
84
135
  astroid = "^3.0.1"
85
136
  click = "^8.1.7"
86
137
  pathspec = "^0.12.1"
87
- python = "^3.8"
138
+ python = "^3.8.1"
88
139
 
89
140
  [tool.poetry.group.dev.dependencies]
90
141
  black = "^24.4.2"
91
- bump2version = "^1.0.1"
142
+ bump-my-version = "^0.24.1"
92
143
  deptry = "^0.16.1"
93
144
  docformatter = "^1.7.5"
94
145
  flynt = "^1.0.1"
146
+ gitpython = "^3.1.43"
95
147
  isort = "^5.13.2"
96
148
  mypy = "^1.10.0"
97
149
  pre-commit = "^3.3.3"
98
150
  pylint = "^3.1.0"
151
+ tomli = "^2.0.1"
152
+ tomli-w = "^1.0.0"
153
+ towncrier = "^23.11.0"
99
154
  tox = "^4.15.0"
100
155
  vulture = "^2.11"
101
156
 
@@ -108,6 +163,9 @@ sphinx-copybutton = "^0.5.2"
108
163
  sphinx-markdown-builder = ">=0.5.5,<0.7.0"
109
164
  templatest = "^0.10.1"
110
165
 
166
+ [tool.poetry.group.flake8.dependencies]
167
+ flake8 = "^7.1.0"
168
+
111
169
  [tool.poetry.group.tests.dependencies]
112
170
  pytest = "^8.2.0"
113
171
  pytest-benchmark = "^4.0.0"
@@ -117,6 +175,9 @@ pytest-sugar = "^1.0.0"
117
175
  pytest-xdist = "^3.6.1"
118
176
  templatest = "^0.10.1"
119
177
 
178
+ [tool.poetry.plugins."flake8.extension"]
179
+ SIG = "docsig.plugin:Docsig"
180
+
120
181
  [tool.poetry.scripts]
121
182
  docsig = "docsig.__main__:main"
122
183
 
@@ -149,3 +210,32 @@ norecursedirs = [
149
210
  ".pytest_cache",
150
211
  "docs"
151
212
  ]
213
+
214
+ [tool.towncrier]
215
+ directory = "changelog"
216
+ filename = "CHANGELOG.md"
217
+ issue_format = "[#{issue}](https://github.com/jshwi/docsig/issues/{issue})"
218
+ package = "docsig"
219
+ start_string = "<!-- release notes start -->\n"
220
+ template = "changelog/_template.md"
221
+
222
+ [tool.towncrier.fragment.add]
223
+ name = "Added"
224
+
225
+ [tool.towncrier.fragment.change]
226
+ name = "Changed"
227
+
228
+ [tool.towncrier.fragment.deprecate]
229
+ name = "Deprecated"
230
+
231
+ [tool.towncrier.fragment.fix]
232
+ name = "Fixed"
233
+
234
+ [tool.towncrier.fragment.hack]
235
+ name = "Hacked"
236
+
237
+ [tool.towncrier.fragment.remove]
238
+ name = "Removed"
239
+
240
+ [tool.towncrier.fragment.security]
241
+ name = "Security"
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
File without changes