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

Ivan Levkivskyi levkivskyi at gmail.com
Tue Sep 12 05:38:32 EDT 2017


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. 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.

Also I really like Yury's idea of dynamic mapping, but it has one downside,
semantics of this will change:

    def fun(x: print("Function defined"), y: int) -> None:
        ...

However I agree functions with side effects in annotations are very rare,
and it would be reasonable to sacrifice this tiny backwards compatibility
to avoid the __future__ import.

--
Ivan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170912/f08686db/attachment.html>


More information about the Python-ideas mailing list