New submission from Eric Wieser <wieser.e...@gmail.com>:
Consider a class like class MyClass: x: int y: int Which has >>> MyClass.__annotations__ {'x': int, 'y': int} In future, it might change to class MyClass: @property def x(self) -> int: ... @functools.cached_property def x(self) -> int: ... Most code won't be able to tell the difference, as properties are already a mostly-transparent replacement for attributes - but any code looking at `__annotations__` will find it is now absent. It would be handy if `property.__set_name__` and `cachedproperty.__set_name__` could populate the `__annotations__` dict from their return type annotation. This isn't just hypothetically useful - `sphinx` master as of https://github.com/sphinx-doc/sphinx/pull/7564 is able to retrieve the type of any descriptor with this behavior. ---------- components: Library (Lib) messages: 368710 nosy: Eric Wieser priority: normal severity: normal status: open title: Copy property return annotations to __annotations__ type: enhancement versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40606> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com