invoke-toolkit 0.0.73__tar.gz → 0.0.75__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.
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/PKG-INFO +47 -1
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/README.md +46 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/config/config.py +1 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/tasks/create.py +13 -10
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/program/program.py +93 -15
- invoke_toolkit-0.0.75/src/invoke_toolkit/program/task_changes.py +184 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/scripts/loader.py +2 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/extensions/test_create.py +16 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_cofig_class.py +6 -0
- invoke_toolkit-0.0.75/tests/test_list_changed.py +383 -0
- invoke_toolkit-0.0.75/tests/test_program_with_collection.py +299 -0
- invoke_toolkit-0.0.73/tests/test_program_with_collection.py +0 -84
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/.gitignore +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/LICENSE.txt +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/pyproject.toml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/__main__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/collections.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/completion.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/config/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/config/registry.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/config/schema.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/config/status_helper.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/context/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/context/async_tools.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/context/context.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/context/types.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/executor.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/tasks/config.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/tasks/dist.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/tasks/plugin.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/tasks/shell.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/uv_tools.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/field_resolvers.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/loader/entrypoint.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/log/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/log/logger.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/output/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/output/console.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/output/utils.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/parser.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/program/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/program/main.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/py.typed +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/runners/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/runners/rich.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/scripts/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/tasks/autocomplete.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/tasks/cache.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/tasks/fields.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/tasks/fields.pyi +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/tasks/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/tasks/types.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/testing.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/utils/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/utils/fzf.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/utils/inspection.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/utils/singleton.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/utils/text.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/package-template/.gitignore.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/package-template/README.md.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/package-template/copier.yml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/package-template/pyproject.toml.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/package-template/src/{{package_slug}}/__init__.py.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/package-template/src/{{package_slug}}/tasks.py.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/provider-template/.gitignore.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/provider-template/README.md.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/provider-template/copier.yml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/provider-template/pyproject.toml.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/provider-template/src/{{package_slug}}/__init__.py.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/templates/provider-template/tests/test_resolver.py.jinja +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/conftest.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/cached_completion/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/completion_with_config/.gitignore +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/completion_with_config/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/config_schema/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/enum_select_size/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/fzf_selector/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/literal_set_level/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/local_field_resolver/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/local_tasks/local_tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/examples/local_tasks/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/extensions/conftest.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/extensions/test_config_tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/extensions/test_package_template_entrypoint.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/extensions/test_shell_tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/extensions/test_uv_plugins.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/fixtures/future_fields.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/integration/pty_plugin_completion.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/integration/uv_tool_plugins.sh +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/all-four/invoke.json +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/all-four/invoke.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/all-four/invoke.yml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/collection.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/echo.yaml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/json/invoke.json +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/json-and-python/invoke.json +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/json-and-python/invoke.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/no-dedupe.yaml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/no-echo.yaml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/package/invoke.yml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/package/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/python/invoke.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/runtime.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/three-of-em/invoke.json +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/three-of-em/invoke.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/three-of-em/invoke.yml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/underscores/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/yaml/explicit.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/yaml/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/yml/explicit.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/yml/invoke.yml +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/configs/yml/tasks.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/_support/has_modules.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/conftest.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/original_invoke/test_config.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/program/main.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/program/tasks/__init__.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/program/tasks/coll1.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/script/test_script.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/tasks/test_cache.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/tasks/test_extensions_config.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_alias_self_reference.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_annotated_help.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_async_edge_cases.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_async_support.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_collection.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_collection_configure.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_completion_with_choices.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_config_helper.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_config_registry.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_config_schema.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_console.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_context_class.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_disable_status_cli.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_enum_arguments.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_executor.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_field_typing.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_fields.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_file_completion.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_global_context.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_help_flags.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_invoke_3_compat.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_invoke_compatibility.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_list_filter_flags.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_loader.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_parsing.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_proctitle.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_pty_stdin.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_release_guard.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_task_suggestions.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/test_toplevel.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/typecheck/fields.py +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/typecheck/fields_negative.py.fixture +0 -0
- {invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/tests/utils/test_fzf.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: invoke-toolkit
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.75
|
|
4
4
|
Summary: Extended APIs for PyInvoke: composable task plugins, typed CLI args, Rich output, shell completion, and PEP 723 script support
|
|
5
5
|
Project-URL: Documentation, https://github.com/D3f0/invoke-toolkit#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/D3f0/invoke-toolkit/issues
|
|
@@ -130,6 +130,37 @@ intk local.my-task
|
|
|
130
130
|
|
|
131
131
|
Local tasks are automatically discovered and added to the `local` namespace, allowing you to keep project-specific tasks separate from your main task collection.
|
|
132
132
|
|
|
133
|
+
### Listing changed tasks
|
|
134
|
+
|
|
135
|
+
For a Git-managed PEP 723 script that calls `invoke_toolkit.script()`:
|
|
136
|
+
|
|
137
|
+
```console
|
|
138
|
+
uv run tasks.py --list-changed
|
|
139
|
+
uv run tasks.py --list-changed --list-format json
|
|
140
|
+
uv run tasks.py --list
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`--list-changed` lists only new or updated task definitions compared with Git
|
|
144
|
+
`HEAD`, including staged and unstaged edits. Normal flat and nested listings
|
|
145
|
+
also highlight new tasks in green and updated tasks in yellow. Color follows
|
|
146
|
+
Rich's terminal detection and `NO_COLOR`; JSON retains Invoke's existing schema.
|
|
147
|
+
The flag also works with `intk --list-changed` for a loaded task file, and can
|
|
148
|
+
combine with `--list <namespace>`, `--list-tasks`, or `--list-plugins` to narrow
|
|
149
|
+
the listing further.
|
|
150
|
+
|
|
151
|
+
Comparison includes task bodies, signatures, decorators, and docstrings, but
|
|
152
|
+
ignores comments, formatting, and line-number shifts. Imported tasks and
|
|
153
|
+
indirect changes through helpers or globals are not included. Historical source
|
|
154
|
+
is parsed, never executed. In a Git repository, every task in a file absent
|
|
155
|
+
from `HEAD` (including a new repository without commits) counts as new.
|
|
156
|
+
Adding a task decorator to a helper counts as new; changing the decorator's
|
|
157
|
+
explicit task name counts as an update to that existing definition.
|
|
158
|
+
|
|
159
|
+
With no changes, the flag exits successfully with an empty JSON task list or a
|
|
160
|
+
message for human-readable formats. Outside a Git repository, or without Git,
|
|
161
|
+
`--list-changed` reports an error; normal listing still works without highlights.
|
|
162
|
+
|
|
163
|
+
|
|
133
164
|
### Using Task Caching
|
|
134
165
|
|
|
135
166
|
Cache expensive task results with the `cache` parameter:
|
|
@@ -262,6 +293,21 @@ do not update invoke-toolkit itself.
|
|
|
262
293
|
Shell completion suggests directly installed plugin names for `plugin.remove`
|
|
263
294
|
and named `plugin.update` operations.
|
|
264
295
|
|
|
296
|
+
To reduce shell-completion latency in environments with expensive collection
|
|
297
|
+
plugins, set `completion.disable_plugins: true` in `invoke.yaml`:
|
|
298
|
+
|
|
299
|
+
```yaml
|
|
300
|
+
completion:
|
|
301
|
+
disable_plugins: true
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
`INVOKE_COMPLETION_DISABLE_PLUGINS=1` enables the same behavior without changing
|
|
305
|
+
the configuration file. Completion then skips installed
|
|
306
|
+
`invoke_toolkit.collection` entry points while retaining project, local, and
|
|
307
|
+
built-in `-x` task suggestions. These settings affect completion only; normal
|
|
308
|
+
task execution and listing still load plugins.
|
|
309
|
+
|
|
310
|
+
|
|
265
311
|
|
|
266
312
|
These commands reject `uvx`, `uv run`, project environments, and installations
|
|
267
313
|
managed by another tool. pipx offers a similar manual workflow:
|
|
@@ -69,6 +69,37 @@ intk local.my-task
|
|
|
69
69
|
|
|
70
70
|
Local tasks are automatically discovered and added to the `local` namespace, allowing you to keep project-specific tasks separate from your main task collection.
|
|
71
71
|
|
|
72
|
+
### Listing changed tasks
|
|
73
|
+
|
|
74
|
+
For a Git-managed PEP 723 script that calls `invoke_toolkit.script()`:
|
|
75
|
+
|
|
76
|
+
```console
|
|
77
|
+
uv run tasks.py --list-changed
|
|
78
|
+
uv run tasks.py --list-changed --list-format json
|
|
79
|
+
uv run tasks.py --list
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`--list-changed` lists only new or updated task definitions compared with Git
|
|
83
|
+
`HEAD`, including staged and unstaged edits. Normal flat and nested listings
|
|
84
|
+
also highlight new tasks in green and updated tasks in yellow. Color follows
|
|
85
|
+
Rich's terminal detection and `NO_COLOR`; JSON retains Invoke's existing schema.
|
|
86
|
+
The flag also works with `intk --list-changed` for a loaded task file, and can
|
|
87
|
+
combine with `--list <namespace>`, `--list-tasks`, or `--list-plugins` to narrow
|
|
88
|
+
the listing further.
|
|
89
|
+
|
|
90
|
+
Comparison includes task bodies, signatures, decorators, and docstrings, but
|
|
91
|
+
ignores comments, formatting, and line-number shifts. Imported tasks and
|
|
92
|
+
indirect changes through helpers or globals are not included. Historical source
|
|
93
|
+
is parsed, never executed. In a Git repository, every task in a file absent
|
|
94
|
+
from `HEAD` (including a new repository without commits) counts as new.
|
|
95
|
+
Adding a task decorator to a helper counts as new; changing the decorator's
|
|
96
|
+
explicit task name counts as an update to that existing definition.
|
|
97
|
+
|
|
98
|
+
With no changes, the flag exits successfully with an empty JSON task list or a
|
|
99
|
+
message for human-readable formats. Outside a Git repository, or without Git,
|
|
100
|
+
`--list-changed` reports an error; normal listing still works without highlights.
|
|
101
|
+
|
|
102
|
+
|
|
72
103
|
### Using Task Caching
|
|
73
104
|
|
|
74
105
|
Cache expensive task results with the `cache` parameter:
|
|
@@ -201,6 +232,21 @@ do not update invoke-toolkit itself.
|
|
|
201
232
|
Shell completion suggests directly installed plugin names for `plugin.remove`
|
|
202
233
|
and named `plugin.update` operations.
|
|
203
234
|
|
|
235
|
+
To reduce shell-completion latency in environments with expensive collection
|
|
236
|
+
plugins, set `completion.disable_plugins: true` in `invoke.yaml`:
|
|
237
|
+
|
|
238
|
+
```yaml
|
|
239
|
+
completion:
|
|
240
|
+
disable_plugins: true
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
`INVOKE_COMPLETION_DISABLE_PLUGINS=1` enables the same behavior without changing
|
|
244
|
+
the configuration file. Completion then skips installed
|
|
245
|
+
`invoke_toolkit.collection` entry points while retaining project, local, and
|
|
246
|
+
built-in `-x` task suggestions. These settings affect completion only; normal
|
|
247
|
+
task execution and listing still load plugins.
|
|
248
|
+
|
|
249
|
+
|
|
204
250
|
|
|
205
251
|
These commands reject `uvx`, `uv run`, project environments, and installations
|
|
206
252
|
managed by another tool. pipx offers a similar manual workflow:
|
|
@@ -101,6 +101,7 @@ class ToolkitConfig(Config):
|
|
|
101
101
|
ret["init_shell"] = False
|
|
102
102
|
ret["completion"] = {
|
|
103
103
|
"callback_timeout": 10.0, # Timeout in seconds for completion callbacks
|
|
104
|
+
"disable_plugins": False, # Skip entry-point plugins during completion
|
|
104
105
|
}
|
|
105
106
|
ret["fuzzy_finder"] = {
|
|
106
107
|
"show_warnings": True, # Show warning when fzf is not available
|
{invoke_toolkit-0.0.73 → invoke_toolkit-0.0.75}/src/invoke_toolkit/extensions/tasks/create.py
RENAMED
|
@@ -19,16 +19,23 @@ import invoke_toolkit
|
|
|
19
19
|
from invoke_toolkit import Context, __version__, task
|
|
20
20
|
from invoke_toolkit.loader.entrypoint import COLLECTION_ENTRY_POINT, PLUGIN_PREFIX
|
|
21
21
|
|
|
22
|
-
try:
|
|
23
|
-
from copier import run_copy
|
|
24
|
-
except ImportError:
|
|
25
|
-
run_copy = None # type: ignore[assignment]
|
|
26
|
-
|
|
27
22
|
|
|
28
23
|
# Git config key for custom template repository/path
|
|
29
24
|
GIT_CONFIG_TEMPLATE_KEY = "invoke-toolkit.package-template"
|
|
30
25
|
|
|
31
26
|
|
|
27
|
+
def _load_copier(ctx: Context):
|
|
28
|
+
"""Load Copier only when package generation needs it."""
|
|
29
|
+
try:
|
|
30
|
+
from copier import run_copy # pylint: disable=import-outside-toplevel
|
|
31
|
+
except ImportError:
|
|
32
|
+
ctx.rich_exit(
|
|
33
|
+
"copier is required to create packages. "
|
|
34
|
+
"Install it with: uv pip install invoke-toolkit[copier]"
|
|
35
|
+
)
|
|
36
|
+
return run_copy
|
|
37
|
+
|
|
38
|
+
|
|
32
39
|
def _get_git_config_value(key: str) -> str | None:
|
|
33
40
|
"""
|
|
34
41
|
Get a value from git config.
|
|
@@ -272,11 +279,7 @@ def package(
|
|
|
272
279
|
Provider packages contain only a field-resolver entry point and never expose
|
|
273
280
|
invoke-toolkit task collections.
|
|
274
281
|
"""
|
|
275
|
-
|
|
276
|
-
ctx.rich_exit(
|
|
277
|
-
"copier is required to create packages. "
|
|
278
|
-
"Install it with: uv pip install invoke-toolkit[copier]"
|
|
279
|
-
)
|
|
282
|
+
run_copy = _load_copier(ctx)
|
|
280
283
|
|
|
281
284
|
if provider and (name or ext_name or template):
|
|
282
285
|
ctx.rich_exit(
|
|
@@ -21,6 +21,7 @@ from pathlib import Path
|
|
|
21
21
|
from typing import Any, Literal
|
|
22
22
|
|
|
23
23
|
from rich.table import Table
|
|
24
|
+
from rich.markup import escape
|
|
24
25
|
|
|
25
26
|
from invoke_toolkit.log.logger import setup_rich_logging, setup_traceback_handler
|
|
26
27
|
from invoke_toolkit.output import get_console
|
|
@@ -56,6 +57,7 @@ from invoke_toolkit.config import ToolkitConfig
|
|
|
56
57
|
from invoke_toolkit.executor import ToolkitExecutor
|
|
57
58
|
from invoke_toolkit.loader.entrypoint import EntryPointLoader
|
|
58
59
|
from invoke_toolkit.parser import ToolkitArgument
|
|
60
|
+
from invoke_toolkit.program.task_changes import Change, filter_changed, task_changes
|
|
59
61
|
|
|
60
62
|
EMPTY_COLLECTION_NAME = "_empty"
|
|
61
63
|
|
|
@@ -69,7 +71,7 @@ def _task_bodies(items: Sequence[Any]) -> Iterator[Any]:
|
|
|
69
71
|
yield item.body
|
|
70
72
|
|
|
71
73
|
|
|
72
|
-
class ToolkitProgram(Program):
|
|
74
|
+
class ToolkitProgram(Program): # pylint: disable=too-many-instance-attributes
|
|
73
75
|
"""Invoke Toolkit program providing rich output, package versioning and other features"""
|
|
74
76
|
|
|
75
77
|
def __init__(
|
|
@@ -96,6 +98,8 @@ class ToolkitProgram(Program):
|
|
|
96
98
|
# Names of sub-collections that were loaded from entry-point plugins.
|
|
97
99
|
# Populated in load_collection(); used by --list-tasks / --list-plugins.
|
|
98
100
|
self._plugin_collection_names: set[str] = set()
|
|
101
|
+
self._task_source: Path | None = None
|
|
102
|
+
self._task_changes: dict[str, Change] = {}
|
|
99
103
|
|
|
100
104
|
def get_version(self) -> str:
|
|
101
105
|
"""Compute version
|
|
@@ -456,19 +460,26 @@ class ToolkitProgram(Program):
|
|
|
456
460
|
default=False,
|
|
457
461
|
help="List only the plugin-provided task collections (excludes main tasks)",
|
|
458
462
|
),
|
|
463
|
+
ToolkitArgument(
|
|
464
|
+
names=("list-changed",),
|
|
465
|
+
kind=bool,
|
|
466
|
+
default=False,
|
|
467
|
+
help="List only tasks created or updated in the task file since Git HEAD",
|
|
468
|
+
),
|
|
459
469
|
]
|
|
460
470
|
args.extend(toolkit_program_arguments)
|
|
461
471
|
return args
|
|
462
472
|
|
|
463
473
|
def _handle_list_flags(self) -> None:
|
|
464
474
|
"""
|
|
465
|
-
Handle --list, --list-tasks, and --list-
|
|
475
|
+
Handle --list, --list-tasks, --list-plugins and --list-changed flags.
|
|
466
476
|
|
|
467
477
|
Sets ``list_format`` / ``list_depth`` / ``scoped_collection`` as needed
|
|
468
478
|
and raises `Exit` when any listing flag is active.
|
|
469
479
|
"""
|
|
470
480
|
self.list_format = self.args["list-format"].value
|
|
471
481
|
self.list_depth = self.args["list-depth"].value
|
|
482
|
+
self._task_changes = {}
|
|
472
483
|
|
|
473
484
|
# --list [root]: standard task listing (optionally scoped to a sub-collection)
|
|
474
485
|
list_root = self.args.list.value # True or a string namespace
|
|
@@ -500,6 +511,48 @@ class ToolkitProgram(Program):
|
|
|
500
511
|
self.list_tasks()
|
|
501
512
|
raise Exit
|
|
502
513
|
|
|
514
|
+
if self.args["list-changed"].value:
|
|
515
|
+
self.list_tasks()
|
|
516
|
+
raise Exit
|
|
517
|
+
|
|
518
|
+
def list_tasks(self) -> None:
|
|
519
|
+
"""Highlight source changes and optionally restrict the listing to them."""
|
|
520
|
+
only_changed = self.args["list-changed"].value
|
|
521
|
+
source = self._task_source
|
|
522
|
+
if source is None:
|
|
523
|
+
if only_changed:
|
|
524
|
+
raise Exit("--list-changed requires a task source file.", code=1)
|
|
525
|
+
elif only_changed or self.list_format != "json":
|
|
526
|
+
try:
|
|
527
|
+
self._task_changes = task_changes(self.scoped_collection, source)
|
|
528
|
+
except Exit:
|
|
529
|
+
if only_changed:
|
|
530
|
+
raise
|
|
531
|
+
if only_changed:
|
|
532
|
+
self.scoped_collection = filter_changed(
|
|
533
|
+
self.scoped_collection, self._task_changes
|
|
534
|
+
)
|
|
535
|
+
if not self.scoped_collection:
|
|
536
|
+
if self.list_format == "json":
|
|
537
|
+
self.list_json()
|
|
538
|
+
else:
|
|
539
|
+
get_console("out").print("No new or updated tasks since Git HEAD.")
|
|
540
|
+
return
|
|
541
|
+
super().list_tasks()
|
|
542
|
+
|
|
543
|
+
def _make_pairs(self, coll, ancestors=None):
|
|
544
|
+
"""Style task rows while leaving Invoke's namespace formatting intact."""
|
|
545
|
+
pairs = super()._make_pairs(coll, ancestors)
|
|
546
|
+
prefix = ".".join(ancestors or [])
|
|
547
|
+
for index, name in enumerate(sorted(coll.tasks)):
|
|
548
|
+
qualified = f"{prefix}.{name}" if prefix else name
|
|
549
|
+
change = self._task_changes.get(qualified)
|
|
550
|
+
if change:
|
|
551
|
+
label, description = pairs[index]
|
|
552
|
+
style = "bold green" if change == "new" else "bold yellow"
|
|
553
|
+
pairs[index] = (f"[{style}]{escape(label)}[/{style}]", description)
|
|
554
|
+
return pairs
|
|
555
|
+
|
|
503
556
|
def _make_filtered_collection(
|
|
504
557
|
self, mode: "Literal['tasks', 'plugins']"
|
|
505
558
|
) -> "ToolkitCollection":
|
|
@@ -580,6 +633,7 @@ class ToolkitProgram(Program):
|
|
|
580
633
|
|
|
581
634
|
Ensures that the type is ToolkitCollection for correctness.
|
|
582
635
|
"""
|
|
636
|
+
self._task_source = None
|
|
583
637
|
# NOTE: start, coll_name both fall back to configuration values within
|
|
584
638
|
# Loader (which may, however, get them from our config.)
|
|
585
639
|
start = self.args["search-root"].value
|
|
@@ -592,6 +646,8 @@ class ToolkitProgram(Program):
|
|
|
592
646
|
coll_name = self.args.collection.value
|
|
593
647
|
try:
|
|
594
648
|
module, parent = loader.load(coll_name)
|
|
649
|
+
if getattr(module, "__file__", None):
|
|
650
|
+
self._task_source = Path(module.__file__)
|
|
595
651
|
# This is the earliest we can load project config, so we should -
|
|
596
652
|
# allows project config to affect the task parsing step!
|
|
597
653
|
# TODO: is it worth merging these set- and load- methods? May
|
|
@@ -605,17 +661,29 @@ class ToolkitProgram(Program):
|
|
|
605
661
|
)
|
|
606
662
|
# Load local tasks if they exist
|
|
607
663
|
self.collection.load_local_tasks(search_path=parent)
|
|
608
|
-
# Also try to load entry points (merge with tasks.py)
|
|
609
|
-
|
|
610
|
-
if
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
664
|
+
# Also try to load entry points (merge with tasks.py), unless the
|
|
665
|
+
# user opted out of plugin discovery for latency-sensitive completion.
|
|
666
|
+
if not self._completion_plugins_disabled():
|
|
667
|
+
ep_collection = self._load_entry_points_collection(parent)
|
|
668
|
+
if ep_collection is not None:
|
|
669
|
+
debug("Merging entry point collections with tasks.py")
|
|
670
|
+
for name, collection in ep_collection.collections.items():
|
|
671
|
+
self.collection.add_collection(collection, name=name)
|
|
672
|
+
self._plugin_collection_names.add(name)
|
|
615
673
|
except CollectionNotFound as e:
|
|
616
|
-
start =
|
|
617
|
-
#
|
|
618
|
-
|
|
674
|
+
start = start or "."
|
|
675
|
+
# A missing tasks.py cannot provide the project location, so load
|
|
676
|
+
# configuration from the resolved search root before deciding
|
|
677
|
+
# whether completion should discover entry-point plugins.
|
|
678
|
+
self.config.set_project_location(start)
|
|
679
|
+
self.config.load_project()
|
|
680
|
+
# First try entry points for packages without tasks.py. Completion
|
|
681
|
+
# may explicitly skip this potentially expensive plugin discovery.
|
|
682
|
+
ep_collection = (
|
|
683
|
+
None
|
|
684
|
+
if self._completion_plugins_disabled()
|
|
685
|
+
else self._load_entry_points_collection(start)
|
|
686
|
+
)
|
|
619
687
|
if ep_collection is not None:
|
|
620
688
|
debug("Loading collections from entry points")
|
|
621
689
|
self.collection = ep_collection
|
|
@@ -643,9 +711,6 @@ class ToolkitProgram(Program):
|
|
|
643
711
|
debug("No collection found, will checking for internal")
|
|
644
712
|
else:
|
|
645
713
|
debug("No tasks.py found, but local_tasks.py exists, continuing...")
|
|
646
|
-
start = self.args["search-root"].value
|
|
647
|
-
self.config.set_project_location(start)
|
|
648
|
-
self.config.load_project()
|
|
649
714
|
self.collection = ToolkitCollection(EMPTY_COLLECTION_NAME)
|
|
650
715
|
# Try to load local tasks if they exist
|
|
651
716
|
self.collection.load_local_tasks(search_path=start)
|
|
@@ -668,6 +733,15 @@ class ToolkitProgram(Program):
|
|
|
668
733
|
"""Flat arguments"""
|
|
669
734
|
return {name: arg.value for name, arg in self.args.items()}
|
|
670
735
|
|
|
736
|
+
def _completion_plugins_disabled(self) -> bool:
|
|
737
|
+
"""Return whether this completion request excludes entry-point plugins."""
|
|
738
|
+
if not self.args.complete.value:
|
|
739
|
+
return False
|
|
740
|
+
return bool(
|
|
741
|
+
self.config.completion.disable_plugins
|
|
742
|
+
or env_enabled(os.getenv("INVOKE_COMPLETION_DISABLE_PLUGINS", "0"))
|
|
743
|
+
)
|
|
744
|
+
|
|
671
745
|
def _has_internal_col_flag_in_completion(self) -> bool:
|
|
672
746
|
"""
|
|
673
747
|
Check if -x or --internal-col flag is present in the completion context.
|
|
@@ -771,6 +845,10 @@ class ToolkitProgram(Program):
|
|
|
771
845
|
print = get_console("out").print
|
|
772
846
|
root = self.list_root
|
|
773
847
|
print(f"{self.task_list_opener(extra=extra)}:\n")
|
|
848
|
+
if self._task_changes:
|
|
849
|
+
print(
|
|
850
|
+
"[bold green]new[/bold green] / [bold yellow]updated[/bold yellow] since Git HEAD\n"
|
|
851
|
+
)
|
|
774
852
|
self.print_columns(pairs)
|
|
775
853
|
# TODO: worth stripping this out for nested? since it's signified with
|
|
776
854
|
# asterisk there? ugggh
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"""Compare loaded task definitions with their Git HEAD source, without executing it."""
|
|
2
|
+
|
|
3
|
+
import ast
|
|
4
|
+
import inspect
|
|
5
|
+
import os
|
|
6
|
+
import subprocess
|
|
7
|
+
from collections.abc import Iterator
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Literal
|
|
10
|
+
|
|
11
|
+
from invoke.collection import Collection
|
|
12
|
+
from invoke.exceptions import Exit
|
|
13
|
+
|
|
14
|
+
Change = Literal["new", "updated"]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _git(path: Path, *args: str) -> subprocess.CompletedProcess[bytes]:
|
|
18
|
+
try:
|
|
19
|
+
return subprocess.run(
|
|
20
|
+
["git", "-C", str(path.parent), *args], capture_output=True, check=False
|
|
21
|
+
)
|
|
22
|
+
except OSError as error:
|
|
23
|
+
raise Exit("Git is required for --list-changed.", code=1) from error
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _head_source(path: Path) -> bytes:
|
|
27
|
+
root = _git(path, "rev-parse", "--show-toplevel")
|
|
28
|
+
if root.returncode:
|
|
29
|
+
raise Exit("--list-changed requires a task file in a Git repository.", code=1)
|
|
30
|
+
relative = path.relative_to(Path(os.fsdecode(root.stdout).rstrip("\n")).resolve())
|
|
31
|
+
if _git(path, "rev-parse", "--verify", "--quiet", "HEAD").returncode:
|
|
32
|
+
return b""
|
|
33
|
+
tree = _git(
|
|
34
|
+
path,
|
|
35
|
+
"ls-tree",
|
|
36
|
+
"--full-tree",
|
|
37
|
+
"-z",
|
|
38
|
+
"HEAD",
|
|
39
|
+
"--",
|
|
40
|
+
f":(literal){relative.as_posix()}",
|
|
41
|
+
)
|
|
42
|
+
if tree.returncode:
|
|
43
|
+
raise Exit("Unable to read task file history from Git HEAD.", code=1)
|
|
44
|
+
if not tree.stdout:
|
|
45
|
+
return b""
|
|
46
|
+
source = _git(path, "show", f"HEAD:{relative.as_posix()}")
|
|
47
|
+
if source.returncode:
|
|
48
|
+
raise Exit("Unable to read task file from Git HEAD.", code=1)
|
|
49
|
+
return source.stdout
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _module_functions(
|
|
53
|
+
node: ast.AST,
|
|
54
|
+
) -> Iterator[ast.FunctionDef | ast.AsyncFunctionDef]:
|
|
55
|
+
"""Find module-scope functions, including control flow but excluding nested scopes."""
|
|
56
|
+
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
57
|
+
yield node
|
|
58
|
+
elif not isinstance(node, (ast.ClassDef, ast.Lambda)):
|
|
59
|
+
for child in ast.iter_child_nodes(node):
|
|
60
|
+
yield from _module_functions(child)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _task_decorated(
|
|
64
|
+
node: ast.FunctionDef | ast.AsyncFunctionDef, tree: ast.Module
|
|
65
|
+
) -> bool:
|
|
66
|
+
"""Recognize task decorators, including imported aliases, without execution."""
|
|
67
|
+
names = {"task"}
|
|
68
|
+
for item in ast.walk(tree):
|
|
69
|
+
if isinstance(item, ast.ImportFrom) and item.module in {
|
|
70
|
+
"invoke_toolkit",
|
|
71
|
+
"invoke",
|
|
72
|
+
"invoke.tasks",
|
|
73
|
+
"invoke_toolkit.tasks",
|
|
74
|
+
}:
|
|
75
|
+
names.update(
|
|
76
|
+
alias.asname or alias.name
|
|
77
|
+
for alias in item.names
|
|
78
|
+
if alias.name == "task"
|
|
79
|
+
)
|
|
80
|
+
for decorator in node.decorator_list:
|
|
81
|
+
target = decorator.func if isinstance(decorator, ast.Call) else decorator
|
|
82
|
+
if isinstance(target, ast.Name) and target.id in names:
|
|
83
|
+
return True
|
|
84
|
+
if isinstance(target, ast.Attribute) and target.attr == "task":
|
|
85
|
+
return True
|
|
86
|
+
pending: list[ast.AST] = []
|
|
87
|
+
pending.extend(tree.body)
|
|
88
|
+
while pending:
|
|
89
|
+
item = pending.pop()
|
|
90
|
+
if isinstance(item, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
|
|
91
|
+
continue
|
|
92
|
+
if isinstance(item, (ast.Assign, ast.AnnAssign)) and isinstance(
|
|
93
|
+
item.value, ast.Call
|
|
94
|
+
):
|
|
95
|
+
call = item.value
|
|
96
|
+
if any(
|
|
97
|
+
isinstance(arg, ast.Name) and arg.id == node.name for arg in call.args
|
|
98
|
+
):
|
|
99
|
+
target = (
|
|
100
|
+
call.func.func if isinstance(call.func, ast.Call) else call.func
|
|
101
|
+
)
|
|
102
|
+
if isinstance(target, ast.Name) and target.id in names:
|
|
103
|
+
return True
|
|
104
|
+
if isinstance(target, ast.Attribute) and target.attr == "task":
|
|
105
|
+
return True
|
|
106
|
+
pending.extend(ast.iter_child_nodes(item))
|
|
107
|
+
return False
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def task_changes(collection: Collection, source_path: Path) -> dict[str, Change]: # pylint: disable=too-many-locals
|
|
111
|
+
"""Return canonical task paths changed in the source file since HEAD.
|
|
112
|
+
|
|
113
|
+
Only the task's own definition is compared; imported tasks and indirect
|
|
114
|
+
changes to helpers or globals are outside this comparison.
|
|
115
|
+
"""
|
|
116
|
+
path = source_path.resolve()
|
|
117
|
+
try:
|
|
118
|
+
current = ast.parse(path.read_bytes(), filename=str(path))
|
|
119
|
+
previous = ast.parse(_head_source(path), filename=f"HEAD:{path.name}")
|
|
120
|
+
except (OSError, SyntaxError, ValueError) as error:
|
|
121
|
+
raise Exit(
|
|
122
|
+
"Unable to compare task definitions with Git HEAD.", code=1
|
|
123
|
+
) from error
|
|
124
|
+
old: dict[str, list[ast.FunctionDef | ast.AsyncFunctionDef]] = {}
|
|
125
|
+
for node in _module_functions(previous):
|
|
126
|
+
old.setdefault(node.name, []).append(node)
|
|
127
|
+
current_nodes = list(_module_functions(current))
|
|
128
|
+
occurrences: dict[str, int] = {}
|
|
129
|
+
definitions = {}
|
|
130
|
+
for node in current_nodes:
|
|
131
|
+
occurrence = occurrences.get(node.name, 0)
|
|
132
|
+
occurrences[node.name] = occurrence + 1
|
|
133
|
+
line = min([node.lineno, *(d.lineno for d in node.decorator_list)])
|
|
134
|
+
definitions[(node.name, line)] = (node, occurrence)
|
|
135
|
+
changes: dict[str, Change] = {}
|
|
136
|
+
for name in collection.task_names:
|
|
137
|
+
body = inspect.unwrap(collection[name].body)
|
|
138
|
+
code = getattr(body, "__code__", None)
|
|
139
|
+
if code is None or Path(code.co_filename).resolve() != path:
|
|
140
|
+
continue
|
|
141
|
+
definition = definitions.get((body.__name__, code.co_firstlineno))
|
|
142
|
+
if definition is None:
|
|
143
|
+
continue
|
|
144
|
+
node, occurrence = definition
|
|
145
|
+
candidates = old.get(node.name, [])
|
|
146
|
+
historical = candidates[occurrence] if occurrence < len(candidates) else None
|
|
147
|
+
if historical is None or (
|
|
148
|
+
_task_decorated(node, current) and not _task_decorated(historical, previous)
|
|
149
|
+
):
|
|
150
|
+
changes[name] = "new"
|
|
151
|
+
elif ast.dump(node) != ast.dump(historical):
|
|
152
|
+
changes[name] = "updated"
|
|
153
|
+
return changes
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def filter_changed(
|
|
157
|
+
collection: Collection, changes: dict[str, Change], prefix: str = ""
|
|
158
|
+
) -> Collection:
|
|
159
|
+
"""Copy the listing tree, retaining changed tasks, aliases and defaults."""
|
|
160
|
+
filtered = Collection(
|
|
161
|
+
collection.name or "", auto_dash_names=collection.auto_dash_names
|
|
162
|
+
)
|
|
163
|
+
for name, task in collection.tasks.items():
|
|
164
|
+
if prefix + name in changes:
|
|
165
|
+
filtered.add_task(
|
|
166
|
+
task,
|
|
167
|
+
name=name,
|
|
168
|
+
aliases=tuple(collection.tasks.aliases_of(name)),
|
|
169
|
+
default=False,
|
|
170
|
+
)
|
|
171
|
+
for name, child in collection.collections.items():
|
|
172
|
+
selected = filter_changed(child, changes, prefix + name + ".")
|
|
173
|
+
if selected:
|
|
174
|
+
filtered.add_collection(selected, name=name)
|
|
175
|
+
for alias in collection.collections.aliases_of(name):
|
|
176
|
+
filtered.collections.alias(alias, to=name)
|
|
177
|
+
filtered.__doc__ = collection.__doc__
|
|
178
|
+
filtered.default = (
|
|
179
|
+
collection.default
|
|
180
|
+
if collection.default in filtered.tasks
|
|
181
|
+
or collection.default in filtered.collections
|
|
182
|
+
else None
|
|
183
|
+
)
|
|
184
|
+
return filtered
|
|
@@ -4,6 +4,7 @@ Run scripts with https://peps.python.org/pep-0723/
|
|
|
4
4
|
|
|
5
5
|
import inspect
|
|
6
6
|
import traceback
|
|
7
|
+
from pathlib import Path
|
|
7
8
|
from types import FrameType
|
|
8
9
|
|
|
9
10
|
from invoke.tasks import Task
|
|
@@ -98,4 +99,5 @@ def script(
|
|
|
98
99
|
p = ToolkitProgram(namespace=c, config_class=CustomConfig)
|
|
99
100
|
else:
|
|
100
101
|
p = ToolkitProgram(namespace=c)
|
|
102
|
+
p._task_source = Path(frame.f_code.co_filename) # pylint: disable=protected-access
|
|
101
103
|
return p.run(argv=argv, exit=exit)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
+
import builtins
|
|
2
3
|
import subprocess
|
|
3
4
|
import typing
|
|
4
5
|
from pathlib import Path
|
|
@@ -11,6 +12,7 @@ from invoke_toolkit.context.context import ToolkitContext
|
|
|
11
12
|
from invoke_toolkit.extensions.tasks.create import (
|
|
12
13
|
GIT_CONFIG_TEMPLATE_KEY,
|
|
13
14
|
_get_git_config_value,
|
|
15
|
+
_load_copier,
|
|
14
16
|
)
|
|
15
17
|
from invoke_toolkit.testing import TestingToolkitProgram
|
|
16
18
|
|
|
@@ -18,6 +20,20 @@ if typing.TYPE_CHECKING:
|
|
|
18
20
|
from tests.conftest import ShellRunTmp, TempVenv
|
|
19
21
|
|
|
20
22
|
|
|
23
|
+
def test_load_copier_exits_when_optional_dependency_is_missing(monkeypatch, ctx):
|
|
24
|
+
real_import = builtins.__import__
|
|
25
|
+
|
|
26
|
+
def import_without_copier(name, *args, **kwargs):
|
|
27
|
+
if name == "copier":
|
|
28
|
+
raise ImportError("copier unavailable")
|
|
29
|
+
return real_import(name, *args, **kwargs)
|
|
30
|
+
|
|
31
|
+
monkeypatch.setattr(builtins, "__import__", import_without_copier)
|
|
32
|
+
|
|
33
|
+
with pytest.raises(SystemExit):
|
|
34
|
+
_load_copier(ctx)
|
|
35
|
+
|
|
36
|
+
|
|
21
37
|
def test_new_script_has_hello_world_task(
|
|
22
38
|
tmp_path: Path,
|
|
23
39
|
monkeypatch: pytest.MonkeyPatch,
|