Repository navigation
[typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.11 #82786
Description
Activity
The PEP-563: Postponed evaluation of annotations was introduced an opt-in feature using "from __future__ import annotations". It is scheduled to become the default in Python 4.0.
I would prefer to limit the number of incompatible changes in Python 4.0: it should just a "regular" release, with a regular number of incompatible changes. The version number change is going to cause enough troubles...
Would it be possible possible to enable postponed evaluation of annotations either before or after Python 4.0? For example, can we imagine to enable it by default in Python 3.9? If not, what about Python 3.10?
See also the PEP-608 (Coordinated Python release) and bpo-38604 (Schedule Py_UNICODE API removal).
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.9 (EOL)end of lifeend of life
on Oct 27, 2019 IMO 3.10 would be better, since 3.9 would be too soon (it would be like a schedule for a normal deprecation).
Also if we are really doing this, I think it is better to announce this soon.
Also we should try to fix relevant issues related to string annotations (in typing and dataclasses), like python/typing#508, python/typing#574, https://bugs.python.org/issue37838, https://bugs.python.org/issue34776 and https://bugs.python.org/issue37948.
We never should have mentioned 4.0 as the target date to make this the
default (and only) behavior -- who knows whether there will ever even be a
Python 4.0? Even 3.10 might be on the early side (assuming we'll switch to
a year-long release cycle per PEP-602 -- we will then make deprecations in
general take two release cycles).I do agree that we should start the process of deprecating the
non-future behavior here in 3.9. I know of one project with a private
fork of Python (for other reasons) that has made this default.We never should have mentioned 4.0 as the target date to make this the
default (and only) behaviorI am fine with modifying __future__ documentation to only modify the "Mandatory" column to remove Python 4.0, and then close this issue:
https://docs.python.org/dev/library/__future__.html--
But I like the "PEP-563: Postponed evaluation of annotations", IMHO it would be nice to get it as the default behavior :-) It's just a matter of properly organize the transition ;-)
You can bring the deprecation schedule up on discourse or python-dev so more folks can let us know whether they'd be okay with 3.9 or 3.10.
I started a thread on typing-sig:
https://mail.python.org/archives/list/typing-sig@python.org/thread/JG4IWHO3TZORNESR6ARXFL6OUZU2BEBX/I personally like 3.10 as the target as that means users had at least 3 years to move to move over. Plus we can put a warning in the What's New for 3.9 about our plans for 3.10.
This issue has been discussed during the Language Summit. A quick poll showed that the majority is in favor of changing the default in Python 3.9.
Lukasz proposed a PEP update to propose to switch the default in Python 3.9:
python/peps#1371For me, the unclear part is which projects would be impacted if the default changes?
Someone mentioned attrs, but it seems like attrs is fine:
python-attrs/attrs#288 (comment)In term of workflow, I would _prefer_ to get such incompatible in the very beginning of a devcycle, rather than just before the feature freeze. But I don't think that it's a blocker issue. Technically, changes are allowed until 3.9.0 beta1. Moreover, Lukasz is the 3.9 release manager, the author of the PEP-563 and he is in favor of changing the default in 3.9 :-)
- changed the title
[-][typing] PEP 563: Postponed evaluation of annotations: enable it by default before Python 4.0[/-][+][typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.10[/+]on May 18, 2020 Too bad nobody took any action here after the positive outcome of the discussion at the summit.
- addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)and removedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.9 (EOL)end of lifeend of life
on May 18, 2020 33 remaining items
May I ask, is this going forward? I installed 3.11-dev, it's not there (though __future__ claims it should be). I understand if it isn't done yet, just want to know if there's risk it will be postponed again (or even given up).
We are still waiting a ruling on PEP-649. If it gets rejected, and no more ideas arises (before beta cut for 3.11), I guess we could move on and resolve this issue again.
I think it would help if we could enable some future feature globally by command line option or environment variable, without modifying all source files. It would allow users to quickly test their code base for compatibility with future changes. The problem currently is that nobody bothers to add "from __future__ import ...", so we have surprises every time when try to make it by default.
A tool which automatically adds or removes "from __future__ import ..." in files could help too.
- added3.8 (EOL)end of lifeend of lifeand removedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)3.10 (EOL)end of lifeend of life
on Nov 4, 2021 There are now multiple PEPs proposed to handle this problem differently.
PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.11
The SC asked to hold this for now. So I prefer to close the issue. Please open a new issue once the SC took a decision on this topic.
Reacted by Jelle Zijlstra
__future__.annotationsto 3.11 #25596annotationsis now "mandatory in 3.11" #25602Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: