[Python-ideas] PEP 563: Postponed Evaluation of Annotations, first draft

Lukasz Langa lukasz at langa.pl
Tue Sep 12 16:11:14 EDT 2017


> On Sep 12, 2017, at 5:38 AM, Ivan Levkivskyi <levkivskyi at gmail.com> wrote:
> 
> In principle, I like this idea, this will save some keystrokes
> and will make annotated code more "beautiful". But I am quite worried about the backwards
> compatibility. One possible idea would be to use __future__ import without a definite
> deprecation plan.

This is not a viable strategy since __future__ is not designed to be a feature toggle but rather to be a gradual introduction of an upcoming breaking change.


> If people will be fine with using typing.get_type_hints
> (btw this is already the preferred way instead of directly accessing __annotations__,
> according to PEP 526 at least) then we could go ahead with deprecation.

As you're pointing out, people already have to use `typing.get_type_hints()`, otherwise they are already failing evaluation of existing forward references. Accessing __annotations__ directly in this context is a bug today.


> Also I really like Yury's idea of dynamic mapping


I responded to his idea under his post.

- Ł
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170912/df2ad65a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170912/df2ad65a/attachment-0001.sig>


More information about the Python-ideas mailing list