docsig 0.59.0__tar.gz → 0.59.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: docsig
3
- Version: 0.59.0
3
+ Version: 0.59.1
4
4
  Summary: Check signature params for proper documentation
5
5
  Home-page: https://pypi.org/project/docsig/
6
6
  License: MIT
@@ -169,7 +169,7 @@ ensure your installation has registered `docsig`
169
169
  .. code-block:: console
170
170
 
171
171
  $ flake8 --version
172
- 7.1.0 (docsig: 0.59.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
172
+ 7.1.0 (docsig: 0.59.1, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
173
173
 
174
174
  And now use `flake8` to lint your files
175
175
 
@@ -258,7 +258,7 @@ Standalone
258
258
 
259
259
  repos:
260
260
  - repo: https://github.com/jshwi/docsig
261
- rev: v0.59.0
261
+ rev: v0.59.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.59.0
280
+ - docsig==0.59.1
281
281
  args:
282
282
  - "--sig-check-class"
283
283
  - "--sig-check-dunders"
@@ -143,7 +143,7 @@ ensure your installation has registered `docsig`
143
143
  .. code-block:: console
144
144
 
145
145
  $ flake8 --version
146
- 7.1.0 (docsig: 0.59.0, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
146
+ 7.1.0 (docsig: 0.59.1, mccabe: 0.7.0, pycodestyle: 2.12.0, pyflakes: 3.2.0) CPython 3.8.13 on Darwin
147
147
 
148
148
  And now use `flake8` to lint your files
149
149
 
@@ -232,7 +232,7 @@ Standalone
232
232
 
233
233
  repos:
234
234
  - repo: https://github.com/jshwi/docsig
235
- rev: v0.59.0
235
+ rev: v0.59.1
236
236
  hooks:
237
237
  - id: docsig
238
238
  args:
@@ -251,7 +251,7 @@ or integrated with ``flake8``
251
251
  hooks:
252
252
  - id: flake8
253
253
  additional_dependencies:
254
- - docsig==0.59.0
254
+ - docsig==0.59.1
255
255
  args:
256
256
  - "--sig-check-class"
257
257
  - "--sig-check-dunders"
@@ -14,7 +14,6 @@ from . import _decorators
14
14
  from ._directives import Directives as _Directives
15
15
  from ._files import FILE_INFO as _FILE_INFO
16
16
  from ._files import Paths as _Paths
17
- from ._module import Ast as _Ast
18
17
  from ._module import Function as _Function
19
18
  from ._module import Parent as _Parent
20
19
  from ._report import Failure as _Failure
@@ -119,6 +118,56 @@ def _run_check( # pylint: disable=too-many-arguments,too-many-locals
119
118
  )
120
119
 
121
120
 
121
+ def _parse_ast( # pylint: disable=too-many-arguments
122
+ messages: _Messages,
123
+ ignore_args: bool,
124
+ ignore_kwargs: bool,
125
+ check_class_constructor,
126
+ verbose: bool,
127
+ no_ansi: bool,
128
+ root: _Path | None = None,
129
+ string: str | None = None,
130
+ ) -> tuple[_Parent | None, int]:
131
+ parent = None
132
+ retcode = 0
133
+ try:
134
+ if root is not None:
135
+ string = root.read_text(encoding="utf-8")
136
+
137
+ # empty string won't happen but keeps the
138
+ # typechecker happy
139
+ string = string or ""
140
+ parent = _Parent(
141
+ _ast.parse(string),
142
+ _Directives(string, messages),
143
+ root,
144
+ ignore_args,
145
+ ignore_kwargs,
146
+ check_class_constructor,
147
+ )
148
+ _vprint(
149
+ _FILE_INFO.format(
150
+ path=root or "stdin", msg="Parsing Python code successful"
151
+ ),
152
+ verbose,
153
+ )
154
+ except (_ast.AstroidSyntaxError, UnicodeDecodeError) as err:
155
+ msg = str(err).replace("\n", " ")
156
+ if root is not None and root.name.endswith(".py"):
157
+ # pass by silently for files that do not end with .py, may
158
+ # result in a 123 syntax error exit status in the future
159
+ print(root, file=_sys.stderr)
160
+ _pretty_print_error(type(err), msg, no_ansi=no_ansi)
161
+ retcode = 1
162
+
163
+ _vprint(
164
+ _FILE_INFO.format(path=root or "stdin", msg=msg),
165
+ verbose,
166
+ )
167
+
168
+ return parent, retcode
169
+
170
+
122
171
  def _get_failures( # pylint: disable=too-many-locals,too-many-arguments
123
172
  module: _Parent,
124
173
  check_class: bool,
@@ -228,22 +277,16 @@ def runner( # pylint: disable=too-many-locals,too-many-arguments
228
277
  :return: Exit status for whether test failed or not.
229
278
  """
230
279
  failures = _Failures()
231
- path = _Path(file)
232
- string = path.read_text(encoding="utf-8")
233
- ast = _Ast.parse(string)
234
- if ast.success:
235
- _vprint(
236
- _FILE_INFO.format(path=path, msg="Parsing Python code successful"),
237
- verbose,
238
- )
239
- module = _Parent(
240
- ast.module,
241
- _Directives(string, disable or _Messages()),
242
- path,
243
- ignore_args,
244
- ignore_kwargs,
245
- check_class_constructor,
246
- )
280
+ module, retcode = _parse_ast(
281
+ disable or _Messages(),
282
+ ignore_args,
283
+ ignore_kwargs,
284
+ check_class_constructor,
285
+ verbose,
286
+ no_ansi,
287
+ root=_Path(file),
288
+ )
289
+ if module:
247
290
  failures = _get_failures(
248
291
  module,
249
292
  check_class,
@@ -259,20 +302,8 @@ def runner( # pylint: disable=too-many-locals,too-many-arguments
259
302
  no_ansi,
260
303
  target or _Messages(),
261
304
  )
262
- return failures, 0
263
-
264
- if path.name.endswith(".py"):
265
- # pass by silently for files that do not end with .py, may
266
- # result in a 123 syntax error exit status in the future
267
- print(path, file=_sys.stderr)
268
- _pretty_print_error(type(ast.err), str(ast.err), no_ansi=no_ansi)
269
- return failures, 1
270
305
 
271
- _vprint(
272
- _FILE_INFO.format(path=path, msg=str(ast.err)),
273
- verbose,
274
- )
275
- return failures, 0
306
+ return failures, retcode
276
307
 
277
308
 
278
309
  @_decorators.parse_msgs
@@ -380,21 +411,16 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
380
411
 
381
412
  return retcode
382
413
 
383
- ast = _Ast.parse(string)
384
- if ast.success:
385
- _vprint(
386
- _FILE_INFO.format(
387
- path="stdin", msg="Parsing Python code successful"
388
- ),
389
- verbose,
390
- )
391
- module = _Parent(
392
- _ast.parse(string),
393
- _Directives(string, messages=disable or _Messages()),
394
- ignore_args=ignore_args,
395
- ignore_kwargs=ignore_kwargs,
396
- check_class_constructor=check_class_constructor,
397
- )
414
+ module, retcode = _parse_ast(
415
+ disable or _Messages(),
416
+ ignore_args,
417
+ ignore_kwargs,
418
+ check_class_constructor,
419
+ verbose,
420
+ no_ansi,
421
+ string=string,
422
+ )
423
+ if module is not None:
398
424
  failures = _get_failures(
399
425
  module,
400
426
  check_class,
@@ -414,6 +440,4 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
414
440
  _report(failures, no_ansi=no_ansi)
415
441
  return 1
416
442
 
417
- _vprint(_FILE_INFO.format(path="stdin", msg=str(ast.err)), verbose)
418
-
419
443
  return 0
@@ -308,23 +308,3 @@ class Function(Parent):
308
308
  :param rettype: Return type of overloaded signature.
309
309
  """
310
310
  self._signature.overload(rettype)
311
-
312
-
313
- class Ast(_t.NamedTuple):
314
- """Object resulting from parsing an AST."""
315
-
316
- module: _ast.Module = _ast.Module("")
317
- err: Exception = Exception()
318
- success: bool = False
319
-
320
- @classmethod
321
- def parse(cls, string: str) -> Ast:
322
- """Parse an AST.
323
-
324
- :param string: String to parse.
325
- :return: Constructed AST object, whether successful or not.
326
- """
327
- try:
328
- return cls(module=_ast.parse(string), success=True)
329
- except (_ast.AstroidSyntaxError, UnicodeDecodeError) as err:
330
- return cls(err=err)
@@ -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.59.0"
11
+ __version__ = "0.59.1"
@@ -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.59.0"
14
+ current_version = "0.59.1"
15
15
  message = "bump: version {current_version} → {new_version}"
16
16
  sign_tags = true
17
17
  tag = true
@@ -132,7 +132,7 @@ maintainers = [
132
132
  name = "docsig"
133
133
  readme = "README.rst"
134
134
  repository = "https://github.com/jshwi/docsig"
135
- version = "0.59.0"
135
+ version = "0.59.1"
136
136
 
137
137
  [tool.poetry.dependencies]
138
138
  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
File without changes
File without changes
File without changes
File without changes
File without changes