Skip to content

Promote CLI override parsing to config loader#155

Merged
aidankhogg merged 1 commit into
dev/alphafrom
codex/add-cli-override-parsing-in-config
Jun 29, 2026
Merged

Promote CLI override parsing to config loader#155
aidankhogg merged 1 commit into
dev/alphafrom
codex/add-cli-override-parsing-in-config

Conversation

@aidankhogg

Copy link
Copy Markdown
Contributor

Motivation

  • Factor the CLI --set dotted key=value override parsing into a reusable config helper so other code can reuse the logic and keep parsing behavior consistent.
  • Preserve existing CLI semantics: require key=value, reject empty dotted path components, parse values with YAML semantics, and disallow nesting under scalar values.

Description

  • Add ConfigOverrideError and parse_dotted_overrides(values: Iterable[str]) -> dict[str, Any] to netengine/config/loader.py, implementing YAML safe_load value parsing, empty-part validation, and scalar-vs-object conflict detection.
  • Replace the inline parser in netengine/cli/main.py with a small shim _parse_set_overrides that delegates to parse_dotted_overrides and converts ConfigOverrideError into click.BadParameter with the --set hint.
  • Add unit tests in tests/test_config.py (TestParseDottedOverrides) covering nested overrides, YAML scalar/list parsing, malformed inputs, and scalar/nested conflicts.
  • Remove the now-unused direct YAML parsing code from the CLI module and keep the single source of truth in the config loader.

Testing

  • Run static checks with python -m ruff check netengine/config/loader.py netengine/cli/main.py tests/test_config.py which passed.
  • Run unit tests with pytest tests/test_config.py tests/test_cli.py -q, which succeeded (all tests passed: 64 passed).

Codex Task

@aidankhogg aidankhogg self-assigned this Jun 29, 2026
@aidankhogg aidankhogg merged commit bb7d2c0 into dev/alpha Jun 29, 2026
@aidankhogg aidankhogg deleted the codex/add-cli-override-parsing-in-config branch June 29, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant