fix: add total=False to modality Parameters TypedDicts#256
Merged
Kamilbenkirane merged 1 commit intomainfrom Apr 10, 2026
Merged
fix: add total=False to modality Parameters TypedDicts#256Kamilbenkirane merged 1 commit intomainfrom
Kamilbenkirane merged 1 commit intomainfrom
Conversation
Per PEP 589, the totality flag only applies to fields defined in the body of the TypedDict definition — it is not inherited from the parent. The five modality Parameters subclasses (Text, Image, Video, Audio, Embeddings) inherited from `class Parameters(TypedDict, total=False)` but redeclared their own fields without the flag, so every field on them was treated as required by mypy. Under PEP 692 `Unpack[...]` this cascaded to downstream consumers: any strict-mypy caller of `celeste.text.generate` (etc.) was forced to pass all ~13 TextParameters keys. Internally silenced by `[[tool.mypy.overrides]] disable_error_code = ["call-arg"]` on the client modules, but leaked to downstream packages like celeste-tools. Also fix the scaffolding template that produced this pattern. Closes #255
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Kamilbenkirane
added a commit
that referenced
this pull request
Apr 10, 2026
…rrides After #256 fixed total=False on the modality Parameters TypedDicts, the call-arg exclusion in the big internal [[tool.mypy.overrides]] block (modalities.*.client / streaming / providers, providers.*, namespaces.domains) is no longer needed for the Unpack[*Parameters] pattern that originally required it. Removing it surfaced one previously-hidden real bug: GoogleImagesClient.model_post_init() forgot to forward self.base_url to the strategy client constructor (Gemini/Imagen). The wrapper would honor a custom base_url, but the strategy would silently default to None. Pass base_url=self.base_url at the call site. Also tightens the override surface: 6 disabled error codes instead of 7 on the same module list. The remaining codes (override, return-value, arg-type, assignment, no-any-return, attr-defined) cover the provider-mixin / multiple-inheritance typing patterns and are unrelated to #256. The tests.* override keeps call-arg disabled — 39 test files still construct provider clients without explicit base_url= and this PR intentionally leaves test ergonomics alone. Closes #257
7 tasks
Kamilbenkirane
added a commit
that referenced
this pull request
Apr 10, 2026
…rrides (#258) After #256 fixed total=False on the modality Parameters TypedDicts, the call-arg exclusion in the big internal [[tool.mypy.overrides]] block (modalities.*.client / streaming / providers, providers.*, namespaces.domains) is no longer needed for the Unpack[*Parameters] pattern that originally required it. Removing it surfaced one previously-hidden real bug: GoogleImagesClient.model_post_init() forgot to forward self.base_url to the strategy client constructor (Gemini/Imagen). The wrapper would honor a custom base_url, but the strategy would silently default to None. Pass base_url=self.base_url at the call site. Also tightens the override surface: 6 disabled error codes instead of 7 on the same module list. The remaining codes (override, return-value, arg-type, assignment, no-any-return, attr-defined) cover the provider-mixin / multiple-inheritance typing patterns and are unrelated to #256. The tests.* override keeps call-arg disabled — 39 test files still construct provider clients without explicit base_url= and this PR intentionally leaves test ergonomics alone. Closes #257
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
total=Falseto the five modalityParametersTypedDict subclasses (TextParameters,ImageParameters,VideoParameters,AudioParameters,EmbeddingsParameters) and to the modality scaffolding template.total=False(or PEP 655NotRequired[...]per field) — it is not inherited from theParametersbase.Six files changed, six lines changed.
Why PEP 589
total=Falseand not PEP 655NotRequiredEquivalent under the spec. Chose
total=Falsefor consistency with the existingParametersbase and because ecosystem precedent (pydanticConfigDict, openai-pythonCompletionCreateParamsBase, anthropic-sdk-pythonMessageCreateParamsBase, google-genai, typeshed stubs) usesTypedDict, total=Falsefor all-optional param bags consumed viaUnpack[...]. ZeroNotRequiredhits in openai-python or anthropic-sdk-python types folders.Impact
Downstream consumers using strict mypy (e.g.
celeste-tools) were hitting 10+Missing named argumenterrors perceleste.text.generatecall, one perTextParametersfield. This fix makes strict-mypy downstream packages type-check cleanly againstceleste-aiwithout needing to disablecall-arg.Internally the problem was masked by
[[tool.mypy.overrides]] disable_error_code = ["call-arg"]onceleste.modalities.*.clientandceleste.providers.*.*inpyproject.toml. Those overrides may become tightenable in a follow-up PR now that the root cause is fixed.Test plan
make lint— ruff cleanmake format— 394 files unchangedmake typecheck— 331 source + 63 test files clean under strict mypymake security— bandit clean (0 issues, 18940 LOC)make test— 586 passed, 0 failed (afteruv sync --extra gcp)Closes #255