Skip to content

Leverage pydantic, simplify shared helpers, and lint CI workflows#19

Merged
alexkroman merged 1 commit into
mainfrom
quality/pydantic-and-ci-hardening
Jun 5, 2026
Merged

Leverage pydantic, simplify shared helpers, and lint CI workflows#19
alexkroman merged 1 commit into
mainfrom
quality/pydantic-and-ci-hardening

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Summary

A quality pass across the CLI in three themes — no behavior changes for users, broader internal type-safety and a hardened CI.

Better leverage of pydantic

  • jsonshape gains pydantic-backed as_int/as_float (with a bool guard so a JSON true isn't treated as a count) and a strict as_object_list. Three near-identical numeric coercers (transcribe_render._int_value/_float_value, account._usage_number) and the per-module _mapping_list/_as_mapping/_mapping pass-through wrappers (keys, audit, account, flow) collapse onto it.
  • config.py models the config.toml document (Config / Profile / StoredSession), so profile/session reads and writes are typed and validated instead of hand-juggling nested dicts and casting. A wrong-shaped (but valid-TOML) config now fails with a clean invalid_config error at load.
  • auth/flow.py parses the AMS login responses (discover/exchange/projects/create) through pydantic models, replacing _require/_require_int/_require_mapping; a single wrapper maps any ValidationError to the existing "run 'aai login' again" error.
  • The four duplicate TypeAdapter(dict[str, object]) definitions (config, config_builder, ams, jsonshape) are routed through jsonshape.

Faster startup

  • llm.py imports openai lazily, so it no longer loads on every CLI invocation (it was pulled in at command-registration time by transcribe/stream, hitting aai --help, doctor, login, etc.).

Workflow linting + CI hardening

  • Add actionlint (via the pip-packaged actionlint-py, no Go/Docker; brings shellcheck-py for embedded run: shell) and zizmor as pre-commit hooks. They run in CI via the existing pre-commit job — no new GitHub Action uses:.
  • Fixed the findings zizmor surfaced rather than suppressing them: persist-credentials: false on every actions/checkout (no job pushes), and a cooldown on both Dependabot entries (the safe-chain minimum-package-age idea applied to auto-opened PRs).

Test plan

  • ./scripts/check.sh passes: ruff + ruff-format, mypy + pyright (both strict), vulture, deptry, import-linter, xenon, branch coverage with 100% diff coverage, escape-hatch gate, build + twine.
  • actionlint, zizmor, and check-yaml pre-commit hooks pass on the workflows.

🤖 Generated with Claude Code

jsonshape gains pydantic-backed as_int/as_float and a strict as_object_list; three near-identical numeric coercers and the per-module _mapping_list/_as_mapping/_mapping pass-through wrappers (keys, audit, account, flow, transcribe_render) collapse onto it. The four duplicate TypeAdapter(dict[str,object]) definitions are routed through jsonshape too.

config.py now models the config.toml document (Config/Profile/StoredSession) so reads/writes are typed and validated instead of hand-juggling nested dicts. auth/flow.py parses the AMS login responses through pydantic models, replacing _require/_require_int/_require_mapping. llm.py imports openai lazily so it no longer loads on every CLI startup.

CI: add actionlint (via actionlint-py) and zizmor pre-commit hooks to lint the workflows, then fix what they surface — persist-credentials: false on every checkout, and a Dependabot cooldown mirroring the safe-chain minimum-package-age posture. Also drops the unused scripts/mutation_gate.py and syncs pyproject/uv.lock/check.sh.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alexkroman alexkroman merged commit 366c7d4 into main Jun 5, 2026
13 checks passed
@alexkroman alexkroman deleted the quality/pydantic-and-ci-hardening branch June 5, 2026 21:31
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.

2 participants