admin管理员组文章数量:1316683
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".
本文标签:
版权声明:本文标题:python typing - PyCharm type hinting for generic type concludes property instead of property's return type - Stack Overf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741852164a2401134.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论