refactor(python): use built-in type hinting generics

Closed
TI
2mo ago
+14187-14423

these are supported from 3.9 onwards, matching the current python constraint, so non-breaking

https://stackoverflow.com/questions/37087457/difference-between-defining-typing-dict-and-dict#37087556
https://peps.python.org/pep-0585/


Summary by cubic

Refactor Python generators, templates, and samples to use built-in generics (dict/list/tuple/set) per PEP 585, and harden codegen to prevent schema/container keywords from leaking into model imports. No behavior changes; Python 3.9+ only.

  • Refactors
    • Templates (python, pydantic-v1, fastapi, flask, aiohttp, blueplanet): replaced typing.Dict/List/Tuple/Set with dict/list/tuple/set, updated ClassVar[...] and type[T], removed unused typing imports, and adjusted docstrings.
    • Clients/helpers: RequestSerialized, response/header maps, and config TypedDicts use built-ins; ApiClient deserializers now match list[ and dict[; asyncio REST kwargs/maps use dict[str, Any]; FastAPI base API uses ClassVar[tuple]; security scope helpers expect list[str].
    • Codegen safeguards: removed List/Dict primitives and per-generator array/map/set overrides; centralized mappings in abstract Python codegens; added guards so container names and schema keywords don’t enter model imports; tests updated to assert built-ins only.
    • Docs/samples: dropped Dict/List from language primitives; regenerated docs, tests, and sample clients to use built-ins.