docsig 0.85.1__tar.gz → 0.85.2__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.4
2
2
  Name: docsig
3
- Version: 0.85.1
3
+ Version: 0.85.2
4
4
  Summary: Check signature params for proper documentation
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -195,7 +195,7 @@ ensure your installation has registered `docsig`
195
195
  .. code-block:: console
196
196
 
197
197
  $ flake8 --version
198
- 7.3.0 (docsig: 0.85.1, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
198
+ 7.3.0 (docsig: 0.85.2, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
199
199
 
200
200
  And now use `flake8` to lint your files
201
201
 
@@ -281,7 +281,7 @@ Standalone
281
281
 
282
282
  repos:
283
283
  - repo: https://github.com/jshwi/docsig
284
- rev: v0.85.1
284
+ rev: v0.85.2
285
285
  hooks:
286
286
  - id: docsig
287
287
  args:
@@ -300,7 +300,7 @@ or integrated with ``flake8``
300
300
  hooks:
301
301
  - id: flake8
302
302
  additional_dependencies:
303
- - docsig==0.85.1
303
+ - docsig==0.85.2
304
304
  args:
305
305
  - "--sig-check-class"
306
306
  - "--sig-check-dunders"
@@ -166,7 +166,7 @@ ensure your installation has registered `docsig`
166
166
  .. code-block:: console
167
167
 
168
168
  $ flake8 --version
169
- 7.3.0 (docsig: 0.85.1, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
169
+ 7.3.0 (docsig: 0.85.2, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
170
170
 
171
171
  And now use `flake8` to lint your files
172
172
 
@@ -252,7 +252,7 @@ Standalone
252
252
 
253
253
  repos:
254
254
  - repo: https://github.com/jshwi/docsig
255
- rev: v0.85.1
255
+ rev: v0.85.2
256
256
  hooks:
257
257
  - id: docsig
258
258
  args:
@@ -271,7 +271,7 @@ or integrated with ``flake8``
271
271
  hooks:
272
272
  - id: flake8
273
273
  additional_dependencies:
274
- - docsig==0.85.1
274
+ - docsig==0.85.2
275
275
  args:
276
276
  - "--sig-check-class"
277
277
  - "--sig-check-dunders"
@@ -5,4 +5,9 @@ from ._core import docsig
5
5
  from ._main import main
6
6
  from ._version import __version__
7
7
 
8
- __all__ = ["__version__", "docsig", "main", "messages"]
8
+ __all__ = [
9
+ "__version__",
10
+ "docsig",
11
+ "main",
12
+ "messages",
13
+ ]
@@ -3,8 +3,6 @@ docsig._check
3
3
  =============
4
4
  """
5
5
 
6
- from __future__ import annotations as _
7
-
8
6
  from ._config import Config as _Config
9
7
  from ._module import Function as _Function
10
8
  from ._module import Parent as _Parent
@@ -5,8 +5,6 @@ docsig._config
5
5
  Config dataclasses, pyproject.toml loader, and commandline.
6
6
  """
7
7
 
8
- from __future__ import annotations as _
9
-
10
8
  import argparse as _argparse
11
9
  import os as _os
12
10
  import re as _re
@@ -5,8 +5,6 @@ docsig._core
5
5
  Entry point and orchestration for running docstring/signature checks.
6
6
  """
7
7
 
8
- from __future__ import annotations as _
9
-
10
8
  import logging as _logging
11
9
  import sys as _sys
12
10
  import warnings as _warnings
@@ -175,6 +173,9 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
175
173
  if exclude is not None:
176
174
  exclude_.append(exclude)
177
175
 
176
+ # while some params could be taken out for one time use (such as
177
+ # verbose), bundling all the configuration together makes it easier
178
+ # to report what args were provided in verbose mode
178
179
  check = _Check(
179
180
  class_=check_class,
180
181
  class_constructor=check_class_constructor,
@@ -3,8 +3,6 @@ docsig._decorators
3
3
  ==================
4
4
  """
5
5
 
6
- from __future__ import annotations as _
7
-
8
6
  import functools as _functools
9
7
  import sys as _sys
10
8
  import typing as _t
@@ -36,10 +36,23 @@ class Comment(_Messages):
36
36
  self._kind = subparts[0]
37
37
  self._flag = None if len(subparts) == 1 else subparts[1]
38
38
  self._isnext = self._flag == "next"
39
- if len(parts) == 1:
40
- self.extend(_E.all)
41
- else:
42
- self.extend(_E.from_ref(i) for i in parts[1].split(","))
39
+
40
+ # if the flag is not valid, the preceding directive is not valid
41
+ # either
42
+ # at first it seems like the directive should be valid, i.e.
43
+ # `docsig: disable-next: SIG101` should still at least disable
44
+ # `SIG101`, but this causes more problems than it solves, at the
45
+ # module level
46
+ # disabling the check for the whole file is likely
47
+ # unexpected, confusing, and the opposite of what was intended
48
+ # better not disable the commented function than disable the
49
+ # whole file
50
+ # note that no directive flag at all is still a valid flag
51
+ if self.isvalidflag:
52
+ if len(parts) == 1:
53
+ self.extend(_E.all)
54
+ else:
55
+ self.extend(_E.from_ref(i) for i in parts[1].split(","))
43
56
 
44
57
  @property
45
58
  def kind(self) -> str:
@@ -90,7 +103,7 @@ class Comment(_Messages):
90
103
  :return: Comment instance if valid; None otherwise.
91
104
  """
92
105
  if comment[1:].strip().startswith(f"{__package__}:"):
93
- return cls(comment.split(":")[1].strip(), col)
106
+ return cls(comment.split(":", maxsplit=1)[1].strip(), col)
94
107
 
95
108
  return None
96
109
 
@@ -5,8 +5,6 @@ docsig._files
5
5
  Path collection and filtering for files to check.
6
6
  """
7
7
 
8
- from __future__ import annotations as _
9
-
10
8
  import logging as _logging
11
9
  import os as _os
12
10
  import re as _re
@@ -5,8 +5,6 @@ docsig._main
5
5
  CLI entry point that parses args and runs docsig.
6
6
  """
7
7
 
8
- from __future__ import annotations as _
9
-
10
8
  import sys as _sys
11
9
  import warnings as _warnings
12
10
 
@@ -5,8 +5,6 @@ docsig._module
5
5
  AST-backed modules, classes, and functions for docstring checking.
6
6
  """
7
7
 
8
- from __future__ import annotations as _
9
-
10
8
  import re as _re
11
9
  import typing as _t
12
10
  from pathlib import Path as _Path
@@ -38,6 +36,8 @@ ERRORS = (
38
36
  _ast.DuplicateBasesError,
39
37
  )
40
38
 
39
+ _DEFAULT_NAME = "module"
40
+
41
41
 
42
42
  class Parent: # pylint: disable=too-many-instance-attributes
43
43
  """Container for functions or methods (module, class, or function).
@@ -74,8 +74,14 @@ class Parent: # pylint: disable=too-many-instance-attributes
74
74
  self._imports = imports or _Imports()
75
75
  self._overloads = _Overloads()
76
76
  if node is None:
77
- self._name = "module"
77
+ # this is either an empty module object (name it module)
78
+ # or an error preventing the module from being parsed
79
+ self._name = _DEFAULT_NAME
78
80
  if not isinstance(self, Function) and error is not None:
81
+ # the only "function" belonging to the module can be
82
+ # later inspected to report on the module error (the
83
+ # report doesn't analyze modules or classes - it
84
+ # analyzes functions)
79
85
  self._children.append(Function(file, error=error))
80
86
  else:
81
87
  self._name = node.name
@@ -3,8 +3,6 @@ docsig._parsers
3
3
  ===============
4
4
  """
5
5
 
6
- from __future__ import annotations as _
7
-
8
6
  import logging as _logging
9
7
  import os as _os
10
8
  from pathlib import Path as _Path
@@ -79,11 +77,16 @@ def parse_from_file(file: _Path, config: _Config) -> _Parent:
79
77
  code = file.read_text(encoding="utf-8")
80
78
  module_name = str(file)[:-3].replace(_os.sep, ".").replace("-", "_")
81
79
  parent = parse_from_string(code, config, module_name, file)
80
+
82
81
  except UnicodeDecodeError as err:
83
82
  logger = _logging.getLogger(__package__)
84
83
  logger.debug(_FILE_INFO, file, str(err).replace("\n", " "))
85
84
  parent = _Parent(error=type(err))
86
85
 
86
+ # not all python files end with .py, but considering this isn't a
87
+ # *.py file and there was an error parsing the file it's likely not
88
+ # meant to bea a python file
89
+ # return empty parent without the error
87
90
  if parent.error is not None and not file.name.endswith(".py"):
88
91
  parent = _Parent()
89
92
 
@@ -8,8 +8,6 @@ issue), Failures (sequence of failures), and report() to print them and
8
8
  return the highest exit code.
9
9
  """
10
10
 
11
- from __future__ import annotations as _
12
-
13
11
  import contextlib as _contextlib
14
12
  import sys as _sys
15
13
  import typing as _t
@@ -324,10 +322,13 @@ class Failure(list[Failed]):
324
322
  if self._func.error is _ast.AstroidSyntaxError:
325
323
  self._add(_E[901])
326
324
  self._retcode = 123
325
+ # unicode-decode-error
327
326
  if self._func.error is UnicodeDecodeError:
328
327
  self._add(_E[902])
328
+ # recursion-error
329
329
  if self._func.error is RecursionError:
330
330
  self._add(_E[903])
331
+ # duplicates-found-in-mros
331
332
  if self._func.error is _ast.DuplicateBasesError:
332
333
  self._add(_E[904])
333
334
 
@@ -5,8 +5,6 @@ docsig._utils
5
5
  Shared helpers.
6
6
  """
7
7
 
8
- from __future__ import annotations as _
9
-
10
8
  import re as _re
11
9
  import sys as _sys
12
10
  from difflib import SequenceMatcher as _SequenceMatcher
@@ -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.85.1"
11
+ __version__ = "0.85.2"
@@ -6,8 +6,6 @@ Error message definitions (Message, MessageMap, E) and format templates
6
6
  for docstring-check output.
7
7
  """
8
8
 
9
- from __future__ import annotations as _
10
-
11
9
  import typing as _t
12
10
 
13
11
  #: Error code for unknown errors.
@@ -19,9 +17,8 @@ TEMPLATE = "{ref}: {description} ({symbolic})"
19
17
  #: Flake8 template to format message strings.
20
18
  FLAKE8 = "{ref} {description} ({symbolic})"
21
19
 
22
- NEW = """\
23
- {ref} is a new violation and will error in a future version\
24
- """
20
+ #: Template for future messages that don't raise a violation yet
21
+ NEW = "{ref} is a new violation and will error in a future version"
25
22
 
26
23
 
27
24
  class Messages(list["Message"]):
@@ -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.85.1"
14
+ current_version = "0.85.2"
15
15
  message = "bump: version {current_version} → {new_version}"
16
16
  sign_tags = true
17
17
  tag = true
@@ -122,7 +122,7 @@ maintainers = [
122
122
  name = "docsig"
123
123
  readme = "README.rst"
124
124
  repository = "https://github.com/jshwi/docsig"
125
- version = "0.85.1"
125
+ version = "0.85.2"
126
126
 
127
127
  [tool.poetry.dependencies]
128
128
  Sphinx = ">=7,<9"
File without changes
File without changes
File without changes
File without changes
File without changes