docsig 0.64.0__tar.gz → 0.65.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.64.0
3
+ Version: 0.65.0
4
4
  Summary: Check signature params for proper documentation
5
5
  Home-page: https://pypi.org/project/docsig/
6
6
  License: MIT
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.9
16
16
  Classifier: Programming Language :: Python :: 3.10
17
17
  Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
19
20
  Requires-Dist: Sphinx (>=7.0.0,<8.0.0)
20
21
  Requires-Dist: astroid (>=3.0.1,<4.0.0)
21
22
  Requires-Dist: pathspec (>=0.12.1,<0.13.0)
@@ -180,7 +181,7 @@ ensure your installation has registered `docsig`
180
181
  .. code-block:: console
181
182
 
182
183
  $ flake8 --version
183
- 7.1.0 (docsig: 0.64.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
184
+ 7.1.0 (docsig: 0.65.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
184
185
 
185
186
  And now use `flake8` to lint your files
186
187
 
@@ -269,7 +270,7 @@ Standalone
269
270
 
270
271
  repos:
271
272
  - repo: https://github.com/jshwi/docsig
272
- rev: v0.64.0
273
+ rev: v0.65.0
273
274
  hooks:
274
275
  - id: docsig
275
276
  args:
@@ -288,7 +289,7 @@ or integrated with ``flake8``
288
289
  hooks:
289
290
  - id: flake8
290
291
  additional_dependencies:
291
- - docsig==0.64.0
292
+ - docsig==0.65.0
292
293
  args:
293
294
  - "--sig-check-class"
294
295
  - "--sig-check-dunders"
@@ -153,7 +153,7 @@ ensure your installation has registered `docsig`
153
153
  .. code-block:: console
154
154
 
155
155
  $ flake8 --version
156
- 7.1.0 (docsig: 0.64.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
156
+ 7.1.0 (docsig: 0.65.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
157
157
 
158
158
  And now use `flake8` to lint your files
159
159
 
@@ -242,7 +242,7 @@ Standalone
242
242
 
243
243
  repos:
244
244
  - repo: https://github.com/jshwi/docsig
245
- rev: v0.64.0
245
+ rev: v0.65.0
246
246
  hooks:
247
247
  - id: docsig
248
248
  args:
@@ -261,7 +261,7 @@ or integrated with ``flake8``
261
261
  hooks:
262
262
  - id: flake8
263
263
  additional_dependencies:
264
- - docsig==0.64.0
264
+ - docsig==0.65.0
265
265
  args:
266
266
  - "--sig-check-class"
267
267
  - "--sig-check-dunders"
@@ -83,7 +83,7 @@ class _ArgumentParser(_a.ArgumentParser):
83
83
  namespace: _a.Namespace | None = None,
84
84
  ) -> tuple[_a.Namespace | None, list[str]]:
85
85
  namespace, args = super().parse_known_args(args, namespace)
86
- config = get_config(self.prog)
86
+ config = get_config(_Path(self.prog).stem)
87
87
  namespace.__dict__ = merge_configs(namespace.__dict__, config)
88
88
  return namespace, args
89
89
 
@@ -254,13 +254,4 @@ def parse_args(args: _t.Sequence[str] | None = None) -> _a.Namespace:
254
254
  metavar="PATH",
255
255
  help="path glob patterns to exclude from checks",
256
256
  )
257
-
258
- # deprecated
259
- parser.add_argument(
260
- "-S",
261
- "--summary",
262
- action="store_true",
263
- help=_a.SUPPRESS,
264
- )
265
-
266
257
  return parser.parse_args(args)
@@ -95,7 +95,7 @@ def _run_check( # pylint: disable=too-many-arguments,too-many-locals
95
95
  failures.append(failure)
96
96
 
97
97
  if check_nested:
98
- for func in child:
98
+ for func in child.children:
99
99
  _run_check(
100
100
  func,
101
101
  child,
@@ -114,7 +114,7 @@ def _run_check( # pylint: disable=too-many-arguments,too-many-locals
114
114
  )
115
115
  else:
116
116
  # this is a class
117
- for func in child:
117
+ for func in child.children:
118
118
  _run_check(
119
119
  func,
120
120
  child,
@@ -134,28 +134,28 @@ def _run_check( # pylint: disable=too-many-arguments,too-many-locals
134
134
 
135
135
 
136
136
  def _from_file(
137
- root: _Path,
137
+ path: _Path,
138
138
  messages: _Messages,
139
139
  ignore_args: bool,
140
140
  ignore_kwargs: bool,
141
141
  check_class_constructor,
142
142
  ) -> _Parent:
143
143
  try:
144
- string = root.read_text(encoding="utf-8")
144
+ string = path.read_text(encoding="utf-8")
145
145
  parent = _from_str(
146
146
  messages=messages,
147
147
  string=string,
148
- root=root,
148
+ path=path,
149
149
  ignore_args=ignore_args,
150
150
  ignore_kwargs=ignore_kwargs,
151
151
  check_class_constructor=check_class_constructor,
152
152
  )
153
153
  except UnicodeDecodeError as err:
154
154
  logger = _logging.getLogger(__package__)
155
- logger.debug(_FILE_INFO, root, str(err).replace("\n", " "))
155
+ logger.debug(_FILE_INFO, path, str(err).replace("\n", " "))
156
156
  parent = _Parent(error=_Error.UNICODE)
157
157
 
158
- if parent.error is not None and not root.name.endswith(".py"):
158
+ if parent.error is not None and not path.name.endswith(".py"):
159
159
  parent = _Parent()
160
160
 
161
161
  return parent
@@ -167,23 +167,23 @@ def _from_str( # pylint: disable=too-many-arguments
167
167
  ignore_args: bool,
168
168
  ignore_kwargs: bool,
169
169
  check_class_constructor,
170
- root: _Path | None = None,
170
+ path: _Path | None = None,
171
171
  ) -> _Parent:
172
172
  logger = _logging.getLogger(__package__)
173
173
  try:
174
174
  parent = _Parent(
175
175
  _ast.parse(string),
176
176
  _Directives.from_text(string, messages),
177
- root,
177
+ path,
178
178
  ignore_args,
179
179
  ignore_kwargs,
180
180
  check_class_constructor,
181
181
  )
182
182
  logger.debug(
183
- _FILE_INFO, root or "stdin", "Parsing Python code successful"
183
+ _FILE_INFO, path or "stdin", "Parsing Python code successful"
184
184
  )
185
185
  except _ast.AstroidSyntaxError as err:
186
- logger.debug(_FILE_INFO, root or "stdin", str(err).replace("\n", " "))
186
+ logger.debug(_FILE_INFO, path or "stdin", str(err).replace("\n", " "))
187
187
  parent = _Parent(error=_Error.SYNTAX)
188
188
 
189
189
  return parent
@@ -205,7 +205,7 @@ def _get_failures( # pylint: disable=too-many-arguments
205
205
  target: _Messages,
206
206
  ) -> _Failures:
207
207
  failures = _Failures()
208
- for top_level in module:
208
+ for top_level in module.children:
209
209
  if (
210
210
  not top_level.isprotected
211
211
  or check_protected
@@ -259,7 +259,7 @@ def _report(
259
259
 
260
260
 
261
261
  def runner( # pylint: disable=too-many-locals,too-many-arguments
262
- file: str | _Path,
262
+ path: _Path,
263
263
  disable: _Messages | None = None,
264
264
  check_class: bool = False,
265
265
  check_class_constructor: bool = False,
@@ -278,7 +278,7 @@ def runner( # pylint: disable=too-many-locals,too-many-arguments
278
278
  ) -> _Failures:
279
279
  """Per path runner.
280
280
 
281
- :param file: Path to check.
281
+ :param path: Path to check.
282
282
  :param disable: Messages to disable.
283
283
  :param check_class: Check class docstrings.
284
284
  :param check_class_constructor: Check ``__init__`` methods. Note
@@ -300,7 +300,7 @@ def runner( # pylint: disable=too-many-locals,too-many-arguments
300
300
  :return: Exit status for whether test failed or not.
301
301
  """
302
302
  module = _from_file(
303
- _Path(file),
303
+ path,
304
304
  disable or _Messages(),
305
305
  ignore_args,
306
306
  ignore_kwargs,
@@ -324,7 +324,6 @@ def runner( # pylint: disable=too-many-locals,too-many-arguments
324
324
 
325
325
 
326
326
  @_decorators.parse_msgs
327
- @_decorators.handle_deprecations
328
327
  @_decorators.validate_args
329
328
  def docsig( # pylint: disable=too-many-locals,too-many-arguments
330
329
  *path: str | _Path,
@@ -392,21 +391,21 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
392
391
  if list_checks:
393
392
  return int(bool(_print_checks())) # type: ignore
394
393
 
395
- patterns = [_DEFAULT_EXCLUDES]
394
+ exclude_ = [_DEFAULT_EXCLUDES]
396
395
  if exclude is not None:
397
- patterns.append(exclude)
396
+ exclude_.append(exclude)
398
397
 
399
398
  if string is None:
400
399
  retcodes = [0]
401
400
  paths = _Paths(
402
401
  *path,
403
- patterns=patterns,
404
- excludes=excludes or [],
402
+ patterns=exclude_,
403
+ excludes=excludes,
405
404
  include_ignored=include_ignored,
406
405
  )
407
- for file in paths:
406
+ for path_ in paths:
408
407
  failures = runner(
409
- file,
408
+ path_,
410
409
  disable,
411
410
  check_class,
412
411
  check_class_constructor,
@@ -423,7 +422,7 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
423
422
  no_ansi,
424
423
  target,
425
424
  )
426
- retcodes.append(_report(failures, str(file), no_ansi))
425
+ retcodes.append(_report(failures, str(path_), no_ansi))
427
426
 
428
427
  return max(retcodes)
429
428
 
@@ -9,7 +9,6 @@ import functools as _functools
9
9
  import sys as _sys
10
10
  import typing as _t
11
11
  from pathlib import Path as _Path
12
- from warnings import warn as _warn
13
12
 
14
13
  from .messages import E as _E
15
14
 
@@ -35,28 +34,6 @@ def parse_msgs(func: _WrappedFuncType) -> _WrappedFuncType:
35
34
  return _wrapper
36
35
 
37
36
 
38
- def handle_deprecations(func: _WrappedFuncType) -> _WrappedFuncType:
39
- """Allow, but warn, of deprecated arguments.
40
-
41
- :param func: Function to wrap.
42
- :return: Wrapped function.
43
- """
44
-
45
- @_functools.wraps(func)
46
- def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> str | int:
47
- if kwargs.pop("summary", None):
48
- _warn(
49
- "summary is deprecated and will be removed in a future"
50
- " version",
51
- category=DeprecationWarning,
52
- stacklevel=4,
53
- )
54
-
55
- return func(*args, **kwargs)
56
-
57
- return _wrapper
58
-
59
-
60
37
  def validate_args(func: _FuncType) -> _WrappedFuncType:
61
38
  """Confirm args passed to function are valid.
62
39
 
@@ -82,7 +82,7 @@ class Paths(_t.List[_Path]):
82
82
  self,
83
83
  *paths: _Path | str,
84
84
  patterns: list[str],
85
- excludes: list[str],
85
+ excludes: list[str] | None = None,
86
86
  include_ignored: bool = False,
87
87
  ) -> None:
88
88
  super().__init__()
@@ -39,7 +39,6 @@ def main() -> str | int:
39
39
  ignore_kwargs=a.ignore_kwargs,
40
40
  ignore_typechecker=a.ignore_typechecker,
41
41
  no_ansi=a.no_ansi,
42
- summary=a.summary, # deprecated
43
42
  verbose=a.verbose,
44
43
  target=a.target,
45
44
  disable=a.disable,
@@ -31,7 +31,7 @@ class _Imports(_t.Dict[str, str]):
31
31
  """Represents python imports."""
32
32
 
33
33
 
34
- class Parent(_t.List["Parent"]):
34
+ class Parent: # pylint: disable=too-many-instance-attributes
35
35
  """Represents an object that contains functions or methods.
36
36
 
37
37
  :param node: Parent's abstract syntax tree.
@@ -64,13 +64,14 @@ class Parent(_t.List["Parent"]):
64
64
  self._ignore_args = ignore_args
65
65
  self._ignore_kwargs = ignore_kwargs
66
66
  self._check_class_constructor = check_class_constructor
67
+ self._children = _Children()
68
+ self._imports = imports or _Imports()
69
+ self._overloads = _Overloads()
67
70
  if node is None:
68
71
  if not isinstance(self, Function) and error is not None:
69
- self.append(Function(path, error=error))
72
+ self._children.append(Function(path, error=error))
70
73
  else:
71
74
  self._name = node.name
72
- self._overloads = _Overloads()
73
- self._imports = imports or _Imports()
74
75
  self._parse_ast(node, directives or _Directives(), path)
75
76
 
76
77
  def _parse_ast(
@@ -121,9 +122,9 @@ class Parent(_t.List["Parent"]):
121
122
  self._overloads[func.name].signature.rettype
122
123
  )
123
124
 
124
- self.append(func)
125
+ self._children.append(func)
125
126
  elif isinstance(subnode, _ast.ClassDef):
126
- self.append(
127
+ self._children.append(
127
128
  Parent(
128
129
  subnode,
129
130
  directives,
@@ -147,6 +148,11 @@ class Parent(_t.List["Parent"]):
147
148
  """Represents an unrecoverable error, if any."""
148
149
  return self._error
149
150
 
151
+ @property
152
+ def children(self) -> _Children:
153
+ """Children of this parent."""
154
+ return self._children
155
+
150
156
 
151
157
  class Function(Parent):
152
158
  """Represents a function with signature and docstring parameters.
@@ -337,3 +343,7 @@ class Function(Parent):
337
343
 
338
344
  class _Overloads(_t.Dict[str, Function]):
339
345
  """Represents overloaded methods."""
346
+
347
+
348
+ class _Children(_t.List[_t.Union[Parent, Function]]):
349
+ """Represents children of object."""
@@ -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.64.0"
11
+ __version__ = "0.65.0"
@@ -3,6 +3,7 @@
3
3
  import ast
4
4
  import typing as t
5
5
  from argparse import Namespace
6
+ from pathlib import Path
6
7
 
7
8
  from ._config import get_config as _get_config
8
9
  from ._config import merge_configs as _merge_configs
@@ -147,7 +148,7 @@ class Docsig:
147
148
  else:
148
149
  setup_logger(self.a.verbose)
149
150
  results = runner(
150
- self.filename,
151
+ Path(self.filename),
151
152
  check_class=self.a.check_class,
152
153
  check_class_constructor=self.a.check_class_constructor,
153
154
  check_dunders=self.a.check_dunders,
@@ -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.64.0"
14
+ current_version = "0.65.0"
15
15
  message = "bump: version {current_version} → {new_version}"
16
16
  sign_tags = true
17
17
  tag = true
@@ -131,7 +131,7 @@ maintainers = [
131
131
  name = "docsig"
132
132
  readme = "README.rst"
133
133
  repository = "https://github.com/jshwi/docsig"
134
- version = "0.64.0"
134
+ version = "0.65.0"
135
135
 
136
136
  [tool.poetry.dependencies]
137
137
  Sphinx = "^7.0.0"
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