(original) (raw)
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" \[1\] \*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.
—Koos
\[1\] As defined in the PEP 563 draft:
--
+ Koos Zevenhoven + http://twitter.com/k7hoven +