refactor(code_gen): type LLM-Gateway options to drop cast() escape hatches#216
Merged
Merged
Conversation
…tches
Introduce a `GatewayOptions` TypedDict (in code_gen/serialize.py) for the
prompt-chain options that `code_gen.gateway_options` builds and the transcribe/
stream renderers consume. Threading the typed shape end-to-end lets pyright/mypy
know `llm["prompts"]` is `list[str]`, removing the two `cast("list[str]", …)`
calls in transcribe.py and stream.py. `interval` is `NotRequired` (transcribe
omits it; the streaming refresh-loop test deliberately exercises the absent case).
Also drops the `# type: ignore[no-any-return]` in the e2e helper by returning a
constructed dict instead of the bare `json.loads` result (no new `Any` token).
Net escape hatches: cast() 13->11, type:ignore/noqa/no-cover 20->19.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FunrXSdcsWguki9hyeeMMe
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.
Introduce a
GatewayOptionsTypedDict (in code_gen/serialize.py) for theprompt-chain options that
code_gen.gateway_optionsbuilds and the transcribe/stream renderers consume. Threading the typed shape end-to-end lets pyright/mypy
know
llm["prompts"]islist[str], removing the twocast("list[str]", …)calls in transcribe.py and stream.py.
intervalisNotRequired(transcribeomits it; the streaming refresh-loop test deliberately exercises the absent case).
Also drops the
# type: ignore[no-any-return]in the e2e helper by returning aconstructed dict instead of the bare
json.loadsresult (no newAnytoken).Net escape hatches: cast() 13->11, type:ignore/noqa/no-cover 20->19.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01FunrXSdcsWguki9hyeeMMe