[issue40606] Copy property return annotations to __annotations__

2020-05-15 Thread Ivan Levkivskyi


Change by Ivan Levkivskyi :


--
nosy: +levkivskyi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40606] Copy property return annotations to __annotations__

2020-05-12 Thread Eric Wieser


Change by Eric Wieser :


--
keywords: +patch
nosy: +Eric.Wieser
nosy_count: 1.0 -> 2.0
pull_requests: +19361
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/20052

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40606] Copy property return annotations to __annotations__

2020-05-12 Thread Eric Wieser


New submission from Eric Wieser :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com