[Python-Dev] __future__ imports and breaking code (was: PEP 563: Postponed Evaluation of Annotations)
k7hoven at gmail.com
Sun Nov 19 17:03:54 EST 2017
Previously, I expressed some concerns about PEP 563 regarding what should
happen when a string is used as an annotation. Since my point here is more
general, I'm starting yet another thread.
For a lot of existing type-annotated code, adding "from __tuture__ import
annotations"  *doesn't break anything*.
But that doesn't seem right. The whole point of __future__ imports is to
break things. Maybe the __future__ import will not give a 100% equivalent
functionality to what will be in Python 4 by default, but anyway, it's
Python 4 that should break as little as possible. This leaves the breaking
business to the future import, if necessary.
If someone cares enough to add the future import that avoids needing string
annotations for forward references, it shouldn't be such a big deal to get
a warning if there's a string annotation left. But the person upgrading to
Python 4 (or whatever they might be upgrading) will have a lot less
motivation to figure out what went wrong.
Then again, code that works in both Python 3 and 4 could still have the
future import. But that would defeat the purpose of Python 4 as a clean and
high-performance dynamic language.
 As defined in the PEP 563 draft:
+ Koos Zevenhoven + http://twitter.com/k7hoven +
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev