Skip to content

Commit 4f6253c

Browse files
committed
Consolidate configuration checks
1 parent bc9a2fc commit 4f6253c

5 files changed

Lines changed: 551 additions & 149 deletions

File tree

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
- Consolidate the `--time`, `--jobs` and `-0`/`--zero-exit` options into a single `click_extra.execution` module. The `click_extra.jobs` and `click_extra.timer` submodules are removed: their decorators and classes (`timer_option`, `jobs_option`, `TimerOption`, `JobsOption`, `CPU_COUNT`, `DEFAULT_JOBS`) remain importable from the `click_extra` root. The `--show-params` table now reports these options under `click_extra.execution`.
1313
- Honor the standard `POSIXLY_CORRECT` environment variable. When it is present in the environment (regardless of value), `ExtraContext` forces `allow_interspersed_args` to `False`, so every Click Extra command and group stops parsing options at the first positional argument, matching GNU getopt-based tools.
1414
- Add an `--accessible` option to the default set of `@extra_command` and `@extra_group` (via `default_extra_params()`). Enabling it, or setting the `ACCESSIBLE` environment variable, is equivalent to `--no-color --table-format plain`: it strips ANSI codes and renders tables without Unicode box-drawing characters, for screen readers. An explicit `--color` or `--table-format` (on the command line or in a configuration file) keeps precedence. Also available as the `@accessible_option` decorator and the `AccessibleOption` class.
15+
- Add the `run_config_validation()` function and the `ValidationReport` dataclass to `click_extra.config` (both re-exported from the package root). They run the CLI-parameter strict check, the typed schema build, and every registered `ConfigValidator` in a single pass, returning the typed schema instance, the extracted extension sub-trees, and the list of `ValidationError`s. `collect_all=True` gathers every error; `collect_all=False` stops at the first. Both `--validate-config` and normal `--config` loading now delegate to this primitive.
16+
- Unify configuration-loading errors under the single `ValidationError` type. Unknown CLI-parameter keys (`strict=True`) and unknown schema fields (`schema_strict=True`) previously surfaced as an uncaught `ValueError` traceback during `--config` loading; they now stop the run with a critical-level log and exit code 1, the same failure mode as extension-validator errors. Code that caught `ValueError` from config loading should catch the `SystemExit` from the exit (or use `--validate-config` / `run_config_validation()` to inspect errors without exiting).
17+
- Fix `schema_strict=True` wrongly rejecting the contents of a configuration field marked as an extension point with `EXTENSION_METADATA_KEY` when the field's Python type is not a mapping. The dataclass adapter now honors the marker the same way the outer strict check does, so the marked sub-tree is kept intact instead of being flattened and reported as unknown keys.
1518

1619
## [`7.17.2` (2026-05-26)](https://github.com/kdeldycke/click-extra/compare/v7.17.1...v7.17.2)
1720

click_extra/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@
7676
NoConfigOption,
7777
ValidateConfigOption,
7878
ValidationError,
79+
ValidationReport,
7980
flatten_config_keys,
8081
get_tool_config,
8182
normalize_config_keys,
83+
run_config_validation,
8284
)
8385
from .context import ExtraContext
8486
from .decorators import ( # type: ignore[no-redef]
@@ -249,6 +251,7 @@
249251
"UsageError",
250252
"ValidateConfigOption",
251253
"ValidationError",
254+
"ValidationReport",
252255
"VerboseOption",
253256
"VerbosityOption",
254257
"VersionOption",
@@ -311,6 +314,7 @@
311314
"render_manpage",
312315
"render_manpages",
313316
"render_table",
317+
"run_config_validation",
314318
"search_params",
315319
"secho",
316320
"serialize_data",

0 commit comments

Comments
 (0)