duty 1.5.0__py3-none-any.whl → 1.6.1__py3-none-any.whl

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.
Files changed (82) hide show
  1. duty/__init__.py +49 -2
  2. duty/__main__.py +1 -1
  3. duty/_internal/__init__.py +0 -0
  4. duty/_internal/callables/__init__.py +34 -0
  5. duty/{callables → _internal/callables}/_io.py +2 -0
  6. duty/_internal/callables/autoflake.py +132 -0
  7. duty/_internal/callables/black.py +176 -0
  8. duty/_internal/callables/blacken_docs.py +92 -0
  9. duty/_internal/callables/build.py +76 -0
  10. duty/_internal/callables/coverage.py +716 -0
  11. duty/_internal/callables/flake8.py +222 -0
  12. duty/_internal/callables/git_changelog.py +178 -0
  13. duty/_internal/callables/griffe.py +227 -0
  14. duty/_internal/callables/interrogate.py +152 -0
  15. duty/_internal/callables/isort.py +573 -0
  16. duty/_internal/callables/mkdocs.py +256 -0
  17. duty/_internal/callables/mypy.py +496 -0
  18. duty/_internal/callables/pytest.py +475 -0
  19. duty/_internal/callables/ruff.py +399 -0
  20. duty/_internal/callables/safety.py +82 -0
  21. duty/_internal/callables/ssort.py +38 -0
  22. duty/_internal/callables/twine.py +284 -0
  23. duty/_internal/cli.py +322 -0
  24. duty/_internal/collection.py +246 -0
  25. duty/_internal/context.py +111 -0
  26. duty/{debug.py → _internal/debug.py} +13 -15
  27. duty/_internal/decorator.py +111 -0
  28. duty/_internal/exceptions.py +12 -0
  29. duty/_internal/tools/__init__.py +41 -0
  30. duty/{tools → _internal/tools}/_autoflake.py +8 -4
  31. duty/{tools → _internal/tools}/_base.py +15 -2
  32. duty/{tools → _internal/tools}/_black.py +5 -5
  33. duty/{tools → _internal/tools}/_blacken_docs.py +10 -5
  34. duty/{tools → _internal/tools}/_build.py +4 -4
  35. duty/{tools → _internal/tools}/_coverage.py +8 -4
  36. duty/{tools → _internal/tools}/_flake8.py +10 -12
  37. duty/{tools → _internal/tools}/_git_changelog.py +8 -4
  38. duty/{tools → _internal/tools}/_griffe.py +8 -4
  39. duty/{tools → _internal/tools}/_interrogate.py +4 -4
  40. duty/{tools → _internal/tools}/_isort.py +8 -6
  41. duty/{tools → _internal/tools}/_mkdocs.py +8 -4
  42. duty/{tools → _internal/tools}/_mypy.py +5 -5
  43. duty/{tools → _internal/tools}/_pytest.py +8 -4
  44. duty/{tools → _internal/tools}/_ruff.py +11 -5
  45. duty/{tools → _internal/tools}/_safety.py +13 -8
  46. duty/{tools → _internal/tools}/_ssort.py +10 -6
  47. duty/{tools → _internal/tools}/_twine.py +11 -5
  48. duty/_internal/tools/_yore.py +96 -0
  49. duty/_internal/validation.py +266 -0
  50. duty/callables/__init__.py +4 -4
  51. duty/callables/autoflake.py +11 -126
  52. duty/callables/black.py +12 -171
  53. duty/callables/blacken_docs.py +11 -86
  54. duty/callables/build.py +12 -71
  55. duty/callables/coverage.py +12 -711
  56. duty/callables/flake8.py +12 -217
  57. duty/callables/git_changelog.py +12 -173
  58. duty/callables/griffe.py +12 -222
  59. duty/callables/interrogate.py +12 -147
  60. duty/callables/isort.py +12 -568
  61. duty/callables/mkdocs.py +12 -251
  62. duty/callables/mypy.py +11 -490
  63. duty/callables/pytest.py +12 -470
  64. duty/callables/ruff.py +12 -394
  65. duty/callables/safety.py +11 -76
  66. duty/callables/ssort.py +12 -33
  67. duty/callables/twine.py +12 -279
  68. duty/cli.py +10 -316
  69. duty/collection.py +12 -228
  70. duty/completions.bash +9 -9
  71. duty/context.py +12 -107
  72. duty/decorator.py +12 -108
  73. duty/exceptions.py +13 -10
  74. duty/tools.py +63 -0
  75. duty/validation.py +12 -262
  76. {duty-1.5.0.dist-info → duty-1.6.1.dist-info}/METADATA +4 -3
  77. duty-1.6.1.dist-info/RECORD +81 -0
  78. {duty-1.5.0.dist-info → duty-1.6.1.dist-info}/WHEEL +1 -1
  79. {duty-1.5.0.dist-info → duty-1.6.1.dist-info}/entry_points.txt +1 -1
  80. duty/tools/__init__.py +0 -48
  81. duty-1.5.0.dist-info/RECORD +0 -54
  82. {duty-1.5.0.dist-info → duty-1.6.1.dist-info}/licenses/LICENSE +0 -0
