django-spec-cli 0.2.1__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/.github/workflows/release.yml +1 -1
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/CHANGELOG.md +30 -1
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/CLAUDE.md +1 -1
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/PKG-INFO +3 -3
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/README.md +1 -1
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/exit_code_for.py +3 -2
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/spec_command.py +30 -16
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/types/exit_code.py +1 -1
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/version.py +1 -1
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/docs/index.md +13 -7
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/pyproject.toml +9 -9
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/test_exit_code_for.py +18 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/test_spec_command.py +32 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/uv.lock +8 -8
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/.github/CODEOWNERS +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/.github/SECURITY.md +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/.github/dependabot.yml +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/.github/workflows/tests.yml +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/.github/workflows/upstream-drift.yml +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/.gitignore +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/.pre-commit-config.yaml +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/LICENSE +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/Makefile +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/apps.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/argv/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/argv/add_spec_arguments.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/argv/describe_parameters.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/argv/parameter_descriptor.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/argv/parsed_arguments.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/argv/utils.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/checks.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/py.typed +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/render/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/render/render_json_lines.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/render/render_result.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/render/render_table.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/render/utils.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/render/wants_table.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/report/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/report/unguarded_message.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/settings.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/types/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/docs/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/docs/examples/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/docs/examples/commands.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/docs/reference.md +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/mkdocs.yml +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/scripts/check-changelog +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/scripts/release-publish.sh +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/argv/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/argv/test_add_spec_arguments.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/argv/test_describe_parameters.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/argv/test_parameter_descriptor.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/argv/test_parsed_arguments.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/argv/test_utils.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/argv/utils.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/apps.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/notes.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_bad_parser.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_broken_import.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_broken_init.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_empty.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_no_registry.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_plain.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_report.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/unguarded_registries.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/conftest.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/conftest_settings.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/dispatch_app/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/dispatch_app/apps.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/dispatch_app/models.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/docs/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/docs/test_commands_examples.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/docs/test_reference.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/render/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/render/test_render_json_lines.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/render/test_render_result.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/render/test_render_table.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/render/test_utils.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/render/test_wants_table.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/render/utils.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/report/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/report/test_unguarded_message.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/test_apps.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/test_checks.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/test_init.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/test_settings.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/types/__init__.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/types/test_exit_code.py +0 -0
- {django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/utils.py +0 -0
|
@@ -43,7 +43,7 @@ jobs:
|
|
|
43
43
|
|
|
44
44
|
- name: Publish to PyPI
|
|
45
45
|
if: steps.prepare.outputs.released == 'true'
|
|
46
|
-
uses: pypa/gh-action-pypi-publish@
|
|
46
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
47
47
|
with:
|
|
48
48
|
# Idempotent on purpose. What gates a release is the git tag, not the
|
|
49
49
|
# index (see `prepare`), so re-running this job after a failure in a
|
|
@@ -7,6 +7,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.1] — 2026-11-04
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- **`--help` offers and requires what dispatch asks a caller for.** A
|
|
14
|
+
subcommand's options, and which of them are marked `(required)`, are now
|
|
15
|
+
read from the kernel's `spec_caller_input_schema` under the command's
|
|
16
|
+
`pool_seeds`, rather than from `server_owned_keys` read without them. On any
|
|
17
|
+
kernel from 0.15.0, two parameters were shown wrongly. A read declared
|
|
18
|
+
required beside a provider that may fill it, such as a `kwargs` provider
|
|
19
|
+
whose return names no keys, was marked `(required)`, though a run leaving
|
|
20
|
+
it out was dispatched. A `reflected` read named like a seed the command's
|
|
21
|
+
`pool_seeds` registers was offered as an option and marked `(required)`,
|
|
22
|
+
and passing it was refused as an unknown argument, exit code 3. It is no
|
|
23
|
+
longer an option. No public name changes.
|
|
24
|
+
|
|
25
|
+
## [0.3.0] — 2026-11-04
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
- **The kernel floor is `django-service-specs>=0.24.0`, the first kernel
|
|
29
|
+
release with `PermissionCheckDenied` in `REFUSALS`.** The kernel raises it,
|
|
30
|
+
a subclass of `NotPermitted`, when a permission check the spec declares
|
|
31
|
+
answers `False`. A run it refuses still exits `NOT_PERMITTED`, through the
|
|
32
|
+
`NotPermitted` row, as it did on every earlier kernel, so no exit code
|
|
33
|
+
changes. The test holding the exit codes against the kernel's list now
|
|
34
|
+
decides that refusal's code by name, and the lowest-declared-versions job
|
|
35
|
+
runs the suite on 0.24.0.
|
|
36
|
+
|
|
10
37
|
## [0.2.1] — 2026-10-21
|
|
11
38
|
|
|
12
39
|
### Fixed
|
|
@@ -55,7 +82,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
55
82
|
`django-service-specs>=0.10.0`, the first kernel release with every name the
|
|
56
83
|
command reads at its root.
|
|
57
84
|
|
|
58
|
-
[Unreleased]: https://github.com/Artui/django-spec-cli/compare/v0.
|
|
85
|
+
[Unreleased]: https://github.com/Artui/django-spec-cli/compare/v0.3.1...HEAD
|
|
86
|
+
[0.3.1]: https://github.com/Artui/django-spec-cli/compare/v0.3.0...v0.3.1
|
|
87
|
+
[0.3.0]: https://github.com/Artui/django-spec-cli/compare/v0.2.1...v0.3.0
|
|
59
88
|
[0.2.1]: https://github.com/Artui/django-spec-cli/compare/v0.2.0...v0.2.1
|
|
60
89
|
[0.2.0]: https://github.com/Artui/django-spec-cli/compare/v0.1.0...v0.2.0
|
|
61
90
|
[0.1.0]: https://github.com/Artui/django-spec-cli/compare/v0.0.0...v0.1.0
|
|
@@ -137,7 +137,7 @@ configured and enforced. isort order is stdlib, third party, first party.
|
|
|
137
137
|
| --- | --- | --- |
|
|
138
138
|
| Python | 3.10 | 3.10 through 3.14 |
|
|
139
139
|
| Django | 4.2 | 4.2, 5.0, 5.1, 5.2, 6.0, 6.1 |
|
|
140
|
-
| django-service-specs | 0.
|
|
140
|
+
| django-service-specs | 0.24.0 | the newest release, and the floor in the `floor` job |
|
|
141
141
|
|
|
142
142
|
The Python and Django floors are the kernel's, and cannot sit below them.
|
|
143
143
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: django-spec-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Run a django-service-specs registry from manage.py: one subcommand per spec, options generated from its parameters, exit codes for every refusal.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Artui/django-spec-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/Artui/django-spec-cli
|
|
@@ -30,7 +30,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
30
30
|
Classifier: Programming Language :: Python :: 3.14
|
|
31
31
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
32
32
|
Requires-Python: >=3.10
|
|
33
|
-
Requires-Dist: django-service-specs>=0.
|
|
33
|
+
Requires-Dist: django-service-specs>=0.24.0
|
|
34
34
|
Requires-Dist: django>=4.2
|
|
35
35
|
Description-Content-Type: text/markdown
|
|
36
36
|
|
|
@@ -61,7 +61,7 @@ the import path, the system check ids and the setting key are this package's.
|
|
|
61
61
|
pip install django-spec-cli
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
Python 3.10 or later, Django 4.2 or later, and `django-service-specs` 0.
|
|
64
|
+
Python 3.10 or later, Django 4.2 or later, and `django-service-specs` 0.24.0 or
|
|
65
65
|
later, which it installs.
|
|
66
66
|
|
|
67
67
|
## Quickstart
|
|
@@ -25,7 +25,7 @@ the import path, the system check ids and the setting key are this package's.
|
|
|
25
25
|
pip install django-spec-cli
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
Python 3.10 or later, Django 4.2 or later, and `django-service-specs` 0.
|
|
28
|
+
Python 3.10 or later, Django 4.2 or later, and `django-service-specs` 0.24.0 or
|
|
29
29
|
later, which it installs.
|
|
30
30
|
|
|
31
31
|
## Quickstart
|
|
@@ -28,8 +28,9 @@ _CODES: tuple[tuple[type[Exception], ExitCode], ...] = (
|
|
|
28
28
|
"""Each refusal's code, read top to bottom, first match wins.
|
|
29
29
|
|
|
30
30
|
A subclass sits above its base, or the base's row would answer for it. Only
|
|
31
|
-
rows that change the answer are listed: ``InvalidArguments
|
|
32
|
-
``ActionUnavailable`` take their base's code, so
|
|
31
|
+
rows that change the answer are listed: ``InvalidArguments``,
|
|
32
|
+
``PermissionCheckDenied`` and ``ActionUnavailable`` take their base's code, so
|
|
33
|
+
the base's row is theirs.
|
|
33
34
|
Coverage sees one expression, not eight rows, so each row is held by its own
|
|
34
35
|
case of test_every_refusal_the_kernel_raises_has_its_code."""
|
|
35
36
|
|
|
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import argparse
|
|
6
6
|
import inspect
|
|
7
7
|
from collections.abc import Mapping
|
|
8
|
+
from dataclasses import replace
|
|
8
9
|
from typing import Any, TextIO, cast
|
|
9
10
|
|
|
10
11
|
from django.core.exceptions import ImproperlyConfigured
|
|
@@ -30,9 +31,8 @@ from django_service_specs import (
|
|
|
30
31
|
kernel_spec,
|
|
31
32
|
present,
|
|
32
33
|
refusal_messages,
|
|
33
|
-
relax_partial,
|
|
34
34
|
resolve_principal,
|
|
35
|
-
|
|
35
|
+
spec_caller_input_schema,
|
|
36
36
|
unguarded_specs,
|
|
37
37
|
)
|
|
38
38
|
|
|
@@ -72,8 +72,10 @@ class SpecCommand(BaseCommand):
|
|
|
72
72
|
- **One subcommand per registry entry**, named after the entry with each
|
|
73
73
|
``_`` shown as ``-``. Its options are the spec's parameters, as
|
|
74
74
|
[`add_spec_arguments`][django_spec_cli.argv.add_spec_arguments.add_spec_arguments]
|
|
75
|
-
spells them,
|
|
76
|
-
([`
|
|
75
|
+
spells them, as the input schema a transport advertises asks for them
|
|
76
|
+
([`spec_caller_input_schema`][django_service_specs.schema.spec_caller_input_schema.spec_caller_input_schema]
|
|
77
|
+
under ``pool_seeds``): less any key the server fills, and required only
|
|
78
|
+
where dispatch refuses leaving it out.
|
|
77
79
|
No option is matched by a prefix: an abbreviation is refused rather
|
|
78
80
|
than read as whichever option it begins.
|
|
79
81
|
- **``--as-user`` is required.** Its value goes through
|
|
@@ -162,7 +164,7 @@ class SpecCommand(BaseCommand):
|
|
|
162
164
|
)
|
|
163
165
|
self._entries[name] = entry
|
|
164
166
|
spec = kernel_spec(entry.spec)
|
|
165
|
-
parameters = _sendable(spec)
|
|
167
|
+
parameters = _sendable(spec, self.pool_seeds)
|
|
166
168
|
summary = _summary(spec, entry.name)
|
|
167
169
|
subparser = subparsers.add_parser(
|
|
168
170
|
name,
|
|
@@ -281,18 +283,30 @@ class SpecCommand(BaseCommand):
|
|
|
281
283
|
self.stdout.write(unguarded_message(unguarded, label))
|
|
282
284
|
|
|
283
285
|
|
|
284
|
-
def _sendable(spec: ServiceSpec | SelectorSpec) -> Parameters:
|
|
285
|
-
"""What a caller may send, as the
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
(
|
|
290
|
-
|
|
291
|
-
(
|
|
286
|
+
def _sendable(spec: ServiceSpec | SelectorSpec, pool_seeds: PoolSeeds) -> Parameters:
|
|
287
|
+
"""What a caller may send, as the kernel's caller schema reads it: required only where dispatch demands it.
|
|
288
|
+
|
|
289
|
+
The parameters ``spec_caller_input_schema`` offers under the command's
|
|
290
|
+
``pool_seeds``, so no key the server fills is an option: one a provider
|
|
291
|
+
is annotated to fill (test_a_key_the_server_fills_is_no_option), and a
|
|
292
|
+
reflected read a registered seed fills
|
|
293
|
+
(test_a_reflected_read_a_seed_fills_is_an_option_only_without_the_seed).
|
|
294
|
+
Each is relaxed where the schema does not require it, so ``--help``
|
|
295
|
+
marks ``(required)`` exactly where an omission is refused: on a
|
|
296
|
+
``partial`` spec (test_a_partial_spec_requires_only_what_names_its_row)
|
|
297
|
+
and beside a provider that may fill it
|
|
298
|
+
(test_a_read_a_provider_may_fill_is_offered_and_not_required). Only
|
|
299
|
+
relaxed, never made required, so a declared default still answers.
|
|
292
300
|
"""
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
return Parameters.of(
|
|
301
|
+
schema = spec_caller_input_schema(spec, pool_seeds=pool_seeds)
|
|
302
|
+
required = frozenset(schema.get("required", ()))
|
|
303
|
+
return Parameters.of(
|
|
304
|
+
*(
|
|
305
|
+
param if param.name in required else replace(param, required=False)
|
|
306
|
+
for param in spec.parameters()
|
|
307
|
+
if param.name in schema["properties"]
|
|
308
|
+
)
|
|
309
|
+
)
|
|
296
310
|
|
|
297
311
|
|
|
298
312
|
def _summary(spec: ServiceSpec | SelectorSpec, name: str) -> str:
|
|
@@ -18,7 +18,7 @@ class ExitCode(IntEnum):
|
|
|
18
18
|
| 1 | `ERROR` | failed in a way nobody declared | anything else, with a traceback |
|
|
19
19
|
| 2 | `USAGE` | never started: the command line was malformed | argparse's own refusals |
|
|
20
20
|
| 3 | `INVALID_ARGUMENTS` | was refused its arguments | `InvalidArguments`, `ServiceValidationError`, any other `DispatchError` |
|
|
21
|
-
| 4 | `NOT_PERMITTED` | was refused to the principal | `NotPermitted` |
|
|
21
|
+
| 4 | `NOT_PERMITTED` | was refused to the principal | `NotPermitted`, `PermissionCheckDenied` |
|
|
22
22
|
| 5 | `PRINCIPAL_UNAVAILABLE` | had nobody to run as | `PrincipalUnavailable` |
|
|
23
23
|
| 6 | `NOT_FOUND` | found no row to act on | a `not_found` result, `ServiceNotFound` |
|
|
24
24
|
| 7 | `CONFLICT` | was refused by the row's current state | `ServiceConflict`, `ActionUnavailable` |
|
|
@@ -27,7 +27,7 @@ pip install django-spec-cli
|
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
It installs [`django-service-specs`](https://artui.github.io/django-service-specs/), the kernel whose specs it serves,
|
|
30
|
-
from 0.
|
|
30
|
+
from 0.24.0, on Python 3.10 and Django 4.2 or later. The command line was the
|
|
31
31
|
kernel's `commands/` subpackage, and moved here so the kernel carries no
|
|
32
32
|
transport.
|
|
33
33
|
|
|
@@ -86,14 +86,20 @@ equals sign: `--tag=-x`.
|
|
|
86
86
|
of its service's or selector's docstring and whether it reads or writes, or
|
|
87
87
|
its registered name when the function says nothing. `manage.py notes
|
|
88
88
|
rename-note --help` lists its options, with `(required)` where leaving one
|
|
89
|
-
out is refused.
|
|
90
|
-
|
|
89
|
+
out is refused. Both are read from the input schema a transport advertises,
|
|
90
|
+
[`spec_caller_input_schema`][django_service_specs.schema.spec_caller_input_schema.spec_caller_input_schema],
|
|
91
|
+
under the command's `pool_seeds`, so the command asks for what dispatch asks
|
|
92
|
+
for. On a `partial` spec, `(required)` is only what names the row: the
|
|
93
|
+
Validator's fields may be left out, as dispatch allows. A parameter a provider
|
|
94
|
+
may fill, such as a read beside a `kwargs` provider whose return names no keys,
|
|
95
|
+
is an option and is not required.
|
|
91
96
|
|
|
92
97
|
Some parameters have no option:
|
|
93
98
|
|
|
94
|
-
- **A key the server fills
|
|
95
|
-
|
|
96
|
-
since
|
|
99
|
+
- **A key the server fills**: one a `kwargs` provider is annotated to answer,
|
|
100
|
+
since a value sent for it would be dropped, and a `reflected` read named like
|
|
101
|
+
a seed `pool_seeds` registers, since the seed fills it and dispatch refuses an
|
|
102
|
+
argument of its name.
|
|
97
103
|
- **A parameter with no flat spelling**: an object, an array of objects or of
|
|
98
104
|
arrays, and a file. The subcommand's help names them. A spec that requires
|
|
99
105
|
one, such as any `many` spec, cannot be run from the command line.
|
|
@@ -184,7 +190,7 @@ branch on:
|
|
|
184
190
|
| 1 | `ERROR` | failed in a way nobody declared: the traceback is printed |
|
|
185
191
|
| 2 | `USAGE` | never started: the command line was malformed |
|
|
186
192
|
| 3 | `INVALID_ARGUMENTS` | `InvalidArguments`, `ServiceValidationError`, any other `DispatchError` |
|
|
187
|
-
| 4 | `NOT_PERMITTED` | `NotPermitted` |
|
|
193
|
+
| 4 | `NOT_PERMITTED` | `NotPermitted`, and `PermissionCheckDenied`, a declared check's denial |
|
|
188
194
|
| 5 | `PRINCIPAL_UNAVAILABLE` | `PrincipalUnavailable`: no such user, or a deactivated one |
|
|
189
195
|
| 6 | `NOT_FOUND` | the row named does not exist, or the service raised `ServiceNotFound` |
|
|
190
196
|
| 7 | `CONFLICT` | `ServiceConflict`, and `ActionUnavailable` with its code in the message |
|
|
@@ -40,14 +40,14 @@ dependencies = [
|
|
|
40
40
|
# kernel's specs, so this package cannot support a Django the kernel does
|
|
41
41
|
# not.
|
|
42
42
|
"django>=4.2",
|
|
43
|
-
# The first kernel release
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
"django-service-specs>=0.
|
|
43
|
+
# The first kernel release with ``PermissionCheckDenied`` in ``REFUSALS``.
|
|
44
|
+
# ``tests/test_exit_code_for.py`` holds the exit codes against that list
|
|
45
|
+
# and decides the new refusal's code by name, so the suite, and the floor
|
|
46
|
+
# job running it, cannot import below 0.24.0. The code itself is
|
|
47
|
+
# ``NotPermitted``'s on every kernel. Below 0.11.0 the kernel also still
|
|
48
|
+
# shipped its own copy of the command and registered its own ``W001`` and
|
|
49
|
+
# ``W003``.
|
|
50
|
+
"django-service-specs>=0.24.0",
|
|
51
51
|
]
|
|
52
52
|
|
|
53
53
|
[project.urls]
|
|
@@ -147,7 +147,7 @@ skip-magic-trailing-comma = false
|
|
|
147
147
|
root = ["./django_spec_cli"]
|
|
148
148
|
|
|
149
149
|
[tool.bumpversion]
|
|
150
|
-
current_version = "0.
|
|
150
|
+
current_version = "0.3.1"
|
|
151
151
|
allow_dirty = false
|
|
152
152
|
commit = false
|
|
153
153
|
tag = false
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
3
5
|
from django_service_specs import (
|
|
4
6
|
REFUSALS,
|
|
5
7
|
ActionUnavailable,
|
|
@@ -7,7 +9,11 @@ from django_service_specs import (
|
|
|
7
9
|
DispatchError,
|
|
8
10
|
InvalidArguments,
|
|
9
11
|
NotPermitted,
|
|
12
|
+
PermissionCheck,
|
|
13
|
+
PermissionCheckDenied,
|
|
10
14
|
PrincipalUnavailable,
|
|
15
|
+
SelectorKind,
|
|
16
|
+
SelectorSpec,
|
|
11
17
|
ServiceConflict,
|
|
12
18
|
ServiceError,
|
|
13
19
|
ServiceNotFound,
|
|
@@ -22,6 +28,7 @@ EXPECTED: dict[type[Exception], ExitCode] = {
|
|
|
22
28
|
DispatchError: ExitCode.INVALID_ARGUMENTS,
|
|
23
29
|
InvalidArguments: ExitCode.INVALID_ARGUMENTS,
|
|
24
30
|
NotPermitted: ExitCode.NOT_PERMITTED,
|
|
31
|
+
PermissionCheckDenied: ExitCode.NOT_PERMITTED,
|
|
25
32
|
PrincipalUnavailable: ExitCode.PRINCIPAL_UNAVAILABLE,
|
|
26
33
|
ServiceError: ExitCode.REFUSED,
|
|
27
34
|
ServiceValidationError: ExitCode.INVALID_ARGUMENTS,
|
|
@@ -33,9 +40,20 @@ EXPECTED: dict[type[Exception], ExitCode] = {
|
|
|
33
40
|
"""Every refusal the kernel raises, and its code, decided one by one."""
|
|
34
41
|
|
|
35
42
|
|
|
43
|
+
class _Denies(PermissionCheck):
|
|
44
|
+
def has_permission(self, principal: Any, spec: Any) -> bool:
|
|
45
|
+
return False
|
|
46
|
+
|
|
47
|
+
|
|
36
48
|
def _instance(kind: type[Exception]) -> Exception:
|
|
37
49
|
if kind is InvalidArguments:
|
|
38
50
|
return InvalidArguments({"title": ["Required."]})
|
|
51
|
+
if kind is PermissionCheckDenied:
|
|
52
|
+
# Built as ``authorize`` raises it: the check that answered and the
|
|
53
|
+
# spec declaring it.
|
|
54
|
+
check = _Denies()
|
|
55
|
+
spec = SelectorSpec(kind=SelectorKind.LIST, selector=list, permissions=[check])
|
|
56
|
+
return PermissionCheckDenied(check=check, spec=spec)
|
|
39
57
|
if kind is ServiceValidationError:
|
|
40
58
|
return ServiceValidationError("Taken.")
|
|
41
59
|
if kind is ActionUnavailable:
|
|
@@ -297,6 +297,23 @@ class TestSeeds:
|
|
|
297
297
|
command = command_over(self._registry(), pool_seeds=seeds)
|
|
298
298
|
assert run("greet", "--as-user", str(owner.pk), command=command) == '"hello acme"\n'
|
|
299
299
|
|
|
300
|
+
def test_a_reflected_read_a_seed_fills_is_an_option_only_without_the_seed(
|
|
301
|
+
self, capsys: pytest.CaptureFixture[str], owner: Any
|
|
302
|
+
) -> None:
|
|
303
|
+
# Offered under the command's seeds, it would be refused when passed,
|
|
304
|
+
# as an argument dispatch does not take.
|
|
305
|
+
def greet(*, tenant: str) -> str:
|
|
306
|
+
return f"hello {tenant}"
|
|
307
|
+
|
|
308
|
+
reads = Parameters.of(Parameter("tenant", "string", required=True, reflected=True))
|
|
309
|
+
spec = ServiceSpec(service=greet, permissions=[Unrestricted()], reads=reads)
|
|
310
|
+
registry = registry_of(greet=spec)
|
|
311
|
+
seeded = command_over(registry, pool_seeds=DEFAULT_POOL_SEEDS.extend(tenant=lambda: "acme"))
|
|
312
|
+
assert "--tenant" not in help_of(capsys, "greet", command=seeded)
|
|
313
|
+
assert run("greet", "--as-user", str(owner.pk), command=seeded) == '"hello acme"\n'
|
|
314
|
+
unseeded = " ".join(help_of(capsys, "greet", command=command_over(registry)).split())
|
|
315
|
+
assert "--tenant STRING (required)" in unseeded
|
|
316
|
+
|
|
300
317
|
def test_with_no_seeds_named_a_callable_reading_one_fails_as_dispatch_does(
|
|
301
318
|
self, owner: Any
|
|
302
319
|
) -> None:
|
|
@@ -428,6 +445,21 @@ class TestHelp:
|
|
|
428
445
|
assert "--project" not in text
|
|
429
446
|
assert "--n INTEGER" in text
|
|
430
447
|
|
|
448
|
+
def test_a_read_a_provider_may_fill_is_offered_and_not_required(
|
|
449
|
+
self, capsys: pytest.CaptureFixture[str], owner: Any
|
|
450
|
+
) -> None:
|
|
451
|
+
# A return that says nothing about its keys may fill any read, so
|
|
452
|
+
# dispatch demands none of them of the caller and the help asks for none.
|
|
453
|
+
def may_fill(**_: Any) -> dict[str, Any]:
|
|
454
|
+
return {"project": 1}
|
|
455
|
+
|
|
456
|
+
spec = echo_spec(Parameter("project", "integer", required=True), kwargs=may_fill)
|
|
457
|
+
command = command_over(registry_of(echo=spec))
|
|
458
|
+
text = " ".join(help_of(capsys, "echo", command=command).split())
|
|
459
|
+
assert "--project INTEGER" in text
|
|
460
|
+
assert "(required)" not in text
|
|
461
|
+
assert lines(run("echo", "--as-user", str(owner.pk), command=command)) == [{"project": 1}]
|
|
462
|
+
|
|
431
463
|
|
|
432
464
|
# --- output --------------------------------------------------------------------------------------
|
|
433
465
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
version = 1
|
|
2
|
-
revision =
|
|
2
|
+
revision = 5
|
|
3
3
|
requires-python = ">=3.10"
|
|
4
4
|
resolution-markers = [
|
|
5
5
|
"python_full_version >= '3.12'",
|
|
@@ -438,16 +438,16 @@ wheels = [
|
|
|
438
438
|
|
|
439
439
|
[[package]]
|
|
440
440
|
name = "django-service-specs"
|
|
441
|
-
version = "0.
|
|
441
|
+
version = "0.25.1"
|
|
442
442
|
source = { registry = "https://pypi.org/simple" }
|
|
443
443
|
dependencies = [
|
|
444
444
|
{ name = "django", version = "5.2.18", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.12'" },
|
|
445
445
|
{ name = "django", version = "6.1.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
|
|
446
446
|
{ name = "typing-extensions" },
|
|
447
447
|
]
|
|
448
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
448
|
+
sdist = { url = "https://files.pythonhosted.org/packages/15/fc/f9d84274df2031d8a954713d68058d11949e29a537c91a4cc4e663badd6f/django_service_specs-0.25.1.tar.gz", hash = "sha256:d1c5ef473ebc3d5bec162b70664895c2493394bbdfdc1447090390071228233c", size = 1172311, upload-time = "2026-11-03T14:45:24.825Z" }
|
|
449
449
|
wheels = [
|
|
450
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
450
|
+
{ url = "https://files.pythonhosted.org/packages/a5/85/27c0da45b031c1080b226b8226e84504d7e1973367380826040db75566a7/django_service_specs-0.25.1-py3-none-any.whl", hash = "sha256:d4d19e64b5a785800a09b81e0b323c6e4acefdabf4694ce297b86493a9560ef8", size = 513779, upload-time = "2026-11-03T14:45:23.115Z" },
|
|
451
451
|
]
|
|
452
452
|
|
|
453
453
|
[package.optional-dependencies]
|
|
@@ -490,7 +490,7 @@ docs = [
|
|
|
490
490
|
[package.metadata]
|
|
491
491
|
requires-dist = [
|
|
492
492
|
{ name = "django", specifier = ">=4.2" },
|
|
493
|
-
{ name = "django-service-specs", specifier = ">=0.
|
|
493
|
+
{ name = "django-service-specs", specifier = ">=0.24.0" },
|
|
494
494
|
]
|
|
495
495
|
|
|
496
496
|
[package.metadata.requires-dev]
|
|
@@ -1761,7 +1761,7 @@ wheels = [
|
|
|
1761
1761
|
|
|
1762
1762
|
[[package]]
|
|
1763
1763
|
name = "virtualenv"
|
|
1764
|
-
version = "21.14.
|
|
1764
|
+
version = "21.14.13"
|
|
1765
1765
|
source = { registry = "https://pypi.org/simple" }
|
|
1766
1766
|
dependencies = [
|
|
1767
1767
|
{ name = "distlib" },
|
|
@@ -1773,9 +1773,9 @@ dependencies = [
|
|
|
1773
1773
|
{ name = "python-discovery" },
|
|
1774
1774
|
{ name = "typing-extensions", marker = "python_full_version < '3.11'" },
|
|
1775
1775
|
]
|
|
1776
|
-
sdist = { url = "https://files.pythonhosted.org/packages/
|
|
1776
|
+
sdist = { url = "https://files.pythonhosted.org/packages/70/aa/bff50daee0488e16d611258a9b6c5a1d0c9e128f8ca424e9f4e1c0444ef2/virtualenv-21.14.13.tar.gz", hash = "sha256:de5307ba4b9a0001d9c8ea02832d38f63ca432880f416c1bface61c4323fd905", size = 5570301, upload-time = "2026-10-22T20:10:16.952Z" }
|
|
1777
1777
|
wheels = [
|
|
1778
|
-
{ url = "https://files.pythonhosted.org/packages/
|
|
1778
|
+
{ url = "https://files.pythonhosted.org/packages/bb/a9/c10d8a44a29fb94a18b43fdf11f38caca53ae7c9406f11a72b1cb8f624f1/virtualenv-21.14.13-py3-none-any.whl", hash = "sha256:5fbb04138a4861580b78ba9110d529a26bc48fcc93c8ec36bc0202eeed96a788", size = 5557094, upload-time = "2026-10-22T20:10:15.096Z" },
|
|
1779
1779
|
]
|
|
1780
1780
|
|
|
1781
1781
|
[[package]]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/django_spec_cli/argv/parameter_descriptor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/__init__.py
RENAMED
|
File without changes
|
{django_spec_cli-0.2.1 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/notes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|