[Python-Dev] future imports and breaking code (was: PEP 563: Postponed Evaluation of Annotations) (original) (raw)
Koos Zevenhoven k7hoven at gmail.com
Sun Nov 19 17:03:54 EST 2017
- Previous message (by thread): [Python-Dev] Comment on PEP 562 (Module __getattr__ and __dir__)
- Next message (by thread): [Python-Dev] PEP 563: Postponed Evaluation of Annotations (Draft 3)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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: https://mail.python.org/pipermail/python-dev/2017-November/150062.html
--
- Koos Zevenhoven + http://twitter.com/k7hoven + -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20171120/7dcb30ae/attachment.html>
- Previous message (by thread): [Python-Dev] Comment on PEP 562 (Module __getattr__ and __dir__)
- Next message (by thread): [Python-Dev] PEP 563: Postponed Evaluation of Annotations (Draft 3)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]