duty/callables/black.py CHANGED
@@ -1,176 +1,17 @@
1
- """Callable for [Black](https://github.com/psf/black)."""
1
+ """Deprecated. Use [`duty.tools.black`][] instead."""
2
2
 
3
- from __future__ import annotations
3
+ # YORE: Bump 2: Remove file.
4
4
 
5
- from failprint.lazy import lazy
5
+ import warnings
6
+ from typing import Any
6
7
 
8
+ from duty._internal.callables import black as _black
7
9
 
8
- @lazy(name="black")
9
- def run(
10
- *src: str,
11
- config: str | None = None,
12
- code: str | None = None,
13
- line_length: int | None = None,
14
- target_version: str | None = None,
15
- check: bool | None = None,
16
- diff: bool | None = None,
17
- color: bool | None = None,
18
- fast: bool | None = None,
19
- pyi: bool | None = None,
20
- ipynb: bool | None = None,
21
- python_cell_magics: str | None = None,
22
- skip_source_first_line: bool | None = None,
23
- skip_string_normalization: bool | None = None,
24
- skip_magic_trailing_comma: bool | None = None,
25
- experimental_string_processing: bool | None = None,
26
- preview: bool | None = None,
27
- quiet: bool | None = None,
28
- verbose: bool | None = None,
29
- required_version: str | None = None,
30
- include: str | None = None,
31
- exclude: str | None = None,
32
- extend_exclude: str | None = None,
33
- force_exclude: str | None = None,
34
- stdin_filename: str | None = None,
35
- workers: int | None = None,
36
- ) -> None:
37
- r"""Run `black`.
38
10
 
39
- Parameters:
40
- src: Format the directories and file paths.
41
- config: Read configuration from this file path.
42
- code: Format the code passed in as a string.
43
- line_length: How many characters per line to allow [default: 120].
44
- target_version: Python versions that should be supported by Black's output.
45
- By default, Black will try to infer this from the project metadata in pyproject.toml.
46
- If this does not yield conclusive results, Black will use per-file auto-detection.
47
- check: Don't write the files back, just return the status. Return code 0 means nothing would change.
48
- Return code 1 means some files would be reformatted. Return code 123 means there was an internal error.
49
- diff: Don't write the files back, just output a diff for each file on stdout.
50
- color: Show colored diff. Only applies when `--diff` is given.
51
- fast: If --fast given, skip temporary sanity checks. [default: --safe]
52
- pyi: Format all input files like typing stubs regardless of file extension
53
- (useful when piping source on standard input).
54
- ipynb: Format all input files like Jupyter Notebooks regardless of file extension
55
- (useful when piping source on standard input).
56
- python_cell_magics: When processing Jupyter Notebooks, add the given magic to the list of known python-magics
57
- (capture, prun, pypy, python, python3, time, timeit). Useful for formatting cells with custom python magics.
58
- skip_source_first_line: Skip the first line of the source code.
59
- skip_string_normalization: Don't normalize string quotes or prefixes.
60
- skip_magic_trailing_comma: Don't use trailing commas as a reason to split lines.
61
- preview: Enable potentially disruptive style changes that may be added
62
- to Black's main functionality in the next major release.
63
- quiet: Don't emit non-error messages to stderr. Errors are still emitted; silence those with 2>/dev/null.
64
- verbose: Also emit messages to stderr about files that were not changed or were ignored due to exclusion patterns.
65
- required_version: Require a specific version of Black to be running (useful for unifying results
66
- across many environments e.g. with a pyproject.toml file).
67
- It can be either a major version number or an exact version.
68
- include: A regular expression that matches files and directories that should be included on recursive searches.
69
- An empty value means all files are included regardless of the name. Use forward slashes for directories
70
- on all platforms (Windows, too). Exclusions are calculated first, inclusions later [default: (\.pyi?|\.ipynb)$].
71
- exclude: A regular expression that matches files and directories that should be excluded on recursive searches.
72
- An empty value means no paths are excluded. Use forward slashes for directories on all platforms (Windows, too).
73
- Exclusions are calculated first, inclusions later [default: /(\.direnv|\.eggs|\.git|\.hg|\.mypy_cache|\.nox|
74
- \.tox|\.venv|venv|\.svn|\.ipynb_checkpoints|_build|buck-out|build|dist|__pypackages__)/].
75
- extend_exclude: Like --exclude, but adds additional files and directories on top of the excluded ones
76
- (useful if you simply want to add to the default).
77
- force_exclude: Like --exclude, but files and directories matching this regex will be excluded
78
- even when they are passed explicitly as arguments.
79
- stdin_filename: The name of the file when passing it through stdin. Useful to make sure Black will respect
80
- --force-exclude option on some editors that rely on using stdin.
81
- workers: Number of parallel workers [default: number CPUs in the system].
82
- """
83
- from black import main as black
84
-
85
- cli_args = list(src)
86
-
87
- if config:
88
- cli_args.append("--config")
89
- cli_args.append(config)
90
-
91
- if code:
92
- cli_args.append("--code")
93
- cli_args.append(code)
94
-
95
- if line_length:
96
- cli_args.append("--line-length")
97
- cli_args.append(str(line_length))
98
-
99
- if target_version:
100
- cli_args.append("--target-version")
101
- cli_args.append(target_version)
102
-
103
- if check:
104
- cli_args.append("--check")
105
-
106
- if diff:
107
- cli_args.append("--diff")
108
-
109
- if color is True:
110
- cli_args.append("--color")
111
- elif color is False:
112
- cli_args.append("--no-color")
113
-
114
- if fast:
115
- cli_args.append("--fast")
116
-
117
- if pyi:
118
- cli_args.append("--pyi")
119
-
120
- if ipynb:
121
- cli_args.append("--ipynb")
122
-
123
- if python_cell_magics:
124
- cli_args.append("--python-cell-magics")
125
- cli_args.append(python_cell_magics)
126
-
127
- if skip_source_first_line:
128
- cli_args.append("--skip_source_first_line")
129
-
130
- if skip_string_normalization:
131
- cli_args.append("--skip_string_normalization")
132
-
133
- if skip_magic_trailing_comma:
134
- cli_args.append("--skip_magic_trailing_comma")
135
-
136
- if experimental_string_processing:
137
- cli_args.append("--experimental_string_processing")
138
-
139
- if preview:
140
- cli_args.append("--preview")
141
-
142
- if quiet:
143
- cli_args.append("--quiet")
144
-
145
- if verbose:
146
- cli_args.append("--verbose")
147
-
148
- if required_version:
149
- cli_args.append("--required-version")
150
- cli_args.append(required_version)
151
-
152
- if include:
153
- cli_args.append("--include")
154
- cli_args.append(include)
155
-
156
- if exclude:
157
- cli_args.append("--exclude")
158
- cli_args.append(exclude)
159
-
160
- if extend_exclude:
161
- cli_args.append("--extend-exclude")
162
- cli_args.append(extend_exclude)
163
-
164
- if force_exclude:
165
- cli_args.append("--force-exclude")
166
- cli_args.append(force_exclude)
167
-
168
- if stdin_filename:
169
- cli_args.append("--stdin-filename")
170
- cli_args.append(stdin_filename)
171
-
172
- if workers:
173
- cli_args.append("--workers")
174
- cli_args.append(str(workers))
175
-
176
- return black(cli_args, prog_name="black")
11
+ def __getattr__(name: str) -> Any:
12
+ warnings.warn(
13
+ "Callables are deprecated in favor of tools, use `duty.tools.black` instead of `duty.callables.black`.",
14
+ DeprecationWarning,
15
+ stacklevel=2,
16
+ )
17
+ return getattr(_black, name)
@@ -1,92 +1,17 @@
1
- """Callable for [blacken-docs](https://github.com/adamchainz/blacken-docs)."""
1
+ """Deprecated. Use [`duty.tools.blacken_docs`][] instead."""
2
2
 
