Skip to content

Canonical response fields typed SchemaVariant lose element types (pyright errors, Any under the mypy plugin) #1416

Closed

Description

@bokelley

Since #1392 made the canonical models real subclasses, src/adcp/types/canonical_creative.py annotates 10 overriding fields as SchemaVariant[...] (lines ~692, 701, 704, 845, 885, 917, 930, 936, 1000, 1023). These include GetProductsResponse.products, CreateMediaBuyResponse1.packages, ListCreativesResponse.creatives and Product.format_options. The deleted canonical_creative.pyi typed them precisely (e.g. list[Product] | None).

SchemaVariant was designed for adopter subclass overrides. With adcp.types.mypy_plugin it becomes Any; without it, it isn't a valid type at all. So for library-internal overrides:

  • pyright / Pylance: list[Product] is not assignable to SchemaVariant, and SchemaVariant is not iterable, on ordinary adopter code like for p in resp.products.
  • mypy without the plugin: the same errors.
  • mypy with the plugin: no errors, but the fields are Any, so element typing is silently lost.

CI misses it because the repo enables the plugin and doesn't gate pyright.

Expected: inside the library, declare these overrides with their precise types, using targeted suppressions for the intentional override (# type: ignore[assignment] / # pyright: ignore[reportIncompatibleVariableOverride]), consistent with scripts/check_type_ignore_contract.py. Adopters should see list[Product] | None etc. under both checkers, with or without the plugin.

Acceptance: a strict adopter fixture iterating each of the 10 fields and using an element attribute passes mypy --strict with and without the plugin, and pyright. Add pyright on tests/type_checks/ to CI, or at least to make typecheck-all, so this can't regress silently.

Found in the post-merge audit of #1392.

Activity

  1. added
    no-triageSkip the Claude triage bot — human or designated agent will handle this issue
    on Oct 6, 2026
  2. added a commit that references this issue on Oct 7, 2026
    43910ce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claude-triagedno-triageSkip the Claude triage bot — human or designated agent will handle this issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions