duty 1.3.0__py3-none-any.whl → 1.4.0__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.
- duty/callables/__init__.py +32 -24
- duty/callables/build.py +76 -0
- duty/callables/git_changelog.py +178 -0
- duty/callables/griffe.py +227 -0
- duty/callables/twine.py +284 -0
- duty/cli.py +2 -0
- duty/context.py +6 -1
- duty/tools/__init__.py +48 -0
- duty/tools/_autoflake.py +138 -0
- duty/tools/_base.py +66 -0
- duty/tools/_black.py +184 -0
- duty/tools/_blacken_docs.py +115 -0
- duty/tools/_build.py +84 -0
- duty/tools/_coverage.py +721 -0
- duty/tools/_flake8.py +230 -0
- duty/tools/_git_changelog.py +186 -0
- duty/tools/_griffe.py +226 -0
- duty/tools/_interrogate.py +160 -0
- duty/tools/_isort.py +579 -0
- duty/tools/_mkdocs.py +271 -0
- duty/tools/_mypy.py +502 -0
- duty/tools/_pytest.py +483 -0
- duty/tools/_ruff.py +451 -0
- duty/tools/_safety.py +97 -0
- duty/tools/_ssort.py +44 -0
- duty/tools/_twine.py +289 -0
- {duty-1.3.0.dist-info → duty-1.4.0.dist-info}/METADATA +2 -1
- duty-1.4.0.dist-info/RECORD +53 -0
- {duty-1.3.0.dist-info → duty-1.4.0.dist-info}/WHEEL +1 -1
- duty-1.3.0.dist-info/RECORD +0 -30
- {duty-1.3.0.dist-info → duty-1.4.0.dist-info}/entry_points.txt +0 -0
- {duty-1.3.0.dist-info → duty-1.4.0.dist-info}/licenses/LICENSE +0 -0
duty/callables/__init__.py
CHANGED
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
"""Module containing callables for many tools.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
If you are the author or maintainer of one of the tools we support
|
|
5
|
-
(or more generally if you are the author/maintainer of a Python CLI/library),
|
|
6
|
-
we kindly request that you add such a callable to your code base. Why?
|
|
7
|
-
|
|
8
|
-
- Most of the time, all `duty` can do is hook into the CLI entrypoint
|
|
9
|
-
for the lack of a better alternative. This is not ideal because
|
|
10
|
-
we have to translate function arguments to CLI arguments,
|
|
11
|
-
that are then parsed again and translated back to Python objects
|
|
12
|
-
by the tool itself. This is not efficient.
|
|
13
|
-
- It is not feasible for `duty` to maintain callables for different versions
|
|
14
|
-
of these tools. Having the callables maintained in the tools
|
|
15
|
-
themselves would make this support transparent.
|
|
16
|
-
- We believe it simply provides a better user- *and* developer-experience.
|
|
17
|
-
Clear separation of concerns: don't intertwine logic into the CLI parser.
|
|
18
|
-
Easy to maintain, easy to test. The CLI parser just has to translate CLI args
|
|
19
|
-
to their equivalent Python arguments.
|
|
20
|
-
|
|
21
|
-
Tips for writing such a library entry point:
|
|
22
|
-
|
|
23
|
-
- Make it equivalent to the CLI entry point: every flag and option must have an equivalent parameter.
|
|
24
|
-
Slight customizations can be made to support `--flag` / `--no-flag` with single parameters.
|
|
25
|
-
- Use only built-in types: don't make users import and use objects from your API.
|
|
26
|
-
For example, accept a list of strings, not a list of `MyCustomClass` instances.
|
|
3
|
+
These callables are **deprecated** in favor of our new [tools][duty.tools].
|
|
27
4
|
"""
|
|
28
5
|
|
|
29
6
|
from __future__ import annotations
|
|
30
7
|
|
|
8
|
+
import warnings
|
|
9
|
+
|
|
31
10
|
from failprint.lazy import lazy
|
|
32
11
|
|
|
12
|
+
from duty.callables import (
|
|
13
|
+
autoflake, # noqa: F401
|
|
14
|
+
black, # noqa: F401
|
|
15
|
+
blacken_docs, # noqa: F401
|
|
16
|
+
build, # noqa: F401
|
|
17
|
+
coverage, # noqa: F401
|
|
18
|
+
flake8, # noqa: F401
|
|
19
|
+
git_changelog, # noqa: F401
|
|
20
|
+
griffe, # noqa: F401
|
|
21
|
+
interrogate, # noqa: F401
|
|
22
|
+
isort, # noqa: F401
|
|
23
|
+
mkdocs, # noqa: F401
|
|
24
|
+
mypy, # noqa: F401
|
|
25
|
+
pytest, # noqa: F401
|
|
26
|
+
ruff, # noqa: F401
|
|
27
|
+
safety, # noqa: F401
|
|
28
|
+
ssort, # noqa: F401
|
|
29
|
+
twine, # noqa: F401
|
|
30
|
+
)
|
|
31
|
+
|
|
33
32
|
__all__ = ["lazy"]
|
|
33
|
+
|
|
34
|
+
warnings.warn(
|
|
35
|
+
"Callables are deprecated in favor of our new `duty.tools`. "
|
|
36
|
+
"They are easier to use and provide more functionality "
|
|
37
|
+
"like automatically computing `command` values in `ctx.run()` calls. "
|
|
38
|
+
"Old callables will be removed in a future version.",
|
|
39
|
+
DeprecationWarning,
|
|
40
|
+
stacklevel=1,
|
|
41
|
+
)
|
duty/callables/build.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Callable for [build](https://github.com/pypa/build)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
from failprint.lazy import lazy
|
|
8
|
+
|
|
9
|
+
|
|
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)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""Callable for [git-changelog](https://github.com/pawamoy/git-changelog)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
from failprint.lazy import lazy
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@lazy(name="git_changelog")
|
|
11
|
+
def run(
|
|
12
|
+
repository: str | None = None,
|
|
13
|
+
*,
|
|
14
|
+
config_file: str | None = None,
|
|
15
|
+
bump: str | None = None,
|
|
16
|
+
versioning: Literal["semver", "pep440"] | None = None,
|
|
17
|
+
in_place: bool = False,
|
|
18
|
+
version_regex: str | None = None,
|
|
19
|
+
marker_line: str | None = None,
|
|
20
|
+
output: str | None = None,
|
|
21
|
+
provider: Literal["github", "gitlab", "bitbucket"] | None = None,
|
|
22
|
+
parse_refs: bool = False,
|
|
23
|
+
release_notes: bool = False,
|
|
24
|
+
input: str | None = None, # noqa: A002
|
|
25
|
+
convention: Literal["basic", "angular", "conventional"] | None = None,
|
|
26
|
+
sections: list[str] | None = None,
|
|
27
|
+
template: str | None = None,
|
|
28
|
+
git_trailers: bool = False,
|
|
29
|
+
omit_empty_versions: bool = False,
|
|
30
|
+
no_zerover: bool = False,
|
|
31
|
+
filter_commits: str | None = None,
|
|
32
|
+
jinja_context: list[str] | None = None,
|
|
33
|
+
version: bool = False,
|
|
34
|
+
debug_info: bool = False,
|
|
35
|
+
) -> None:
|
|
36
|
+
r"""Run `git-changelog`.
|
|
37
|
+
|
|
38
|
+
Parameters:
|
|
39
|
+
repository: The repository path, relative or absolute. Default: current working directory.
|
|
40
|
+
config_file: Configuration file(s).
|
|
41
|
+
bump: Specify the bump from latest version for the set of unreleased commits.
|
|
42
|
+
Can be one of `auto`, `major`, `minor`, `patch` or a valid SemVer version (eg. 1.2.3).
|
|
43
|
+
For both SemVer and PEP 440 versioning schemes (see -n), `auto` will bump the major number
|
|
44
|
+
if a commit contains breaking changes (or the minor number for 0.x versions, see -Z),
|
|
45
|
+
else the minor number if there are new features, else the patch number. Default: unset (false).
|
|
46
|
+
versioning: Versioning scheme to use when bumping and comparing versions.
|
|
47
|
+
The selected scheme will impact the values accepted by the `--bump` option.
|
|
48
|
+
Supported: `pep440`, `semver`.
|
|
49
|
+
|
|
50
|
+
PEP 440 provides the following bump strategies: `auto`, `epoch`, `release`, `major`, `minor`, `micro`, `patch`,
|
|
51
|
+
`pre`, `alpha`, `beta`, `candidate`, `post`, `dev`.
|
|
52
|
+
Values `auto`, `major`, `minor`, `micro` can be suffixed with one of `+alpha`, `+beta`, `+candidate`, and/or `+dev`.
|
|
53
|
+
Values `alpha`, `beta` and `candidate` can be suffixed with `+dev`.
|
|
54
|
+
Examples: `auto+alpha`, `major+beta+dev`, `micro+dev`, `candidate+dev`, etc..
|
|
55
|
+
|
|
56
|
+
SemVer provides the following bump strategies: `auto`, `major`, `minor`, `patch`, `release`.
|
|
57
|
+
See the docs for more information. Default: unset (`semver`).
|
|
58
|
+
in_place: Insert new entries (versions missing from changelog) in-place.
|
|
59
|
+
An output file must be specified. With custom templates, you can pass two additional
|
|
60
|
+
arguments: `--version-regex` and `--marker-line`.
|
|
61
|
+
When writing in-place, an `in_place` variable will be injected in the Jinja context,
|
|
62
|
+
allowing to adapt the generated contents (for example to skip changelog headers or footers).
|
|
63
|
+
Default: unset (false).
|
|
64
|
+
version_regex: A regular expression to match versions in the existing changelog
|
|
65
|
+
(used to find the latest release) when writing in-place.
|
|
66
|
+
The regular expression must be a Python regex with a `version` named group.
|
|
67
|
+
Default: `^## \[(?P<version>v?[^\]]+)`.
|
|
68
|
+
marker_line: A marker line at which to insert new entries (versions missing from changelog).
|
|
69
|
+
If two marker lines are present in the changelog, the contents between those two lines
|
|
70
|
+
will be overwritten (useful to update an 'Unreleased' entry for example). Default: `<!-- insertion marker -->`.
|
|
71
|
+
output: Output to given file. Default: standard output.
|
|
72
|
+
provider: Explicitly specify the repository provider. Default: unset.
|
|
73
|
+
parse_refs: Parse provider-specific references in commit messages (GitHub/GitLab/Bitbucket issues, PRs, etc.).
|
|
74
|
+
Default: unset (false).
|
|
75
|
+
release_notes: Output release notes to stdout based on the last entry in the changelog. Default: unset (false).
|
|
76
|
+
input: Read from given file when creating release notes. Default: `CHANGELOG.md`.
|
|
77
|
+
convention: The commit convention to match against. Default: `basic`.
|
|
78
|
+
sections: A comma-separated list of sections to render.
|
|
79
|
+
See the available sections for each supported convention in the description. Default: unset (None).
|
|
80
|
+
template: The Jinja2 template to use.
|
|
81
|
+
Prefix it with `path:` to specify the path to a Jinja templated file. Default: `keepachangelog`.
|
|
82
|
+
git_trailers: Parse Git trailers in the commit message.
|
|
83
|
+
See https://git-scm.com/docs/git-interpret-trailers. Default: unset (false).
|
|
84
|
+
omit_empty_versions: Omit empty versions from the output. Default: unset (false).
|
|
85
|
+
no_zerover: By default, breaking changes on a 0.x don't bump the major version, maintaining it at 0.
|
|
86
|
+
With this option, a breaking change will bump a 0.x version to 1.0.
|
|
87
|
+
filter_commits: The Git revision-range filter to use (e.g. `v1.2.0..`). Default: no filter.
|
|
88
|
+
jinja_context: Pass additional key/value pairs to the template.
|
|
89
|
+
Option can be used multiple times.
|
|
90
|
+
The key/value pairs are accessible as 'jinja_context' in the template.
|
|
91
|
+
version: Show the current version of the program and exit.
|
|
92
|
+
debug_info: Print debug information.
|
|
93
|
+
"""
|
|
94
|
+
from git_changelog.cli import main as git_changelog
|
|
95
|
+
|
|
96
|
+
cli_args = []
|
|
97
|
+
|
|
98
|
+
if repository:
|
|
99
|
+
cli_args.append(repository)
|
|
100
|
+
|
|
101
|
+
if config_file:
|
|
102
|
+
cli_args.append("--config-file")
|
|
103
|
+
cli_args.append(config_file)
|
|
104
|
+
|
|
105
|
+
if bump:
|
|
106
|
+
cli_args.append("--bump")
|
|
107
|
+
cli_args.append(bump)
|
|
108
|
+
|
|
109
|
+
if versioning:
|
|
110
|
+
cli_args.append("--versioning")
|
|
111
|
+
cli_args.append(versioning)
|
|
112
|
+
|
|
113
|
+
if in_place:
|
|
114
|
+
cli_args.append("--in-place")
|
|
115
|
+
|
|
116
|
+
if version_regex:
|
|
117
|
+
cli_args.append("--version-regex")
|
|
118
|
+
cli_args.append(version_regex)
|
|
119
|
+
|
|
120
|
+
if marker_line:
|
|
121
|
+
cli_args.append("--marker-line")
|
|
122
|
+
cli_args.append(marker_line)
|
|
123
|
+
|
|
124
|
+
if output:
|
|
125
|
+
cli_args.append("--output")
|
|
126
|
+
cli_args.append(output)
|
|
127
|
+
|
|
128
|
+
if provider:
|
|
129
|
+
cli_args.append("--provider")
|
|
130
|
+
cli_args.append(provider)
|
|
131
|
+
|
|
132
|
+
if parse_refs:
|
|
133
|
+
cli_args.append("--parse-refs")
|
|
134
|
+
|
|
135
|
+
if release_notes:
|
|
136
|
+
cli_args.append("--release-notes")
|
|
137
|
+
|
|
138
|
+
if input:
|
|
139
|
+
cli_args.append("--input")
|
|
140
|
+
cli_args.append(input)
|
|
141
|
+
|
|
142
|
+
if convention:
|
|
143
|
+
cli_args.append("--convention")
|
|
144
|
+
cli_args.append(convention)
|
|
145
|
+
|
|
146
|
+
if sections:
|
|
147
|
+
cli_args.append("--sections")
|
|
148
|
+
cli_args.append(",".join(sections))
|
|
149
|
+
|
|
150
|
+
if template:
|
|
151
|
+
cli_args.append("--template")
|
|
152
|
+
cli_args.append(template)
|
|
153
|
+
|
|
154
|
+
if git_trailers:
|
|
155
|
+
cli_args.append("--git-trailers")
|
|
156
|
+
|
|
157
|
+
if omit_empty_versions:
|
|
158
|
+
cli_args.append("--omit-empty-versions")
|
|
159
|
+
|
|
160
|
+
if no_zerover:
|
|
161
|
+
cli_args.append("--no-zerover")
|
|
162
|
+
|
|
163
|
+
if filter_commits:
|
|
164
|
+
cli_args.append("--filter-commits")
|
|
165
|
+
cli_args.append(filter_commits)
|
|
166
|
+
|
|
167
|
+
if jinja_context:
|
|
168
|
+
for key_value in jinja_context:
|
|
169
|
+
cli_args.append("--jinja-context")
|
|
170
|
+
cli_args.append(key_value)
|
|
171
|
+
|
|
172
|
+
if version:
|
|
173
|
+
cli_args.append("--version")
|
|
174
|
+
|
|
175
|
+
if debug_info:
|
|
176
|
+
cli_args.append("--debug-info")
|
|
177
|
+
|
|
178
|
+
git_changelog(cli_args)
|
duty/callables/griffe.py
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"""Callable for [Griffe](https://github.com/mkdocstrings/griffe)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
from failprint.lazy import lazy
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def run(*args: str, version: bool = False, debug_info: bool = False) -> None:
|
|
11
|
+
"""Run `griffe`.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
*args: CLI arguments.
|
|
15
|
+
version: Show program's version number and exit.
|
|
16
|
+
debug_info: Print debug information.
|
|
17
|
+
"""
|
|
18
|
+
from griffe.cli import main as griffe
|
|
19
|
+
|
|
20
|
+
cli_args = []
|
|
21
|
+
|
|
22
|
+
# --version and --debug-info must appear first.
|
|
23
|
+
if version:
|
|
24
|
+
cli_args.append("--version")
|
|
25
|
+
|
|
26
|
+
if debug_info:
|
|
27
|
+
cli_args.append("--debug-info")
|
|
28
|
+
|
|
29
|
+
cli_args.extend(args)
|
|
30
|
+
|
|
31
|
+
griffe(cli_args)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@lazy(name="griffe.check")
|
|
35
|
+
def check(
|
|
36
|
+
package: str,
|
|
37
|
+
*,
|
|
38
|
+
against: str | None = None,
|
|
39
|
+
base_ref: str | None = None,
|
|
40
|
+
color: bool = False,
|
|
41
|
+
verbose: bool = False,
|
|
42
|
+
format: Literal["oneline", "verbose", "markdown", "github"] | None = None, # noqa: A002
|
|
43
|
+
search: list[str] | None = None,
|
|
44
|
+
sys_path: bool = False,
|
|
45
|
+
find_stubs_packages: bool = False,
|
|
46
|
+
extensions: str | list[str] | None = None,
|
|
47
|
+
inspection: bool | None = None,
|
|
48
|
+
log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] | None = None,
|
|
49
|
+
version: bool = False,
|
|
50
|
+
debug_info: bool = False,
|
|
51
|
+
) -> None:
|
|
52
|
+
"""Check for API breakages or possible improvements.
|
|
53
|
+
|
|
54
|
+
Parameters:
|
|
55
|
+
package: Package to find, load and check, as path.
|
|
56
|
+
against: Older Git reference (commit, branch, tag) to check against. Default: load latest tag.
|
|
57
|
+
base_ref: Git reference (commit, branch, tag) to check. Default: load current code.
|
|
58
|
+
color: Force enable/disable colors in the output.
|
|
59
|
+
verbose: Verbose output.
|
|
60
|
+
format: Output format.
|
|
61
|
+
search: Paths to search packages into.
|
|
62
|
+
sys_path: Whether to append `sys.path` to search paths specified with `-s`.
|
|
63
|
+
find_stubs_packages: Whether to look for stubs-only packages and merge them with concrete ones.
|
|
64
|
+
extensions: A comma-separated list or a JSON list of extensions to load.
|
|
65
|
+
inspection: Whether to disallow or force inspection (dynamic analysis).
|
|
66
|
+
By default, Griffe tries to use static analysis and falls back to dynamic analysis when it can't.
|
|
67
|
+
log_level: Set the log level: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`.
|
|
68
|
+
version: Show program's version number and exit.
|
|
69
|
+
debug_info: Print debug information.
|
|
70
|
+
"""
|
|
71
|
+
cli_args = []
|
|
72
|
+
|
|
73
|
+
if package:
|
|
74
|
+
cli_args.append(package)
|
|
75
|
+
|
|
76
|
+
if against:
|
|
77
|
+
cli_args.append("--against")
|
|
78
|
+
cli_args.append(against)
|
|
79
|
+
|
|
80
|
+
if base_ref:
|
|
81
|
+
cli_args.append("--base-ref")
|
|
82
|
+
cli_args.append(base_ref)
|
|
83
|
+
|
|
84
|
+
if color is True:
|
|
85
|
+
cli_args.append("--color")
|
|
86
|
+
elif color is False:
|
|
87
|
+
cli_args.append("--no-color")
|
|
88
|
+
|
|
89
|
+
if verbose:
|
|
90
|
+
cli_args.append("--verbose")
|
|
91
|
+
|
|
92
|
+
if format:
|
|
93
|
+
cli_args.append("--format")
|
|
94
|
+
cli_args.append(format)
|
|
95
|
+
|
|
96
|
+
if search:
|
|
97
|
+
for path in search:
|
|
98
|
+
cli_args.append("--search")
|
|
99
|
+
cli_args.append(path)
|
|
100
|
+
|
|
101
|
+
if sys_path:
|
|
102
|
+
cli_args.append("--sys-path")
|
|
103
|
+
|
|
104
|
+
if find_stubs_packages:
|
|
105
|
+
cli_args.append("--find-stubs-packages")
|
|
106
|
+
|
|
107
|
+
if extensions:
|
|
108
|
+
cli_args.append("--extensions")
|
|
109
|
+
if isinstance(extensions, str):
|
|
110
|
+
cli_args.append(extensions)
|
|
111
|
+
else:
|
|
112
|
+
cli_args.append(",".join(extensions))
|
|
113
|
+
|
|
114
|
+
if inspection is True:
|
|
115
|
+
cli_args.append("--force-inspection")
|
|
116
|
+
elif inspection is False:
|
|
117
|
+
cli_args.append("--no-inspection")
|
|
118
|
+
|
|
119
|
+
if log_level:
|
|
120
|
+
cli_args.append("--log-level")
|
|
121
|
+
cli_args.append(log_level)
|
|
122
|
+
|
|
123
|
+
run("check", *cli_args, version=version, debug_info=debug_info)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@lazy(name="griffe.dump")
|
|
127
|
+
def dump(
|
|
128
|
+
*packages: str,
|
|
129
|
+
full: bool = False,
|
|
130
|
+
output: str | None = None,
|
|
131
|
+
docstyle: str | None = None,
|
|
132
|
+
docopts: str | None = None,
|
|
133
|
+
resolve_aliases: bool = False,
|
|
134
|
+
resolve_implicit: bool = False,
|
|
135
|
+
resolve_external: bool | None = None,
|
|
136
|
+
stats: bool = False,
|
|
137
|
+
search: list[str] | None = None,
|
|
138
|
+
sys_path: bool = False,
|
|
139
|
+
find_stubs_packages: bool = False,
|
|
140
|
+
extensions: str | list[str] | None = None,
|
|
141
|
+
inspection: bool | None = None,
|
|
142
|
+
log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] | None = None,
|
|
143
|
+
version: bool = False,
|
|
144
|
+
debug_info: bool = False,
|
|
145
|
+
) -> None:
|
|
146
|
+
"""Load package-signatures and dump them as JSON.
|
|
147
|
+
|
|
148
|
+
Parameters:
|
|
149
|
+
packages: Packages to find, load and dump.
|
|
150
|
+
full: Whether to dump full data in JSON.
|
|
151
|
+
output: Output file. Supports templating to output each package in its own file, with `{package}`.
|
|
152
|
+
docstyle: The docstring style to parse.
|
|
153
|
+
docopts: The options for the docstring parser.
|
|
154
|
+
resolve_aliases: Whether to resolve aliases.
|
|
155
|
+
resolve_implicit: Whether to resolve implicitely exported aliases as well. Aliases are explicitely exported when defined in `__all__`.
|
|
156
|
+
resolve_external: Whether to resolve aliases pointing to external/unknown modules (not loaded directly).
|
|
157
|
+
Default is to resolve only from one module to its private sibling (`ast` -> `_ast`).
|
|
158
|
+
stats: Show statistics at the end.
|
|
159
|
+
search: Paths to search packages into.
|
|
160
|
+
sys_path: Whether to append `sys.path` to search paths specified with `-s`.
|
|
161
|
+
find_stubs_packages: Whether to look for stubs-only packages and merge them with concrete ones.
|
|
162
|
+
extensions: A comma-separated list or a JSON list of extensions to load.
|
|
163
|
+
inspection: Whether to disallow or force inspection (dynamic analysis).
|
|
164
|
+
By default, Griffe tries to use static analysis and falls back to dynamic analysis when it can't.
|
|
165
|
+
log_level: Set the log level: `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`.
|
|
166
|
+
version: Show program's version number and exit.
|
|
167
|
+
debug_info: Print debug information.
|
|
168
|
+
"""
|
|
169
|
+
cli_args = list(packages)
|
|
170
|
+
|
|
171
|
+
if full:
|
|
172
|
+
cli_args.append("--full")
|
|
173
|
+
|
|
174
|
+
if output:
|
|
175
|
+
cli_args.append("--output")
|
|
176
|
+
cli_args.append(output)
|
|
177
|
+
|
|
178
|
+
if docstyle:
|
|
179
|
+
cli_args.append("--docstyle")
|
|
180
|
+
cli_args.append(docstyle)
|
|
181
|
+
|
|
182
|
+
if docopts:
|
|
183
|
+
cli_args.append("--docopts")
|
|
184
|
+
cli_args.append(docopts)
|
|
185
|
+
|
|
186
|
+
if resolve_aliases:
|
|
187
|
+
cli_args.append("--resolve-aliases")
|
|
188
|
+
|
|
189
|
+
if resolve_implicit:
|
|
190
|
+
cli_args.append("--resolve-implicit")
|
|
191
|
+
|
|
192
|
+
if resolve_external is True:
|
|
193
|
+
cli_args.append("--resolve-external")
|
|
194
|
+
elif resolve_external is False:
|
|
195
|
+
cli_args.append("--no-resolve-external")
|
|
196
|
+
|
|
197
|
+
if stats:
|
|
198
|
+
cli_args.append("--stats")
|
|
199
|
+
|
|
200
|
+
if search:
|
|
201
|
+
for path in search:
|
|
202
|
+
cli_args.append("--search")
|
|
203
|
+
cli_args.append(path)
|
|
204
|
+
|
|
205
|
+
if sys_path:
|
|
206
|
+
cli_args.append("--sys-path")
|
|
207
|
+
|
|
208
|
+
if find_stubs_packages:
|
|
209
|
+
cli_args.append("--find-stubs-packages")
|
|
210
|
+
|
|
211
|
+
if extensions:
|
|
212
|
+
cli_args.append("--extensions")
|
|
213
|
+
if isinstance(extensions, str):
|
|
214
|
+
cli_args.append(extensions)
|
|
215
|
+
else:
|
|
216
|
+
cli_args.append(",".join(extensions))
|
|
217
|
+
|
|
218
|
+
if inspection is True:
|
|
219
|
+
cli_args.append("--force-inspection")
|
|
220
|
+
elif inspection is False:
|
|
221
|
+
cli_args.append("--no-inspection")
|
|
222
|
+
|
|
223
|
+
if log_level:
|
|
224
|
+
cli_args.append("--log-level")
|
|
225
|
+
cli_args.append(log_level)
|
|
226
|
+
|
|
227
|
+
run("check", *cli_args, version=version, debug_info=debug_info)
|