invoke-tasklib 0.0.7__tar.gz → 0.1.0__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.
Files changed (122) hide show
  1. {invoke_tasklib-0.0.7 → invoke_tasklib-0.1.0}/.gitignore +2 -0
  2. invoke_tasklib-0.1.0/PKG-INFO +337 -0
  3. invoke_tasklib-0.1.0/README.md +309 -0
  4. invoke_tasklib-0.1.0/invoke_tasklib/__init__.py +248 -0
  5. invoke_tasklib-0.1.0/invoke_tasklib/_coverage.py +147 -0
  6. invoke_tasklib-0.1.0/invoke_tasklib/_discover.py +270 -0
  7. invoke_tasklib-0.1.0/invoke_tasklib/_files.py +225 -0
  8. invoke_tasklib-0.1.0/invoke_tasklib/_graph.py +499 -0
  9. invoke_tasklib-0.1.0/invoke_tasklib/_pyproject.py +75 -0
  10. invoke_tasklib-0.1.0/invoke_tasklib/_steps.py +388 -0
  11. invoke_tasklib-0.1.0/invoke_tasklib/check.py +165 -0
  12. invoke_tasklib-0.1.0/invoke_tasklib/clean.py +446 -0
  13. invoke_tasklib-0.1.0/invoke_tasklib/config/__init__.py +50 -0
  14. invoke_tasklib-0.1.0/invoke_tasklib/config/__main__.py +44 -0
  15. invoke_tasklib-0.1.0/invoke_tasklib/config/_constants.py +27 -0
  16. invoke_tasklib-0.1.0/invoke_tasklib/config/_derive.py +80 -0
  17. invoke_tasklib-0.1.0/invoke_tasklib/config/_invoke.py +160 -0
  18. invoke_tasklib-0.1.0/invoke_tasklib/config/_resolve.py +181 -0
  19. invoke_tasklib-0.1.0/invoke_tasklib/config/_schema.py +439 -0
  20. invoke_tasklib-0.1.0/invoke_tasklib/config/_validate.py +579 -0
  21. invoke_tasklib-0.1.0/invoke_tasklib/doc.py +405 -0
  22. invoke_tasklib-0.1.0/invoke_tasklib/env.py +273 -0
  23. invoke_tasklib-0.1.0/invoke_tasklib/fix.py +91 -0
  24. invoke_tasklib-0.1.0/invoke_tasklib/formatting.py +241 -0
  25. invoke_tasklib-0.1.0/invoke_tasklib/imports.py +126 -0
  26. invoke_tasklib-0.1.0/invoke_tasklib/lint.py +116 -0
  27. invoke_tasklib-0.1.0/invoke_tasklib/output.py +251 -0
  28. invoke_tasklib-0.1.0/invoke_tasklib/release.py +452 -0
  29. invoke_tasklib-0.1.0/invoke_tasklib/runner.py +324 -0
  30. invoke_tasklib-0.1.0/invoke_tasklib/security.py +64 -0
  31. invoke_tasklib-0.1.0/invoke_tasklib/show.py +182 -0
  32. invoke_tasklib-0.1.0/invoke_tasklib/testing.py +449 -0
  33. invoke_tasklib-0.1.0/invoke_tasklib/tools.py +404 -0
  34. invoke_tasklib-0.1.0/invoke_tasklib/typecheck.py +76 -0
  35. invoke_tasklib-0.1.0/pyproject.toml +353 -0
  36. invoke_tasklib-0.1.0/tests/__init__.py +0 -0
  37. invoke_tasklib-0.1.0/tests/benchmarks/__init__.py +0 -0
  38. invoke_tasklib-0.1.0/tests/benchmarks/test_config_benchmark.py +41 -0
  39. invoke_tasklib-0.1.0/tests/benchmarks/test_files_benchmark.py +30 -0
  40. invoke_tasklib-0.1.0/tests/benchmarks/test_graph_benchmark.py +51 -0
  41. invoke_tasklib-0.1.0/tests/benchmarks/test_init_benchmark.py +24 -0
  42. invoke_tasklib-0.1.0/tests/benchmarks/test_runner_benchmark.py +17 -0
  43. invoke_tasklib-0.1.0/tests/helpers.py +110 -0
  44. invoke_tasklib-0.1.0/tests/integration/__init__.py +0 -0
  45. invoke_tasklib-0.1.0/tests/integration/helpers.py +48 -0
  46. invoke_tasklib-0.1.0/tests/integration/test_check.py +81 -0
  47. invoke_tasklib-0.1.0/tests/integration/test_clean.py +86 -0
  48. invoke_tasklib-0.1.0/tests/integration/test_doc.py +144 -0
  49. invoke_tasklib-0.1.0/tests/integration/test_docs.py +151 -0
  50. invoke_tasklib-0.1.0/tests/integration/test_doctest.py +17 -0
  51. invoke_tasklib-0.1.0/tests/integration/test_env_config.py +176 -0
  52. invoke_tasklib-0.1.0/tests/integration/test_env_install.py +57 -0
  53. invoke_tasklib-0.1.0/tests/integration/test_env_python.py +42 -0
  54. invoke_tasklib-0.1.0/tests/integration/test_env_tools.py +85 -0
  55. invoke_tasklib-0.1.0/tests/integration/test_exit_codes.py +88 -0
  56. invoke_tasklib-0.1.0/tests/integration/test_files.py +132 -0
  57. invoke_tasklib-0.1.0/tests/integration/test_fix_converges.py +66 -0
  58. invoke_tasklib-0.1.0/tests/integration/test_formatting.py +86 -0
  59. invoke_tasklib-0.1.0/tests/integration/test_imports.py +271 -0
  60. invoke_tasklib-0.1.0/tests/integration/test_output.py +35 -0
  61. invoke_tasklib-0.1.0/tests/integration/test_project.py +204 -0
  62. invoke_tasklib-0.1.0/tests/integration/test_quoting.py +21 -0
  63. invoke_tasklib-0.1.0/tests/integration/test_read_only.py +74 -0
  64. invoke_tasklib-0.1.0/tests/integration/test_readme.py +28 -0
  65. invoke_tasklib-0.1.0/tests/integration/test_release.py +169 -0
  66. invoke_tasklib-0.1.0/tests/integration/test_runner.py +67 -0
  67. invoke_tasklib-0.1.0/tests/integration/test_security.py +49 -0
  68. invoke_tasklib-0.1.0/tests/integration/test_testing.py +158 -0
  69. invoke_tasklib-0.1.0/tests/unit/__init__.py +0 -0
  70. invoke_tasklib-0.1.0/tests/unit/config/__init__.py +0 -0
  71. invoke_tasklib-0.1.0/tests/unit/config/conftest.py +15 -0
  72. invoke_tasklib-0.1.0/tests/unit/config/test___main__.py +60 -0
  73. invoke_tasklib-0.1.0/tests/unit/config/test__derive.py +134 -0
  74. invoke_tasklib-0.1.0/tests/unit/config/test__invoke.py +135 -0
  75. invoke_tasklib-0.1.0/tests/unit/config/test__resolve.py +699 -0
  76. invoke_tasklib-0.1.0/tests/unit/config/test__schema.py +309 -0
  77. invoke_tasklib-0.1.0/tests/unit/config/test__validate.py +591 -0
  78. invoke_tasklib-0.1.0/tests/unit/conftest.py +36 -0
  79. invoke_tasklib-0.1.0/tests/unit/test__coverage.py +151 -0
  80. invoke_tasklib-0.1.0/tests/unit/test__discover.py +276 -0
  81. invoke_tasklib-0.1.0/tests/unit/test__files.py +352 -0
  82. invoke_tasklib-0.1.0/tests/unit/test__graph.py +908 -0
  83. invoke_tasklib-0.1.0/tests/unit/test__pyproject.py +79 -0
  84. invoke_tasklib-0.1.0/tests/unit/test__steps.py +708 -0
  85. invoke_tasklib-0.1.0/tests/unit/test_architecture.py +330 -0
  86. invoke_tasklib-0.1.0/tests/unit/test_check.py +512 -0
  87. invoke_tasklib-0.1.0/tests/unit/test_clean.py +1019 -0
  88. invoke_tasklib-0.1.0/tests/unit/test_doc.py +582 -0
  89. invoke_tasklib-0.1.0/tests/unit/test_docstrings.py +107 -0
  90. invoke_tasklib-0.1.0/tests/unit/test_env.py +681 -0
  91. invoke_tasklib-0.1.0/tests/unit/test_fix.py +145 -0
  92. invoke_tasklib-0.1.0/tests/unit/test_formatting.py +357 -0
  93. invoke_tasklib-0.1.0/tests/unit/test_helpers.py +62 -0
  94. invoke_tasklib-0.1.0/tests/unit/test_imports.py +315 -0
  95. invoke_tasklib-0.1.0/tests/unit/test_init.py +461 -0
  96. invoke_tasklib-0.1.0/tests/unit/test_lint.py +126 -0
  97. invoke_tasklib-0.1.0/tests/unit/test_output.py +372 -0
  98. invoke_tasklib-0.1.0/tests/unit/test_program_hints.py +66 -0
  99. invoke_tasklib-0.1.0/tests/unit/test_release.py +809 -0
  100. invoke_tasklib-0.1.0/tests/unit/test_runner.py +519 -0
  101. invoke_tasklib-0.1.0/tests/unit/test_security.py +54 -0
  102. invoke_tasklib-0.1.0/tests/unit/test_show.py +238 -0
  103. invoke_tasklib-0.1.0/tests/unit/test_testing.py +853 -0
  104. invoke_tasklib-0.1.0/tests/unit/test_tools.py +671 -0
  105. invoke_tasklib-0.1.0/tests/unit/test_typecheck.py +112 -0
  106. invoke_tasklib-0.0.7/PKG-INFO +0 -247
  107. invoke_tasklib-0.0.7/README.md +0 -219
  108. invoke_tasklib-0.0.7/invoke_tasklib/__init__.py +0 -63
  109. invoke_tasklib-0.0.7/invoke_tasklib/clean.py +0 -55
  110. invoke_tasklib-0.0.7/invoke_tasklib/config.py +0 -124
  111. invoke_tasklib-0.0.7/invoke_tasklib/doc.py +0 -59
  112. invoke_tasklib-0.0.7/invoke_tasklib/env.py +0 -103
  113. invoke_tasklib-0.0.7/invoke_tasklib/format.py +0 -89
  114. invoke_tasklib-0.0.7/invoke_tasklib/imports.py +0 -47
  115. invoke_tasklib-0.0.7/invoke_tasklib/lint.py +0 -34
  116. invoke_tasklib-0.0.7/invoke_tasklib/release.py +0 -47
  117. invoke_tasklib-0.0.7/invoke_tasklib/security.py +0 -22
  118. invoke_tasklib-0.0.7/invoke_tasklib/test.py +0 -169
  119. invoke_tasklib-0.0.7/invoke_tasklib/types.py +0 -25
  120. invoke_tasklib-0.0.7/pyproject.toml +0 -279
  121. {invoke_tasklib-0.0.7 → invoke_tasklib-0.1.0}/LICENSE +0 -0
  122. {invoke_tasklib-0.0.7 → invoke_tasklib-0.1.0}/invoke_tasklib/py.typed +0 -0
