Skip to content

Add typed configuration schema validation#303

Merged
JE-Chen merged 2 commits into
devfrom
feat/config-schema-batch
Jun 21, 2026
Merged

Add typed configuration schema validation#303
JE-Chen merged 2 commits into
devfrom
feat/config-schema-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

What

assets._coerce coerces one value and json_schema validates structure, but nothing bound a resolved config dict into a typed object with required-field enforcement and choice constraints — a stdlib pydantic-settings analog.

  • ConfigField(type, *, default, required, choices, env).
  • ConfigSchema.validate(mapping){ok, config, errors} (coerces str/int/float/bool, applies defaults, enforces required/choices).
  • ConfigSchema.from_dict(spec), validate_config(spec, mapping), coerce(value, kind).

Layers

  • Headless core: utils/config_schema/ (pure stdlib dataclasses, zero PySide6).
  • Facade: 4 symbols + __all__.
  • Executor: AC_validate_config.
  • MCP: ac_validate_config (read-only).
  • Script Builder: under Data.
  • Tests: test/unit_test/headless/test_config_schema_batch.py (9 tests).
  • Docs: v95_features_doc.rst (EN + Zh) + toctrees + 3 README What's-new sections.

Verification

  • pytest test/unit_test/headless/test_config_schema_batch.py → 9 passed.
  • ruff check je_auto_control/ clean; pylint 10.00/10; bandit clean; radon CC clean.
  • Package stays Qt-free.

assets._coerce coerces one value and json_schema validates JSON
structure, but nothing bound a resolved config dict into a typed object
with required-field enforcement and choice constraints. Add ConfigSchema
/ ConfigField / validate_config / coerce: a stdlib pydantic-settings
analog that coerces types, applies defaults, enforces required/choices,
and returns {ok, config, errors}. Wired through facade, executor
(AC_validate_config), MCP, and the Script Builder with a headless test
batch and EN/Zh docs.
@codacy-production

codacy-production Bot commented Jun 21, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 39 complexity · 0 duplication

Metric Results
Complexity 39
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 1ecbe9f into dev Jun 21, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/config-schema-batch branch June 21, 2026 20:05
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant