You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TypeVar with constraints not resolving __getitem__ #3059
This is because the way we preserve both T & the bound when doing attribute access is via a special AttributeBase, which stores both the quantified and the bound. The bound is represented as a ClassType, so if the bound isn't a ClassType our handling doesn't work.
If the bounds here were list, dict, etc. it wouldbe fine. Tuple I'm not sure. But the issue is that TypedDict is not a class.
The current logic of calling getitem won't work perfectly since tuple/typeddict have special semantics there, so maybe it needs to be special cased somehow, as in asuka's PR
Activity
asukaminato0721 commentedon May 11, 2026
claim
yangdanny97 commentedon Jun 2, 2026
This is because the way we preserve both T & the bound when doing attribute access is via a special AttributeBase, which stores both the quantified and the bound. The bound is represented as a ClassType, so if the bound isn't a ClassType our handling doesn't work.
If the bounds here were list, dict, etc. it wouldbe fine. Tuple I'm not sure. But the issue is that TypedDict is not a class.
quantified_bound_classis the relevant functionyangdanny97 commentedon Jun 2, 2026
The current logic of calling getitem won't work perfectly since tuple/typeddict have special semantics there, so maybe it needs to be special cased somehow, as in asuka's PR
fix TypeVar with constraints not resolving __getitem__ #3059 (#3358)