Environment: google-genai 2.12.0, mypy 1.18.2-2.3.0
Repro:
from google.genai.interactions import Interaction
def check(x: object) -> None:
if isinstance(x, Interaction): # error: incompatible type "TypeAliasType"; expected "_ClassInfo"
print(x.id) # error: "object" has no attribute "id"
reveal_type(Interaction) # note: Revealed type is "typing.TypeAliasType"
When type checking with mypy, we get the errors noted above, while at runtime, the same import binds the resource class, as intended:
>>> from google.genai.interactions import Interaction
>>> Interaction
<class 'google.genai._gaos.types.interactions.interaction.Interaction'>
Cause: google/genai/interactions.py star-imports ._gaos.types.triggers (which exports Interaction as a TypeAliasType) and then ._gaos.types.interactions (the resource class), relying on last-binding-wins. That holds at runtime and for pyright, but mypy keeps the first star-import binding for a redefined name, so typed users get the triggers alias: isinstance is rejected and the resource fields (id, status, …) are missing. Not present in 2.11.x. Downstream example: temporalio/sdk-python#1652.
Potential Fix (verified against an installed 2.12.0): Rename the triggers Interaction alias, or drop it from the star surface merged into interactions. Removing "Interaction" from triggers' __all__ correctly flips mypy to the resource class. An explicit binding inside interactions.py after the star-imports does not help; mypy keeps the alias regardless.
Environment: google-genai 2.12.0, mypy 1.18.2-2.3.0
Repro:
When type checking with mypy, we get the errors noted above, while at runtime, the same import binds the resource class, as intended:
Cause:
google/genai/interactions.pystar-imports._gaos.types.triggers(which exportsInteractionas aTypeAliasType) and then._gaos.types.interactions(the resource class), relying on last-binding-wins. That holds at runtime and for pyright, but mypy keeps the first star-import binding for a redefined name, so typed users get the triggers alias:isinstanceis rejected and the resource fields (id,status, …) are missing. Not present in 2.11.x. Downstream example: temporalio/sdk-python#1652.Potential Fix (verified against an installed 2.12.0): Rename the
triggersInteractionalias, or drop it from the star surface merged intointeractions. Removing"Interaction"fromtriggers'__all__correctly flips mypy to the resource class. An explicit binding insideinteractions.pyafter the star-imports does not help; mypy keeps the alias regardless.