I have a problem with type hints recognition in Pycharm. Following simplified example constructed to show my issue:
class A:
@property
def a(self) -> A:
a_ = ...
return a_
def f[T: A](b: T):
c = b.a # `b.a` recognized as type `property` instead of `A`
The variable c
is not recognized as having type A
(which is returned by the property). Instead it is recognized as having type property
.
Any suggestion whether I do something wrong, or need a workaround, possibly because of known(?) PyCharm limitation in PEP 695 handling? I use Python 3.12.
Note this is not exactly same case as with TypeVar. If I use TypeVar construction, then Pycharm makes an Any
from a.b
and then thus stops complaining about the type being a property instead of what it really "returns".