Leverage pydantic, simplify shared helpers, and lint CI workflows#19
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
jsonshapegains pydantic-backedas_int/as_float(with aboolguard so a JSONtrueisn't treated as a count) and a strictas_object_list. Three near-identical numeric coercers (transcribe_render._int_value/_float_value,account._usage_number) and the per-module_mapping_list/_as_mapping/_mappingpass-through wrappers (keys,audit,account,flow) collapse onto it.config.pymodels theconfig.tomldocument (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 cleaninvalid_configerror at load.auth/flow.pyparses the AMS login responses (discover/exchange/projects/create) through pydantic models, replacing_require/_require_int/_require_mapping; a single wrapper maps anyValidationErrorto the existing "run 'aai login' again" error.TypeAdapter(dict[str, object])definitions (config,config_builder,ams,jsonshape) are routed throughjsonshape.Faster startup
llm.pyimportsopenailazily, so it no longer loads on every CLI invocation (it was pulled in at command-registration time bytranscribe/stream, hittingaai --help,doctor,login, etc.).Workflow linting + CI hardening
actionlint-py, no Go/Docker; bringsshellcheck-pyfor embeddedrun:shell) and zizmor as pre-commit hooks. They run in CI via the existingpre-commitjob — no new GitHub Actionuses:.persist-credentials: falseon everyactions/checkout(no job pushes), and acooldownon both Dependabot entries (the safe-chain minimum-package-age idea applied to auto-opened PRs).Test plan
./scripts/check.shpasses: 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, andcheck-yamlpre-commit hooks pass on the workflows.🤖 Generated with Claude Code