django-spec-cli 0.3.0__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.
Files changed (95) hide show
  1. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/CHANGELOG.md +17 -1
  2. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/PKG-INFO +1 -1
  3. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/spec_command.py +30 -16
  4. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/version.py +1 -1
  5. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/docs/index.md +11 -5
  6. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/pyproject.toml +1 -1
  7. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/test_spec_command.py +32 -0
  8. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/.github/CODEOWNERS +0 -0
  9. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/.github/SECURITY.md +0 -0
  10. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/.github/dependabot.yml +0 -0
  11. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/.github/workflows/release.yml +0 -0
  12. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/.github/workflows/tests.yml +0 -0
  13. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/.github/workflows/upstream-drift.yml +0 -0
  14. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/.gitignore +0 -0
  15. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/.pre-commit-config.yaml +0 -0
  16. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/CLAUDE.md +0 -0
  17. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/LICENSE +0 -0
  18. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/Makefile +0 -0
  19. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/README.md +0 -0
  20. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/__init__.py +0 -0
  21. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/apps.py +0 -0
  22. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/argv/__init__.py +0 -0
  23. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/argv/add_spec_arguments.py +0 -0
  24. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/argv/describe_parameters.py +0 -0
  25. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/argv/parameter_descriptor.py +0 -0
  26. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/argv/parsed_arguments.py +0 -0
  27. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/argv/utils.py +0 -0
  28. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/checks.py +0 -0
  29. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/exit_code_for.py +0 -0
  30. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/py.typed +0 -0
  31. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/render/__init__.py +0 -0
  32. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/render/render_json_lines.py +0 -0
  33. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/render/render_result.py +0 -0
  34. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/render/render_table.py +0 -0
  35. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/render/utils.py +0 -0
  36. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/render/wants_table.py +0 -0
  37. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/report/__init__.py +0 -0
  38. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/report/unguarded_message.py +0 -0
  39. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/settings.py +0 -0
  40. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/types/__init__.py +0 -0
  41. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/django_spec_cli/types/exit_code.py +0 -0
  42. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/docs/__init__.py +0 -0
  43. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/docs/examples/__init__.py +0 -0
  44. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/docs/examples/commands.py +0 -0
  45. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/docs/reference.md +0 -0
  46. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/mkdocs.yml +0 -0
  47. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/scripts/check-changelog +0 -0
  48. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/scripts/release-publish.sh +0 -0
  49. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/__init__.py +0 -0
  50. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/argv/__init__.py +0 -0
  51. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/argv/test_add_spec_arguments.py +0 -0
  52. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/argv/test_describe_parameters.py +0 -0
  53. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/argv/test_parameter_descriptor.py +0 -0
  54. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/argv/test_parsed_arguments.py +0 -0
  55. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/argv/test_utils.py +0 -0
  56. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/argv/utils.py +0 -0
  57. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/__init__.py +0 -0
  58. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/apps.py +0 -0
  59. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/__init__.py +0 -0
  60. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/__init__.py +0 -0
  61. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/notes.py +0 -0
  62. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_bad_parser.py +0 -0
  63. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_broken_import.py +0 -0
  64. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_broken_init.py +0 -0
  65. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_empty.py +0 -0
  66. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_no_registry.py +0 -0
  67. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_plain.py +0 -0
  68. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/management/commands/unguarded_report.py +0 -0
  69. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/commands_app/unguarded_registries.py +0 -0
  70. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/conftest.py +0 -0
  71. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/conftest_settings.py +0 -0
  72. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/dispatch_app/__init__.py +0 -0
  73. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/dispatch_app/apps.py +0 -0
  74. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/dispatch_app/models.py +0 -0
  75. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/docs/__init__.py +0 -0
  76. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/docs/test_commands_examples.py +0 -0
  77. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/docs/test_reference.py +0 -0
  78. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/render/__init__.py +0 -0
  79. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/render/test_render_json_lines.py +0 -0
  80. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/render/test_render_result.py +0 -0
  81. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/render/test_render_table.py +0 -0
  82. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/render/test_utils.py +0 -0
  83. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/render/test_wants_table.py +0 -0
  84. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/render/utils.py +0 -0
  85. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/report/__init__.py +0 -0
  86. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/report/test_unguarded_message.py +0 -0
  87. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/test_apps.py +0 -0
  88. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/test_checks.py +0 -0
  89. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/test_exit_code_for.py +0 -0
  90. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/test_init.py +0 -0
  91. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/test_settings.py +0 -0
  92. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/types/__init__.py +0 -0
  93. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/types/test_exit_code.py +0 -0
  94. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/tests/utils.py +0 -0
  95. {django_spec_cli-0.3.0 → django_spec_cli-0.3.1}/uv.lock +0 -0
@@ -7,6 +7,21 @@ 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
+
10
25
  ## [0.3.0] — 2026-11-04
11
26
 
12
27
  ### Changed
@@ -67,7 +82,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
67
82
  `django-service-specs>=0.10.0`, the first kernel release with every name the
68
83
  command reads at its root.
69
84
 
70
- [Unreleased]: https://github.com/Artui/django-spec-cli/compare/v0.3.0...HEAD
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
71
87
  [0.3.0]: https://github.com/Artui/django-spec-cli/compare/v0.2.1...v0.3.0
72
88
  [0.2.1]: https://github.com/Artui/django-spec-cli/compare/v0.2.0...v0.2.1
73
89
  [0.2.0]: https://github.com/Artui/django-spec-cli/compare/v0.1.0...v0.2.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: django-spec-cli
3
- Version: 0.3.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
@@ -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
- server_owned_keys,
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, less any key the server fills
76
- ([`server_owned_keys`][django_service_specs.specs.server_owned_keys.server_owned_keys]).
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 shape check reads it: required only where dispatch demands it.
286
-
287
- Relaxed for ``partial`` by the shape check's own reading, so ``--help``
288
- marks ``(required)`` exactly where an omission is refused
289
- (test_a_partial_spec_requires_only_what_names_its_row), and without the
290
- keys the server fills, whose value a caller's would never replace
291
- (test_a_key_the_server_fills_is_no_option).
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
- owned = server_owned_keys(spec)
294
- relaxed = relax_partial(spec, spec.parameters())
295
- return Parameters.of(*(param for param in relaxed if param.name not in owned))
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:
@@ -2,6 +2,6 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- __version__: str = "0.3.0"
5
+ __version__: str = "0.3.1"
6
6
 
7
7
  __all__ = ["__version__"]
@@ -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. On a `partial` spec, that is only what names the row: the
90
- Validator's fields may be left out, as dispatch allows.
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**, one a `kwargs` provider is annotated to answer
95
- ([`server_owned_keys`][django_service_specs.specs.server_owned_keys.server_owned_keys]),
96
- since a value sent for it would be dropped.
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.
@@ -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.3.0"
150
+ current_version = "0.3.1"
151
151
  allow_dirty = false
152
152
  commit = false
153
153
  tag = false
@@ -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
 
File without changes
File without changes