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
TYP: types in a class body that use names shadowed by a class method confuse ty #30752
# file test.pyclassdtype: ...
classndarray:
defmethod(self) ->dtype: ... # defined before the dtype property@propertydefdtype(self): ...
defmethod2(self) ->dtype: ... # defined after the dtype propertyprint(ndarray.method.__annotations__)
print(ndarray.method2.__annotations__)
$ uvx --isolated --python=3.14 python test.py{'return': <property object at 0x787a8e5a4a90>}{'return': <property object at 0x787a8e5a4a90>}
So starting with Python 3.14, the dtype annotation of methods defined anywhere in the class body will point to ndarray.dtype property instead of the dtype class. While mypy models the <3.14 behavior, ty chose to model the >=3.14 behavior.
I'll prepare a PR to fix these annotations so that work with all type checkers and across Python versions.
Activity