| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Named tuples are represented as TupleType, but analyze_descriptor_access() returned early for any non-Instance type, so a __get__ or __set__ override defined on a named tuple class was ignored when the named tuple was used as a class attribute descriptor. Map TupleType to its fallback instance before the Instance check, matching what regular member access already does. Fixes python#22193.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Named tuples are represented as TupleType, but analyze_descriptor_access() returned early for any non-Instance type. As a result, a __get__ (or __set__) override defined in a NamedTuple class body was ignored when the named tuple was used as a class attribute descriptor: reveal_type(SomeClass.tuple_descr) produced the raw tuple fallback instead of the __get__ return type.
Map TupleType to its fallback instance before the Instance check, matching how regular tuple member access already handles this via tuple_fallback().
Adds testDescriptorGetNamedTuple and testDescriptorSetNamedTuple regression tests covering both the class-attribute and instance-attribute access paths.
Fixes #22193.
Local test runs:
Note: this contribution was developed with LLM assistance under human review.