3
- from __future__ import annotations
3
+ # YORE: Bump 2: Remove file.
4
4
 
5
- import re
6
- from pathlib import Path
7
- from re import Pattern
8
- from typing import TYPE_CHECKING
5
+ import warnings
6
+ from typing import Any
9
7
 
10
- from failprint.lazy import lazy
8
+ from duty._internal.callables import blacken_docs as _blacken_docs
11
9
 
12
- if TYPE_CHECKING:
13
- from collections.abc import Sequence
14
10
 
15
-
16
- @lazy(name="blacken_docs")
17
- def run(
18
- *paths: str | Path,
19
- exts: Sequence[str] | None = None,
20
- exclude: Sequence[str | Pattern] | None = None,
21
- skip_errors: bool = False,
22
- rst_literal_blocks: bool = False,
23
- line_length: int | None = None,
24
- string_normalization: bool = True,
25
- is_pyi: bool = False,
26
- is_ipynb: bool = False,
27
- skip_source_first_line: bool = False,
28
- magic_trailing_comma: bool = True,
29
- python_cell_magics: set[str] | None = None,
30
- preview: bool = False,
31
- check_only: bool = False,
32
- ) -> int:
33
- """Run `blacken-docs`.
34
-
35
- Parameters:
36
- *paths: Directories and files to format.
37
- exts: List of extensions to select files with.
38
- exclude: List of regular expressions to exclude files.
39
- skip_errors: Don't exit non-zero for errors from Black (normally syntax errors).
40
- rst_literal_blocks: Also format literal blocks in reStructuredText files (more below).
41
- line_length: How many characters per line to allow.
42
- string_normalization: Normalize string quotes or prefixes.
43
- is_pyi: Format all input files like typing stubs regardless of file extension.
44
- is_ipynb: Format all input files like Jupyter Notebooks regardless of file extension.
45
- skip_source_first_line: Skip the first line of the source code.
46
- magic_trailing_comma: Use trailing commas as a reason to split lines.
47
- python_cell_magics: When processing Jupyter Notebooks, add the given magic to the list
48
- of known python-magics (capture, prun, pypy, python, python3, time, timeit).
49
- Useful for formatting cells with custom python magics.
50
- preview: Enable potentially disruptive style changes that may be added
51
- to Black's main functionality in the next major release.
52
- check_only: Don't modify files but indicate when changes are necessary
53
- with a message and non-zero return code.
54
-
55
- Returns:
56
- Success/failure.
57
- """
58
- import black
59
- from blacken_docs import format_file
60
-
61
- exts = ("md", "py") if exts is None else tuple(ext.lstrip(".") for ext in exts)
62
- if exclude:
63
- exclude = tuple(re.compile(regex, re.I) if isinstance(regex, str) else regex for regex in exclude)
64
- filepaths = set()
65
- for path in paths:
66
- path = Path(path) # noqa: PLW2901
67
- if path.is_file():
68
- filepaths.add(path.as_posix())
69
- else:
70
- for ext in exts:
71
- filepaths |= {filepath.as_posix() for filepath in path.rglob(f"*.{ext}")}
72
-
73
- black_mode = black.Mode(
74
- line_length=line_length or black.DEFAULT_LINE_LENGTH,
75
- string_normalization=string_normalization,
76
- is_pyi=is_pyi,
77
- is_ipynb=is_ipynb,
78
- skip_source_first_line=skip_source_first_line,
79
- magic_trailing_comma=magic_trailing_comma,
80
- python_cell_magics=python_cell_magics or set(),
81
- preview=preview,
11
+ def __getattr__(name: str) -> Any:
12
+ warnings.warn(
13
+ "Callables are deprecated in favor of tools, use `duty.tools.blacken_docs` instead of `duty.callables.blacken_docs`.",
14
+ DeprecationWarning,
15
+ stacklevel=2,
82
16
  )
83
- retv = 0
84
- for filepath in sorted(filepaths):
85
- retv |= format_file(
86
- filepath,
87
- black_mode,
88
- skip_errors=skip_errors,
89
- rst_literal_blocks=rst_literal_blocks,
90
- check_only=check_only,
91
- )
92
- return retv
17
+ return getattr(_blacken_docs, name)
duty/callables/build.py CHANGED
@@ -1,76 +1,17 @@
1
- """Callable for [build](https://github.com/pypa/build)."""
1
+ """Deprecated. Use [`duty.tools.build`][] instead."""
2
2
 
3
- from __future__ import annotations
3
+ # YORE: Bump 2: Remove file.
4
4
 
5
- from typing import Literal
5
+ import warnings
6
+ from typing import Any
6
7
 
7
- from failprint.lazy import lazy
8
+ from duty._internal.callables import build as _build
8
9
 
9
10
 
10
- @lazy(name="build")
11
- def run(
12
- srcdir: str | None = None,
13
- *,
14
- version: bool = False,
15
- verbose: bool = False,
16
- sdist: bool = False,
17
- wheel: bool = False,
18
- outdir: str | None = None,
19
- skip_dependency_check: bool = False,
20
- no_isolation: bool = False,
21
- installer: Literal["pip", "uv"] | None = None,
22
- config_setting: list[str] | None = None,
23
- ) -> None:
24
- """Run `build`.
25
-
26
- Parameters:
27
- srcdir: Source directory (defaults to current directory).
28
- version: Show program's version number and exit.
29
- verbose: Increase verbosity
30
- sdist: Build a source distribution (disables the default behavior).
31
- wheel: Build a wheel (disables the default behavior).
32
- outdir: Output directory (defaults to `{srcdir}/dist`).
33
- skip_dependency_check: Do not check that build dependencies are installed.
34
- no_isolation: Disable building the project in an isolated virtual environment.
35
- Build dependencies must be installed separately when this option is used.
36
- installer: Python package installer to use (defaults to pip).
37
- config_setting: Settings to pass to the backend. Multiple settings can be provided.
38
- """
39
- from build.__main__ import main as build
40
-
41
- cli_args = []
42
-
43
- if srcdir:
44
- cli_args.append(srcdir)
45
-
46
- if version:
47
- cli_args.append("--version")
48
-
49
- if verbose:
50
- cli_args.append("--verbose")
51
-
52
- if sdist:
53
- cli_args.append("--sdist")
54
-
55
- if wheel:
56
- cli_args.append("--wheel")
57
-
58
- if outdir:
59
- cli_args.append("--outdir")
60
- cli_args.append(outdir)
61
-
62
- if skip_dependency_check:
63
- cli_args.append("--skip-dependency-check")
64
-
65
- if no_isolation:
66
- cli_args.append("--no-isolation")
67
-
68
- if installer:
69
- cli_args.append("--installer")
70
- cli_args.append(installer)
71
-
72
- if config_setting:
73
- for setting in config_setting:
74
- cli_args.append(f"--config-setting={setting}")
75
-
76
- build(cli_args)
11
+ def __getattr__(name: str) -> Any:
12
+ warnings.warn(
13
+ "Callables are deprecated in favor of tools, use `duty.tools.build` instead of `duty.callables.build`.",
14
+ DeprecationWarning,
15
+ stacklevel=2,
16
+ )
17
+ return getattr(_build, name)