docsig 0.86.0__tar.gz → 0.86.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.4
2
2
  Name: docsig
3
- Version: 0.86.0
3
+ Version: 0.86.1
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.86.0, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
198
+ 7.3.0 (docsig: 0.86.1, 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.86.0
284
+ rev: v0.86.1
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.86.0
303
+ - docsig==0.86.1
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.86.0, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.10.19 on Darwin
169
+ 7.3.0 (docsig: 0.86.1, 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.86.0
255
+ rev: v0.86.1
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.86.0
274
+ - docsig==0.86.1
275
275
  args:
276
276
  - "--sig-check-class"
277
277
  - "--sig-check-dunders"
@@ -336,6 +336,23 @@ class Ignore:
336
336
  kwargs: bool = False
337
337
 
338
338
 
339
+ @_dataclass
340
+ # pylint: disable-next=too-few-public-methods
341
+ class Filters:
342
+ """Configuration for which paths to filter.
343
+
344
+ :param exclude: Regular expression of files and dirs to exclude from
345
+ checks.
346
+ :param excludes: Files or dirs to exclude from checks.
347
+ :param include_ignored: Check files even if they match a gitignore
348
+ pattern.
349
+ """
350
+
351
+ exclude: list[str] = _field(default_factory=list)
352
+ excludes: list[str] = _field(default_factory=list)
353
+ include_ignored: bool = False
354
+
355
+
339
356
  @_dataclass(frozen=True)
340
357
  # pylint: disable-next=too-many-instance-attributes,too-few-public-methods
341
358
  class Config:
@@ -347,11 +364,9 @@ class Config:
347
364
 
348
365
  check: Check = _field(default_factory=Check)
349
366
  ignore: Ignore = _field(default_factory=Ignore)
367
+ filters: Filters = _field(default_factory=Filters)
350
368
  target: _Messages = _field(default_factory=_Messages)
351
369
  disable: _Messages = _field(default_factory=_Messages)
352
- exclude: list[str] = _field(default_factory=list)
353
- excludes: list[str] = _field(default_factory=list)
354
370
  list_checks: bool = False
355
- include_ignored: bool = False
356
371
  no_ansi: bool = False
357
372
  verbose: bool = False
@@ -15,6 +15,7 @@ from . import _decorators
15
15
  from ._check import run_checks as _run_checks
16
16
  from ._config import Check as _Check
17
17
  from ._config import Config as _Config
18
+ from ._config import Filters as _Filters
18
19
  from ._config import Ignore as _Ignore
19
20
  from ._files import Files as _Files
20
21
  from ._parsers import parse_from_file as _parse_from_file
@@ -191,17 +192,20 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
191
192
  args=ignore_args,
192
193
  kwargs=ignore_kwargs,
193
194
  )
195
+ filters = _Filters(
196
+ include_ignored=include_ignored,
197
+ exclude=exclude_,
198
+ excludes=excludes or [],
199
+ )
194
200
  config = _Config(
195
201
  list_checks=list_checks,
196
- include_ignored=include_ignored,
197
202
  check=check,
198
203
  ignore=ignore,
204
+ filters=filters,
199
205
  no_ansi=no_ansi,
200
206
  verbose=verbose,
201
207
  target=target or _Messages(),
202
208
  disable=disable,
203
- exclude=exclude_,
204
- excludes=excludes or [],
205
209
  )
206
210
  setup_logger(config.verbose)
207
211
  logger = _logging.getLogger(__package__)
@@ -215,7 +219,7 @@ def docsig( # pylint: disable=too-many-locals,too-many-arguments
215
219
  return _report(failures, config)
216
220
 
217
221
  retcodes = [0]
218
- files = _Files(path, config)
222
+ files = _Files(path, config.filters)
219
223
  for file in files:
220
224
  failures = runner(file, config)
221
225
  retcode = _report(failures, config, str(file))
@@ -11,7 +11,7 @@ from pathlib import Path as _Path
11
11
  from .messages import E as _E
12
12
 
13
13
  _FuncType = _t.Callable[..., int]
14
- _WrappedFuncType = _t.Callable[..., str | int]
14
+ _WrappedFuncType = _t.Callable[..., int]
15
15
 
16
16
 
17
17
  def parse_msgs(func: _WrappedFuncType) -> _WrappedFuncType:
@@ -25,7 +25,7 @@ def parse_msgs(func: _WrappedFuncType) -> _WrappedFuncType:
25
25
  """
26
26
 
27
27
  @_functools.wraps(func)
28
- def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> str | int:
28
+ def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> int:
29
29
  disable = _E.from_codes(kwargs.get("disable", [])) or None
30
30
  target = _E.from_codes(kwargs.get("target", [])) or None
31
31
  kwargs["disable"] = disable
@@ -50,7 +50,7 @@ def validate_args(func: _FuncType) -> _WrappedFuncType:
50
50
  """
51
51
 
52
52
  @_functools.wraps(func)
53
- def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> str | int:
53
+ def _wrapper(*args: str | _Path, **kwargs: _t.Any) -> int:
54
54
  stderr = []
55
55
  if not kwargs.get("list_checks", False):
56
56
  if not args and not kwargs.get("string"):
@@ -88,6 +88,10 @@ def validate_args(func: _FuncType) -> _WrappedFuncType:
88
88
  "please check your pyproject.toml configuration",
89
89
  )
90
90
 
91
- return "\n".join(stderr) if stderr else func(*args, **kwargs)
91
+ if stderr:
92
+ print("\n".join(stderr), file=_sys.stderr)
93
+ return 2
94
+
95
+ return func(*args, **kwargs)
92
96
 
93
97
  return _wrapper
@@ -14,7 +14,7 @@ from pathspec import PathSpec as _PathSpec
14
14
  from pathspec.patterns import GitWildMatchPattern as _GitWildMatchPattern
15
15
  from wcmatch.pathlib import Path as _WcPath
16
16
 
17
- from ._config import Config as _Config
17
+ from ._config import Filters as _Filters
18
18
 
19
19
  FILE_INFO = "%s: %s"
20
20
 
@@ -72,16 +72,16 @@ class Files(list[_Path]):
72
72
  """Collect paths to check (gitignore and exclude applied).
73
73
 
74
74
  :param paths: Path(s) to collect (files or directories).
75
- :param config: Configuration object.
75
+ :param filters: Filters object.
76
76
  """
77
77
 
78
78
  def __init__(
79
79
  self,
80
80
  paths: tuple[str | _Path, ...],
81
- config: _Config,
81
+ filters: _Filters,
82
82
  ) -> None:
83
83
  super().__init__()
84
- self._include_ignored = config.include_ignored
84
+ self._include_ignored = filters.include_ignored
85
85
  self._gitignore = _Gitignore()
86
86
  logger = _logging.getLogger(__package__)
87
87
  for path in paths:
@@ -89,8 +89,8 @@ class Files(list[_Path]):
89
89
 
90
90
  for path in list(self):
91
91
  if str(path) != "." and (
92
- any(_re.match(i, str(path)) for i in config.exclude)
93
- or any(_glob(path, i) for i in config.excludes)
92
+ any(_re.match(i, str(path)) for i in filters.exclude)
93
+ or any(_glob(path, i) for i in filters.excludes)
94
94
  ):
95
95
  logger.debug(FILE_INFO, path, "in exclude list, skipping")
96
96
  self.remove(path)
@@ -77,6 +77,7 @@ class Failure(list[Failed]):
77
77
  self._name = f"{self._func.parent.name}.{self._name}"
78
78
 
79
79
  if self._func.error is not None:
80
+ self._retcode.append(2)
80
81
  self._sig9xx_error()
81
82
  else:
82
83
  self._sig0xx_config()
@@ -364,6 +365,7 @@ def report(
364
365
  :return: Exit code (non-zero if any check failed).
365
366
  """
366
367
  retcodes = [0]
368
+ output = []
367
369
  for failure in failures:
368
370
  retcodes.append(failure.retcode)
369
371
  path_prefix = f"{file}:" if file is not None else ""
@@ -371,7 +373,7 @@ def report(
371
373
  if not config.no_ansi and _sys.stdout.isatty():
372
374
  header = f"\033[35m{header}\033[0m"
373
375
 
374
- print(header)
376
+ output.append(header)
375
377
  for item in failure:
376
378
  extra = None
377
379
  if item.hint:
@@ -381,15 +383,16 @@ def report(
381
383
  extra = "warning: please remember to fix this or disable it"
382
384
  _warn(_NEW.format(ref=item.ref), FutureWarning, stacklevel=3)
383
385
 
384
- print(
385
- " "
386
- + _TEMPLATE.format(
387
- ref=item.ref,
388
- description=item.description,
389
- symbolic=item.symbolic,
390
- ),
386
+ msg = _TEMPLATE.format(
387
+ ref=item.ref,
388
+ description=item.description,
389
+ symbolic=item.symbolic,
391
390
  )
391
+ output.append(f" {msg}")
392
392
  if extra is not None:
393
- print(f" {extra}")
393
+ output.append(f" {extra}")
394
+
395
+ if output:
396
+ print("\n".join(output))
394
397
 
395
398
  return max(retcodes)
@@ -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.86.0"
11
+ __version__ = "0.86.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.86.0"
14
+ current_version = "0.86.1"
15
15
  message = "bump: version {current_version} → {new_version}"
16
16
  sign_tags = true
17
17
  tag = true
@@ -117,7 +117,7 @@ maintainers = [
117
117
  name = "docsig"
118
118
  readme = "README.rst"
119
119
  repository = "https://github.com/jshwi/docsig"
120
- version = "0.86.0"
120
+ version = "0.86.1"
121
121
 
122
122
  [tool.poetry.dependencies]
123
123
  Sphinx = ">=7,<9"
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