Help examples, error suggestions, and test cleanup#8
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses code-review feedback: CliRunner/app are already imported at module scope in each test file; remove the duplicated in-function imports and normalize blank lines. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses code-review feedback: replace constructor-only contract tests with assertions on the real raise sites (flow.run_login_flow timeout, client.resolve_audio_source), checking message and suggestion separately. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Golden tests pin the exact rendered CLI surface: every leaf command's --help (usage + options + Examples epilog) and the human/JSON forms of errors (including the Suggestion: line). The command list is derived from the live Typer tree, so new commands are automatically required to have a snapshot. Refresh intentionally with: pytest --snapshot-update Requires the syrupy>=4.0 dev dependency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Parametrized over every init template: build a clean venv with uv, install its requirements.txt, and import api/index.py in that venv. Catches the one drift the static contract tests can't — a dependency listed but uninstallable, a missing transitive pin, or an import that only fails with the real packages present. Gated behind a new `install` marker (slow; needs network + uv) and excluded from the default run and precommit gate; skips rather than fails when uv is absent or PyPI is unreachable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add pyright as a dev dependency and gate on it in scripts/check.sh (after mypy), scoped via a new [tool.pyright] section to the same aai_cli + tests sources mypy already covers. pyright resolves third-party types mypy ignores, so it surfaces a stricter class of issues; fix all 120 it reported so the gate lands green. Source fixes: - config_builder: type the dynamic SDK-kwargs dicts as dict[str, Any] at the construct_* unpack sites (the honest type for values bound for the SDK constructor). - microphone: broaden stream_factory to Callable[..., Iterable[bytes]] — the source only iterates the result + getattr(close), never needs Iterator. - scaffold: import Traversable from importlib.abc to match the protocol resources.files() actually returns. - transcribe template: guard the None transcript id before returning. - youtube: scoped ignore for yt-dlp's private _Params TypedDict. - llm/auth: tighten Any returns to ChatCompletion / Mapping now that pyright sees the real types. Test fixes: annotate TypedDict literals, narrow Optional fakes via local + assert, type stand-in modules as Any, and cast duck-typed stand-ins (CLIError, ChatCompletion, TextIO, Generator) to the API type they impersonate. Add numpy dev dep (e2e resampling) and wrap the over-long stream example line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Consolidate the two duplicate Typer-tree walkers into a shared tests/_cli_tree.py and drop the ~12 per-command *_help_has_examples tests now subsumed by the tree-derived examples-coverage guard plus the full --help snapshot. Remove redundant inline imports / CliRunner() re-instantiation in the error-suggestion tests, and cache the install test's PyPI reachability probe. Also add coverage for AMS auth, init runner, config_builder error paths, and duplex audio, and tidy output.emit_error's suggestion render. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Reformat output.py (collapse the Suggestion: print onto one line). - Exclude tests/__snapshots__/ from trailing-whitespace/end-of-file-fixer: syrupy stores .ambr blank lines as " ", so trimming them desyncs the goldens from the live render and breaks all snapshot tests in CI. - Bump ruff-pre-commit to v0.15.16 to match the project's ruff dev pin. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`uv run` does not install [project.optional-dependencies] by default, so the uv-managed env lacked pytest/hypothesis/fastapi/numpy/etc. mypy hid this via ignore_missing_imports, but pyright reported 44 reportMissingImports errors and failed CI. Run the type-checkers and pytest with `uv run --extra dev`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
GitHub runners set FORCE_COLOR, which overrides NO_COLOR in Rich, so the --help renders carried SGR escape codes the plain goldens don't have — 17 snapshot tests failed only on CI. _normalize now strips ANSI before comparing (no-op for the already-plain error renders), making the goldens color-env independent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move dev deps from [project.optional-dependencies].dev to [dependency-groups].dev, which uv installs by default for uv run/uv sync. This drops the `uv run --extra dev` band-aid in check.sh and makes a plain .venv correct for editors, so [tool.pyright] is pinned to .venv — Pylance and the CLI now resolve imports identically. The code already required 3.11 (config.py imports stdlib `tomllib`, added in 3.11), so requires-python, the mypy/pyright/ruff targets, doctor's runtime gate, install.sh, and the README all move to 3.11 — making pyright resolve tomllib under the new venv pin. CI installs the group via `pip install --group dev` (needs pip >= 25.1; upgraded in the pre-commit job); the check.sh job just needs uv on PATH. 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
--help, with a tree-derived coverage guard (test_help_examples_coverage.py) and full--helpsnapshots (test_cli_output_snapshots.py) so new commands are automatically required to carry examples.Suggestion:line on user-facing errors (auth, usage, missing ffmpeg/yt-dlp/sounddevice, bad profile names, etc.) and render it in both human and JSON output.tests/_cli_tree.py; remove the ~12 per-command*_help_has_examplestests now subsumed by the generalized guards; drop redundant inline imports /CliRunner()re-instantiation in the error-suggestion tests; cache the install test's PyPI reachability probe.config_buildererror paths, and duplex audio.Test plan
ruff check+ruff format --check: cleanmypy+pyright: clean (0 errors)pytest -m "not e2e and not install": all pass, 27 snapshots pass, coverage 95% (gate 90%)install-marked test collects correctly🤖 Generated with Claude Code