@@ -47,6 +47,7 @@ nosetests.xml
47
47
  coverage.xml
48
48
  *.cover
49
49
  *.py.cover
50
+ .benchmarks/
50
51
  .hypothesis/
51
52
  .pytest_cache/
52
53
  cover/
@@ -166,6 +167,7 @@ venv.bak/
166
167
 
167
168
  # mkdocs documentation
168
169
  /site
170
+ /docs/site
169
171
 
170
172
  # mypy
171
173
  .mypy_cache/
@@ -0,0 +1,337 @@
1
+ Metadata-Version: 2.5
2
+ Name: invoke-tasklib
3
+ Version: 0.1.0
4
+ Summary: Reusable Invoke tasks shared across Python projects.
5
+ Project-URL: Homepage, https://github.com/durandtibo/invoke-tasklib
6
+ Project-URL: Repository, https://github.com/durandtibo/invoke-tasklib
7
+ Project-URL: Documentation, https://durandtibo.github.io/invoke-tasklib/
8
+ Project-URL: Changelog, https://github.com/durandtibo/invoke-tasklib/releases
9
+ Project-URL: Issues, https://github.com/durandtibo/invoke-tasklib/issues
10
+ Author-email: Thibaut Durand <durand.tibo+gh@gmail.com>
11
+ License-Expression: BSD-3-Clause
12
+ License-File: LICENSE
13
+ Keywords: automation,devtools,invoke,tasks
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: 3.15
23
+ Classifier: Topic :: Software Development :: Build Tools
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: invoke<4.0,>=3.0
27
+ Description-Content-Type: text/markdown
28
+
29
+ # invoke-tasklib
30
+
31
+ <p align="center">
32
+ <a href="https://github.com/durandtibo/invoke-tasklib/actions/workflows/ci.yaml"><img
33
+ alt="CI"
34
+ src="https://img.shields.io/github/actions/workflow/status/durandtibo/invoke-tasklib/ci.yaml?branch=main&label=CI&logo=github"></a>
35
+ <a href="https://github.com/durandtibo/invoke-tasklib/actions/workflows/nightly-package.yaml"><img
36
+ alt="Nightly Package Tests"
37
+ src="https://img.shields.io/github/actions/workflow/status/durandtibo/invoke-tasklib/nightly-package.yaml?label=nightly&logo=github"></a>
38
+ <a href="https://codecov.io/gh/durandtibo/invoke-tasklib"><img
39
+ alt="Codecov"
40
+ src="https://img.shields.io/codecov/c/github/durandtibo/invoke-tasklib?logo=codecov"></a>
41
+ <a href="https://durandtibo.github.io/invoke-tasklib/"><img
42
+ alt="Documentation (stable)"
43
+ src="https://img.shields.io/badge/docs-stable-blue?logo=readthedocs&logoColor=white"></a>
44
+ <br/>
45
+ <a href="https://pypi.org/project/invoke-tasklib/"><img
46
+ alt="PyPI version"
47
+ src="https://img.shields.io/pypi/v/invoke-tasklib?logo=pypi&logoColor=white"></a>
48
+ <a href="https://pypi.org/project/invoke-tasklib/"><img
49
+ alt="Python"
50
+ src="https://img.shields.io/pypi/pyversions/invoke-tasklib?logo=python&logoColor=white"></a>
51
+ <a href="https://opensource.org/licenses/BSD-3-Clause"><img
52
+ alt="BSD-3-Clause"
53
+ src="https://img.shields.io/pypi/l/invoke-tasklib"></a>
54
+ <br/>
55
+ <a href="https://github.com/astral-sh/ruff"><img
56
+ alt="Ruff"
57
+ src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
58
+ <a href="https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings"><img
59
+ alt="Doc style: google"
60
+ src="https://img.shields.io/badge/docstyle-google-3666d6"></a>
61
+ <a href="https://scorecard.dev/viewer/?uri=github.com/durandtibo/invoke-tasklib"><img
62
+ alt="OpenSSF Scorecard"
63
+ src="https://img.shields.io/ossf-scorecard/github.com/durandtibo/invoke-tasklib?label=openssf%20scorecard"></a>
64
+ <br/>
65
+ <a href="https://pepy.tech/project/invoke-tasklib"><img
66
+ alt="Downloads"
67
+ src="https://img.shields.io/pepy/dt/invoke-tasklib"></a>
68
+ <a href="https://pepy.tech/project/invoke-tasklib"><img
69
+ alt="Monthly downloads"
70
+ src="https://img.shields.io/pepy/dm/invoke-tasklib"></a>
71
+ <a href="https://github.com/durandtibo/invoke-tasklib/stargazers"><img
72
+ alt="GitHub stars"
73
+ src="https://img.shields.io/github/stars/durandtibo/invoke-tasklib?logo=github"></a>
74
+ </p>
75
+
76
+ Reusable [Invoke](https://www.pyinvoke.org/) tasks shared across Python
77
+ projects: formatting, linting, type-checking, testing, environment setup,
78
+ security auditing, releasing, documentation, and cleanup — all as a single
79
+ importable package instead of a `tasks.py` you copy-paste and let drift
80
+ between repositories.
81
+
82
+ :book: **Full documentation:** <https://durandtibo.github.io/invoke-tasklib/>
83
+
84
+ ## Install
85
+
86
+ ```shell
87
+ uv add --dev invoke-tasklib
88
+ ```
89
+
90
+ or with `pip`:
91
+
92
+ ```shell
93
+ pip install invoke-tasklib
94
+ ```
95
+
96
+ **Prerequisite:** most tasks (`env.*`, `release.*`, `security.audit`) run
97
+ [`uv`](https://docs.astral.sh/uv/getting-started/installation/), so install
98
+ it even if you install `invoke-tasklib` with `pip`.
99
+
100
+ **Platforms:** Linux and macOS. Windows is not supported: the tasks rely on
101
+ a POSIX shell (for the quoting of the commands), and `make_ns` emits a
102
+ `RuntimeWarning` on Windows.
103
+
104
+ ## Quickstart
105
+
106
+ **1. Add a `tasks.py`** at the root of your project:
107
+
108
+ ```python
109
+ # tasks.py
110
+ from invoke_tasklib import make_ns
111
+
112
+ ns = make_ns()
113
+ ```
114
+
115
+ **2. Add an `invoke.yaml`** with, at minimum, your package name:
116
+
117
+ ```yaml
118
+ tasklib:
119
+ package:
120
+ name: my_package
121
+ ```
122
+
123
+ **3. List and run the tasks:**
124
+
125
+ ```shell
126
+ invoke --list
127
+ invoke format.check-python lint.check-python
128
+ invoke test.unit
129
+ ```
130
+
131
+ If a task fails because a tool like `ruff` or `pytest` isn't installed yet,
132
+ run `invoke env.install` first.
133
+
134
+ See the [Get Started guide](https://durandtibo.github.io/invoke-tasklib/get_started/)
135
+ for a full walkthrough.
136
+
137
+ ## Tasks
138
+
139
+ Tasks are grouped into namespaces, one per module. Each task either
140
+ **checks/reports** (read-only, exits non-zero on violations) or
141
+ **mutates** (formats, builds, publishes) — the table below flags which.
142
+
143
+ | Namespace | Task | Behavior | Mutates? |
144
+ | ---------- | ----------------------------- | ---------------------------------------------------------------------------------------- | :------: |
145
+ | `format` | `format.check-python` | Check Python formatting with ruff | ❌ |
146
+ | `format` | `format.fix-python` | Format Python code with ruff | ✅ |
147
+ | `format` | `format.check-docstrings` | Check docstring formatting with docformatter | ❌ |
148
+ | `format` | `format.fix-docstrings` | Format docstrings with docformatter | ✅ |
149
+ | `format` | `format.check-shell` | Check shell scripts with shellcheck | ❌ |
150
+ | `format` | `format.check-shell-format` | Check the format of shell scripts with shfmt | ❌ |
151
+ | `format` | `format.fix-shell` | Format shell scripts with shfmt | ✅ |
152
+ | `lint` | `lint.check-python` | Check linting with ruff | ❌ |
153
+ | `lint` | `lint.fix-python` | Fix auto-fixable linting issues with ruff | ✅ |
154
+ | `lint` | `lint.check-spelling` | Check the spelling with codespell | ❌ |
155
+ | `lint` | `lint.pre-commit` | Run all the pre-commit hooks | ✅ |
156
+ | `imports` | `imports.check-cycles` | Check for cyclic import dependencies | ❌ |
157
+ | `imports` | `imports.check-isolated` | Check that every module imports on its own | ❌ |
158
+ | `types` | `types.check` | Check type hints with ty (`--complete` also runs pyright) | ❌ |
159
+ | `test` | `test.doctest` | Run doctests on source code and markdown files | ❌ |
160
+ | `test` | `test.doctest-src` | Run doctests on source code | ❌ |
161
+ | `test` | `test.doctest-markdown` | Run doctests on Python examples in markdown files | ❌ |
162
+ | `test` | `test.unit` | Run unit tests | ❌ |
163
+ | `test` | `test.integration` | Run integration tests | ❌ |
164
+ | `test` | `test.functional` | Run functional tests | ❌ |
165
+ | `test` | `test.all` | Run unit, integration, and functional tests | ❌ |
166
+ | `test` | `test.coverage-report` | Generate an HTML/terminal report from existing coverage data | ❌ |
167
+ | `test` | `test.benchmark` | Run performance benchmarks | ❌ |
168
+ | `env` | `env.create-venv` | Create a virtual environment and install the project | ✅ |
169
+ | `env` | `env.install` | Install project dependencies and the package (editable) | ✅ |
170
+ | `env` | `env.check-tools` | Check which tools (ruff, pyright, ...) are available | ❌ |
171
+ | `env` | `env.update` | Update dependencies and pre-commit hooks | ✅ |
172
+ | `env` | `env.show-installed-packages` | Show the installed packages | ❌ |
173
+ | `env` | `env.show-python-config` | Show the Python configuration | ❌ |
174
+ | `release` | `release.build` | Build the package and verify installation (`--check` also validates metadata with twine) | ✅ |
175
+ | `release` | `release.publish` | Build and publish the package to PyPI | ✅ |
176
+ | `doc` | `doc.publish-dev` | Publish development (unstable) docs | ✅ |
177
+ | `doc` | `doc.publish-latest` | Publish latest (stable) docs | ✅ |
178
+ | `doc` | `doc.build` | Build the docs, failing on warnings (`mkdocs build --strict`) | ❌ |
179
+ | `doc` | `doc.serve` | Serve the docs locally | ❌ |
180
+ | `security` | `security.audit` | Audit the locked dependencies for known vulnerabilities with pip-audit | ❌ |
181
+ | `check` | `check.all` (or `check`) | Run the main read-only checks | ❌ |
182
+ | `fix` | `fix.all` (or `fix`) | Fix the lint and format issues | ✅ |
183
+ | `clean` | `clean.all` (or `clean`) | Remove build artifacts and caches | ✅ |
184
+ | `clean` | `clean.pycache` | Remove all `__pycache__` directories | ✅ |
185
+ | `config` | `config.show` | Show the resolved config and where each value comes from | ❌ |
186
+
187
+ `format.*` and `lint.*` follow a naming convention: read-only checks are
188
+ named `check_<target>`, and the matching in-place fixer is named
189
+ `fix_<target>` (e.g. `check_python`/`fix_python`), so the counterpart of a
190
+ task is always easy to find. Follow this convention when adding new tasks
191
+ to these namespaces.
192
+
193
+ For task-by-task details, options (like `--cov` on `test.*` tasks), and the
194
+ tools each one wraps, see the
195
+ [User Guide](https://durandtibo.github.io/invoke-tasklib/uguide/).
196
+
197
+ ## Configuration
198
+
199
+ Only `tasklib.package.name` is required — everything else has a sensible
200
+ default derived from it:
201
+
202
+ ```yaml
203
+ tasklib:
204
+ package:
205
+ name: my_package # required
206
+ import_name: my_package # default: <package.name> with - replaced by _
207
+ python_version: "3.14" # used by env.create-venv (default: the version that uv chooses)
208
+ paths:
209
+ src: src/my_package # default: src/<package.import_name>
210
+ tests: tests
211
+ unit_tests: tests/unit # default: <tests>/unit
212
+ integration_tests: tests/integration # default: <tests>/integration
213
+ functional_tests: tests/functional # default: <tests>/functional
214
+ benchmarks: tests/benchmarks # default: <tests>/benchmarks
215
+ docs_config: docs/mkdocs.yml
216
+ groups:
217
+ install: dev # dependency groups of env.install
218
+ update: dev,docs # dependency groups of env.update
219
+ test:
220
+ unit_timeout: 10 # seconds, also integration_timeout and functional_timeout
221
+ xdoctest: true # pytest --xdoctest (needs xdoctest)
222
+ timeout: true # pytest --timeout (needs pytest-timeout)
223
+ cov_fail_under: 90 # threshold of --cov (default: not set)
224
+ cov_reports: html,xml,term
225
+ types:
226
+ checker: ty # type checker of types.check: ty, pyright or mypy
227
+ check:
228
+ tasks: format-python,format-docstrings,lint,types,imports,unit # steps of check.all
229
+ cov: false # run the unit step of check.all with --cov
230
+ fix:
231
+ tasks: lint,format-python,format-docstrings # steps of fix.all
232
+ ```
233
+
234
+ `check.tasks` also accepts `doctest`, `shell`, `spelling`, `docs` and `audit`; `fix.tasks` also
235
+ accepts `shell`. `invoke config.show` prints the resolved values and where each one comes from.
236
+
237
+ See the [Config reference](https://durandtibo.github.io/invoke-tasklib/uguide/config/)
238
+ for how each path default is derived.
239
+
240
+ Every key can also be set with an `INVOKE_TASKLIB_<SECTION>_<KEY>` environment variable, for example
241
+ `INVOKE_TASKLIB_PATHS_SRC=lib` or `INVOKE_TASKLIB_TEST_UNIT_TIMEOUT=30`, which wins over
242
+ `invoke.yaml`. An invalid value, an unknown key (with the closest valid key suggested) or a wrong
243
+ working directory exits with the code 2 before any command runs. For editor completion, the JSON
244
+ schema of the `tasklib` section is published at
245
+ <https://durandtibo.github.io/invoke-tasklib/schema.json> (`python -m invoke_tasklib.config` prints
246
+ it).
247
+
248
+ ## Conventions
249
+
250
+ - **Arguments:** the tasks that run a tool take `--args` (extra arguments for the tool, as one
251
+ string, e.g. `--args "-k foo -x"`) and, for the tasks that work on files, `--paths` (files or
252
+ directories instead of the default ones). Both are quoted, so a glob or `~` reaches the tool as
253
+ it is.
254
+ - **Exit codes:** `0` the task passed, or had nothing to do (a `⏭️` line says why); `1` the checked
255
+ thing failed; `2` invalid usage or config; `127` a tool is missing. A missing program or Python
256
+ module is reported with the command that installs it.
257
+ - **Composite tasks:** `invoke check` runs the main read-only checks and `invoke fix` the fixers;
258
+ `--only`, `--skip` and `--keep-going` select the steps and report all the failures at the end.
259
+ - **Dangerous tasks ask first:** `env.create-venv` asks before it clears `.venv` and
260
+ `release.publish` checks the git state and asks before it uploads (`--yes` skips the question,
261
+ `--dry-run` publishes nothing). `clean` stays inside the project and keeps what git tracks.
262
+ - **ASCII output:** set `INVOKE_TASKLIB_ASCII=1` to replace the emojis of the messages with
263
+ `[ok]`, `[fail]` and `[skip]`.
264
+
265
+ ## Composing a custom subset of tasks
266
+
267
+ Need a different set of tasks, or a one-off task alongside the shared ones?
268
+ Use `make_ns`, which returns a new collection each time, so adding or removing tasks never affects
269
+ other importers. Leave out the tasks you do not use (for example the ones that publish):
270
+
271
+ ```python
272
+ # tasks.py
273
+ from invoke import task
274
+ from invoke_tasklib import make_ns
275
+
276
+
277
+ @task
278
+ def my_custom_task(c):
279
+ r"""Run a one-off command."""
280
+ c.run("echo hello")
281
+
282
+
283
+ ns = make_ns(exclude=["release.publish", "doc"])
284
+ ns.add_task(my_custom_task)
285
+ ```
286
+
287
+ `tasks.py` is imported by Invoke as a top-level module, so a task defined in another file of the
288
+ project is imported with an absolute import (`from my_tasks import my_custom_task`), not a
289
+ relative one (`from . import my_custom_task`), which fails with an `ImportError`.
290
+
291
+ or keep only some of them with `include`, e.g. `make_ns(include=["lint", "test.unit"])`. The names
292
+ are namespaces (`"doc"`) or tasks (`"release.publish"`); an unknown name raises a `ValueError`. The
293
+ `make_ns()` with no argument has all the tasks (there is no pre-built `invoke_tasklib.ns`, so no
294
+ collection is shared between importers). Individual task modules can also be composed by
295
+ hand:
296
+
297
+ ```python
298
+ # tasks.py
299
+ from invoke import Collection, task
300
+ from invoke_tasklib import lint, testing
301
+
302
+
303
+ @task
304
+ def my_custom_task(c):
305
+ r"""Run a one-off command."""
306
+ c.run("echo hello")
307
+
308
+
309
+ ns = Collection(lint, Collection.from_module(testing, name=testing.NAMESPACE), my_custom_task)
310
+ ```
311
+
312
+ The modules of the `format`, `types` and `test` namespaces are named `formatting`, `typecheck`
313
+ and `testing` so that they do not shadow the standard library (`types`, `test`) or a builtin
314
+ (`format`); pass `name=module.NAMESPACE` (every task module has the name of its namespace in `NAMESPACE`)
315
+ to `Collection.from_module` to keep the task names.
316
+
317
+ Prefer adding a config knob to a shared task over forking it; reserve custom
318
+ composition for things that are genuinely one-off to a single project.
319
+
320
+ ## API Stability
321
+
322
+ :warning: `invoke-tasklib` is under active development and its API is not
323
+ yet stable — pin a specific version in your project's dependencies for
324
+ consistent behavior across releases.
325
+
326
+ ## Contributing
327
+
328
+ Contributions are welcome! Please open an issue first to discuss
329
+ significant changes. See the
330
+ [developer guide](https://durandtibo.github.io/invoke-tasklib/dev/development/)
331
+ for how to set up a development environment.
332
+
333
+ ## License
334
+
335
+ `invoke-tasklib` is licensed under the BSD 3-Clause "New" or "Revised"
336
+ license available in
337
+ [LICENSE](https://github.com/durandtibo/invoke-tasklib/blob/main/LICENSE).
@@ -0,0 +1,309 @@
1
+ # invoke-tasklib
2
+
3
+ <p align="center">
4
+ <a href="https://github.com/durandtibo/invoke-tasklib/actions/workflows/ci.yaml"><img
5
+ alt="CI"
6
+ src="https://img.shields.io/github/actions/workflow/status/durandtibo/invoke-tasklib/ci.yaml?branch=main&label=CI&logo=github"></a>
7
+ <a href="https://github.com/durandtibo/invoke-tasklib/actions/workflows/nightly-package.yaml"><img
8
+ alt="Nightly Package Tests"
9
+ src="https://img.shields.io/github/actions/workflow/status/durandtibo/invoke-tasklib/nightly-package.yaml?label=nightly&logo=github"></a>
10
+ <a href="https://codecov.io/gh/durandtibo/invoke-tasklib"><img
11
+ alt="Codecov"
12
+ src="https://img.shields.io/codecov/c/github/durandtibo/invoke-tasklib?logo=codecov"></a>
13
+ <a href="https://durandtibo.github.io/invoke-tasklib/"><img
14
+ alt="Documentation (stable)"
15
+ src="https://img.shields.io/badge/docs-stable-blue?logo=readthedocs&logoColor=white"></a>
16
+ <br/>
17
+ <a href="https://pypi.org/project/invoke-tasklib/"><img
18
+ alt="PyPI version"
19
+ src="https://img.shields.io/pypi/v/invoke-tasklib?logo=pypi&logoColor=white"></a>
20
+ <a href="https://pypi.org/project/invoke-tasklib/"><img
21
+ alt="Python"
22
+ src="https://img.shields.io/pypi/pyversions/invoke-tasklib?logo=python&logoColor=white"></a>
23
+ <a href="https://opensource.org/licenses/BSD-3-Clause"><img
24
+ alt="BSD-3-Clause"
25
+ src="https://img.shields.io/pypi/l/invoke-tasklib"></a>
26
+ <br/>
27
+ <a href="https://github.com/astral-sh/ruff"><img
28
+ alt="Ruff"
29
+ src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"></a>
30
+ <a href="https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings"><img
31
+ alt="Doc style: google"
32
+ src="https://img.shields.io/badge/docstyle-google-3666d6"></a>
33
+ <a href="https://scorecard.dev/viewer/?uri=github.com/durandtibo/invoke-tasklib"><img
34
+ alt="OpenSSF Scorecard"
35
+ src="https://img.shields.io/ossf-scorecard/github.com/durandtibo/invoke-tasklib?label=openssf%20scorecard"></a>
36
+ <br/>
37
+ <a href="https://pepy.tech/project/invoke-tasklib"><img
38
+ alt="Downloads"
39
+ src="https://img.shields.io/pepy/dt/invoke-tasklib"></a>
40
+ <a href="https://pepy.tech/project/invoke-tasklib"><img
41
+ alt="Monthly downloads"
42
+ src="https://img.shields.io/pepy/dm/invoke-tasklib"></a>
43
+ <a href="https://github.com/durandtibo/invoke-tasklib/stargazers"><img
44
+ alt="GitHub stars"
45
+ src="https://img.shields.io/github/stars/durandtibo/invoke-tasklib?logo=github"></a>
46
+ </p>
47
+
48
+ Reusable [Invoke](https://www.pyinvoke.org/) tasks shared across Python
49
+ projects: formatting, linting, type-checking, testing, environment setup,
50
+ security auditing, releasing, documentation, and cleanup — all as a single
51
+ importable package instead of a `tasks.py` you copy-paste and let drift
52
+ between repositories.
53
+
54
+ :book: **Full documentation:** <https://durandtibo.github.io/invoke-tasklib/>
55
+
56
+ ## Install
57
+
58
+ ```shell
59
+ uv add --dev invoke-tasklib
60
+ ```
61
+
62
+ or with `pip`:
63
+
64
+ ```shell
65
+ pip install invoke-tasklib
66
+ ```
67
+
68
+ **Prerequisite:** most tasks (`env.*`, `release.*`, `security.audit`) run
69
+ [`uv`](https://docs.astral.sh/uv/getting-started/installation/), so install
70
+ it even if you install `invoke-tasklib` with `pip`.
71
+
72
+ **Platforms:** Linux and macOS. Windows is not supported: the tasks rely on
73
+ a POSIX shell (for the quoting of the commands), and `make_ns` emits a
74
+ `RuntimeWarning` on Windows.
75
+
76
+ ## Quickstart
77
+
78
+ **1. Add a `tasks.py`** at the root of your project:
79
+
80
+ ```python
81
+ # tasks.py
82
+ from invoke_tasklib import make_ns
83
+
84
+ ns = make_ns()
85
+ ```
86
+
87
+ **2. Add an `invoke.yaml`** with, at minimum, your package name:
88
+
89
+ ```yaml
90
+ tasklib:
91
+ package:
92
+ name: my_package
93
+ ```
94
+
95
+ **3. List and run the tasks:**
96
+
97
+ ```shell
98
+ invoke --list
99
+ invoke format.check-python lint.check-python
100
+ invoke test.unit
101
+ ```
102
+
103
+ If a task fails because a tool like `ruff` or `pytest` isn't installed yet,
104
+ run `invoke env.install` first.
105
+
106
+ See the [Get Started guide](https://durandtibo.github.io/invoke-tasklib/get_started/)
107
+ for a full walkthrough.
108
+
109
+ ## Tasks
110
+
111
+ Tasks are grouped into namespaces, one per module. Each task either
112
+ **checks/reports** (read-only, exits non-zero on violations) or
113
+ **mutates** (formats, builds, publishes) — the table below flags which.
114
+
115
+ | Namespace | Task | Behavior | Mutates? |
116
+ | ---------- | ----------------------------- | ---------------------------------------------------------------------------------------- | :------: |
117
+ | `format` | `format.check-python` | Check Python formatting with ruff | ❌ |
118
+ | `format` | `format.fix-python` | Format Python code with ruff | ✅ |
119
+ | `format` | `format.check-docstrings` | Check docstring formatting with docformatter | ❌ |
120
+ | `format` | `format.fix-docstrings` | Format docstrings with docformatter | ✅ |
121
+ | `format` | `format.check-shell` | Check shell scripts with shellcheck | ❌ |
122
+ | `format` | `format.check-shell-format` | Check the format of shell scripts with shfmt | ❌ |
123
+ | `format` | `format.fix-shell` | Format shell scripts with shfmt | ✅ |
124
+ | `lint` | `lint.check-python` | Check linting with ruff | ❌ |
125
+ | `lint` | `lint.fix-python` | Fix auto-fixable linting issues with ruff | ✅ |
126
+ | `lint` | `lint.check-spelling` | Check the spelling with codespell | ❌ |
127
+ | `lint` | `lint.pre-commit` | Run all the pre-commit hooks | ✅ |
128
+ | `imports` | `imports.check-cycles` | Check for cyclic import dependencies | ❌ |
129
+ | `imports` | `imports.check-isolated` | Check that every module imports on its own | ❌ |
130
+ | `types` | `types.check` | Check type hints with ty (`--complete` also runs pyright) | ❌ |
131
+ | `test` | `test.doctest` | Run doctests on source code and markdown files | ❌ |
132
+ | `test` | `test.doctest-src` | Run doctests on source code | ❌ |
133
+ | `test` | `test.doctest-markdown` | Run doctests on Python examples in markdown files | ❌ |
134
+ | `test` | `test.unit` | Run unit tests | ❌ |
135
+ | `test` | `test.integration` | Run integration tests | ❌ |
136
+ | `test` | `test.functional` | Run functional tests | ❌ |
137
+ | `test` | `test.all` | Run unit, integration, and functional tests | ❌ |
138
+ | `test` | `test.coverage-report` | Generate an HTML/terminal report from existing coverage data | ❌ |
139
+ | `test` | `test.benchmark` | Run performance benchmarks | ❌ |
140
+ | `env` | `env.create-venv` | Create a virtual environment and install the project | ✅ |
141
+ | `env` | `env.install` | Install project dependencies and the package (editable) | ✅ |
142
+ | `env` | `env.check-tools` | Check which tools (ruff, pyright, ...) are available | ❌ |
143
+ | `env` | `env.update` | Update dependencies and pre-commit hooks | ✅ |
144
+ | `env` | `env.show-installed-packages` | Show the installed packages | ❌ |
145
+ | `env` | `env.show-python-config` | Show the Python configuration | ❌ |
146
+ | `release` | `release.build` | Build the package and verify installation (`--check` also validates metadata with twine) | ✅ |
147
+ | `release` | `release.publish` | Build and publish the package to PyPI | ✅ |
148
+ | `doc` | `doc.publish-dev` | Publish development (unstable) docs | ✅ |
149
+ | `doc` | `doc.publish-latest` | Publish latest (stable) docs | ✅ |
150
+ | `doc` | `doc.build` | Build the docs, failing on warnings (`mkdocs build --strict`) | ❌ |
151
+ | `doc` | `doc.serve` | Serve the docs locally | ❌ |
152
+ | `security` | `security.audit` | Audit the locked dependencies for known vulnerabilities with pip-audit | ❌ |
153
+ | `check` | `check.all` (or `check`) | Run the main read-only checks | ❌ |
154
+ | `fix` | `fix.all` (or `fix`) | Fix the lint and format issues | ✅ |
155
+ | `clean` | `clean.all` (or `clean`) | Remove build artifacts and caches | ✅ |
156
+ | `clean` | `clean.pycache` | Remove all `__pycache__` directories | ✅ |
157
+ | `config` | `config.show` | Show the resolved config and where each value comes from | ❌ |
158
+
159
+ `format.*` and `lint.*` follow a naming convention: read-only checks are
160
+ named `check_<target>`, and the matching in-place fixer is named
161
+ `fix_<target>` (e.g. `check_python`/`fix_python`), so the counterpart of a
162
+ task is always easy to find. Follow this convention when adding new tasks
163
+ to these namespaces.
164
+
165
+ For task-by-task details, options (like `--cov` on `test.*` tasks), and the
166
+ tools each one wraps, see the
167
+ [User Guide](https://durandtibo.github.io/invoke-tasklib/uguide/).
168
+
169
+ ## Configuration
170
+
171
+ Only `tasklib.package.name` is required — everything else has a sensible
172
+ default derived from it:
173
+
174
+ ```yaml
175
+ tasklib:
176
+ package:
177
+ name: my_package # required
178
+ import_name: my_package # default: <package.name> with - replaced by _
179
+ python_version: "3.14" # used by env.create-venv (default: the version that uv chooses)
180
+ paths:
181
+ src: src/my_package # default: src/<package.import_name>
182
+ tests: tests
183
+ unit_tests: tests/unit # default: <tests>/unit
184
+ integration_tests: tests/integration # default: <tests>/integration
185
+ functional_tests: tests/functional # default: <tests>/functional
186
+ benchmarks: tests/benchmarks # default: <tests>/benchmarks
187
+ docs_config: docs/mkdocs.yml
188
+ groups:
189
+ install: dev # dependency groups of env.install
190
+ update: dev,docs # dependency groups of env.update
191
+ test:
192
+ unit_timeout: 10 # seconds, also integration_timeout and functional_timeout
193
+ xdoctest: true # pytest --xdoctest (needs xdoctest)
194
+ timeout: true # pytest --timeout (needs pytest-timeout)
195
+ cov_fail_under: 90 # threshold of --cov (default: not set)
196
+ cov_reports: html,xml,term
197
+ types:
198
+ checker: ty # type checker of types.check: ty, pyright or mypy
199
+ check:
200
+ tasks: format-python,format-docstrings,lint,types,imports,unit # steps of check.all
201
+ cov: false # run the unit step of check.all with --cov
202
+ fix:
203
+ tasks: lint,format-python,format-docstrings # steps of fix.all
204
+ ```
205
+
206
+ `check.tasks` also accepts `doctest`, `shell`, `spelling`, `docs` and `audit`; `fix.tasks` also
207
+ accepts `shell`. `invoke config.show` prints the resolved values and where each one comes from.
208
+
209
+ See the [Config reference](https://durandtibo.github.io/invoke-tasklib/uguide/config/)
210
+ for how each path default is derived.
211
+
212
+ Every key can also be set with an `INVOKE_TASKLIB_<SECTION>_<KEY>` environment variable, for example
213
+ `INVOKE_TASKLIB_PATHS_SRC=lib` or `INVOKE_TASKLIB_TEST_UNIT_TIMEOUT=30`, which wins over
214
+ `invoke.yaml`. An invalid value, an unknown key (with the closest valid key suggested) or a wrong
215
+ working directory exits with the code 2 before any command runs. For editor completion, the JSON
216
+ schema of the `tasklib` section is published at
217
+ <https://durandtibo.github.io/invoke-tasklib/schema.json> (`python -m invoke_tasklib.config` prints
218
+ it).
219
+
220
+ ## Conventions
221
+
222
+ - **Arguments:** the tasks that run a tool take `--args` (extra arguments for the tool, as one
223
+ string, e.g. `--args "-k foo -x"`) and, for the tasks that work on files, `--paths` (files or
224
+ directories instead of the default ones). Both are quoted, so a glob or `~` reaches the tool as
225
+ it is.
226
+ - **Exit codes:** `0` the task passed, or had nothing to do (a `⏭️` line says why); `1` the checked
227
+ thing failed; `2` invalid usage or config; `127` a tool is missing. A missing program or Python
228
+ module is reported with the command that installs it.
229
+ - **Composite tasks:** `invoke check` runs the main read-only checks and `invoke fix` the fixers;
230
+ `--only`, `--skip` and `--keep-going` select the steps and report all the failures at the end.
231
+ - **Dangerous tasks ask first:** `env.create-venv` asks before it clears `.venv` and
232
+ `release.publish` checks the git state and asks before it uploads (`--yes` skips the question,
233
+ `--dry-run` publishes nothing). `clean` stays inside the project and keeps what git tracks.
234
+ - **ASCII output:** set `INVOKE_TASKLIB_ASCII=1` to replace the emojis of the messages with
235
+ `[ok]`, `[fail]` and `[skip]`.
236
+
237
+ ## Composing a custom subset of tasks
238
+
239
+ Need a different set of tasks, or a one-off task alongside the shared ones?
240
+ Use `make_ns`, which returns a new collection each time, so adding or removing tasks never affects
241
+ other importers. Leave out the tasks you do not use (for example the ones that publish):
242
+
243
+ ```python
244
+ # tasks.py
245
+ from invoke import task
246
+ from invoke_tasklib import make_ns
247
+
248
+
249
+ @task
250
+ def my_custom_task(c):
251
+ r"""Run a one-off command."""
252
+ c.run("echo hello")
253
+
254
+
255
+ ns = make_ns(exclude=["release.publish", "doc"])
256
+ ns.add_task(my_custom_task)
257
+ ```
258
+
259
+ `tasks.py` is imported by Invoke as a top-level module, so a task defined in another file of the
260
+ project is imported with an absolute import (`from my_tasks import my_custom_task`), not a
261
+ relative one (`from . import my_custom_task`), which fails with an `ImportError`.
262
+
263
+ or keep only some of them with `include`, e.g. `make_ns(include=["lint", "test.unit"])`. The names
264
+ are namespaces (`"doc"`) or tasks (`"release.publish"`); an unknown name raises a `ValueError`. The
265
+ `make_ns()` with no argument has all the tasks (there is no pre-built `invoke_tasklib.ns`, so no
266
+ collection is shared between importers). Individual task modules can also be composed by
267
+ hand:
268
+
269
+ ```python
270
+ # tasks.py
271
+ from invoke import Collection, task
272
+ from invoke_tasklib import lint, testing
273
+
274
+
275
+ @task
276
+ def my_custom_task(c):
277
+ r"""Run a one-off command."""
278
+ c.run("echo hello")
279
+
280
+
281
+ ns = Collection(lint, Collection.from_module(testing, name=testing.NAMESPACE), my_custom_task)
282
+ ```
283
+
284
+ The modules of the `format`, `types` and `test` namespaces are named `formatting`, `typecheck`
285
+ and `testing` so that they do not shadow the standard library (`types`, `test`) or a builtin
286
+ (`format`); pass `name=module.NAMESPACE` (every task module has the name of its namespace in `NAMESPACE`)
287
+ to `Collection.from_module` to keep the task names.
288
+
289
+ Prefer adding a config knob to a shared task over forking it; reserve custom
290
+ composition for things that are genuinely one-off to a single project.
291
+
292
+ ## API Stability
293
+
294
+ :warning: `invoke-tasklib` is under active development and its API is not
295
+ yet stable — pin a specific version in your project's dependencies for
296
+ consistent behavior across releases.
297
+
298
+ ## Contributing
299
+
300
+ Contributions are welcome! Please open an issue first to discuss
301
+ significant changes. See the
302
+ [developer guide](https://durandtibo.github.io/invoke-tasklib/dev/development/)
303
+ for how to set up a development environment.
304
+
305
+ ## License
306
+
307
+ `invoke-tasklib` is licensed under the BSD 3-Clause "New" or "Revised"
308
+ license available in
309
+ [LICENSE](https://github.com/durandtibo/invoke-tasklib/blob/main/LICENSE).