Skip to content

[typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.11 #82786

Description

@vstinner
BPO 38605
Nosy @gvanrossum, @warsaw, @brettcannon, @terryjreedy, @ericvsmith, @jwilk, @stevendaprano, @methane, @ambv, @serhiy-storchaka, @vedgar, @ilevkivskyi, @asottile, @pablogsal, @miss-islington, @isidentical, @gousaiyang, @AlexWaygood
PRs
  • bpo-38605: Make postponed evaluation of annotations default #20434
  • bpo-38605: bump the magic number for 'annotations' future #22630
  • bpo-38605: Update "Future statements" docs since PEP 563 is always enabled #25236
  • bpo-38605: Revert making 'from __future__ import annotations' the default #25490
  • bpo-38605: Set the release for __future__.annotations to 3.11 #25596
  • bpo-38605: Update __future__ module doc as annotations is now "mandatory in 3.11" #25602
  • Note: 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:

    assignee = None
    closed_at = None
    created_at = <Date 2019-10-27.16:07:10.414>
    labels = ['type-bug', '3.10', 'expert-unicode']
    title = '[typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.11'
    updated_at = <Date 2022-02-07.11:12:54.549>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2022-02-07.11:12:54.549>
    actor = 'jwilk'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Unicode']
    creation = <Date 2019-10-27.16:07:10.414>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38605
    keywords = ['patch']
    message_count = 40.0
    messages = ['355476', '355495', '355506', '355523', '355546', '360830', '366634', '366635', '369269', '369301', '369303', '370000', '370020', '370028', '370031', '370035', '370037', '370188', '370214', '370220', '370232', '375177', '377783', '378133', '378134', '378135', '378139', '378374', '378416', '390399', '391512', '391515', '391700', '391732', '391755', '391869', '394114', '394115', '404129', '404130']
    nosy_count = 18.0
    nosy_names = ['gvanrossum', 'barry', 'brett.cannon', 'terry.reedy', 'eric.smith', 'jwilk', 'steven.daprano', 'methane', 'lukasz.langa', 'serhiy.storchaka', 'veky', 'levkivskyi', 'Anthony Sottile', 'pablogsal', 'miss-islington', 'BTaskaya', 'gousaiyang', 'AlexWaygood']
    pr_nums = ['20434', '22630', '25236', '25490', '25596', '25602']
    priority = 'normal'
    resolution = 'postponed'
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38605'
    versions = ['Python 3.10']

    Activity

    1. vstinner commented on Oct 27, 2019

      @vstinner
      MemberAuthor

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

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Oct 27, 2019
    3. ilevkivskyi commented on Oct 27, 2019

      @ilevkivskyi
      Member

      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.

    4. gvanrossum commented on Oct 27, 2019

      @gvanrossum
      Member

      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.

    5. vstinner commented on Oct 28, 2019

      @vstinner
      MemberAuthor

      We never should have mentioned 4.0 as the target date to make this the
      default (and only) behavior

      I 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 ;-)

    6. gvanrossum commented on Oct 28, 2019

      @gvanrossum
      Member

      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.

    7. vstinner commented on Jan 28, 2020

      @vstinner
      MemberAuthor
    8. brettcannon commented on Apr 17, 2020

      @brettcannon
      Member

      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.

    9. vstinner commented on Apr 17, 2020

      @vstinner
      MemberAuthor

      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#1371

      For 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 :-)

    10. 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
    11. gvanrossum commented on May 18, 2020

      @gvanrossum
      Member

      Too bad nobody took any action here after the positive outcome of the discussion at the summit.

    12. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      and removed
      stdlibStandard Library Python modules in the Lib/ directory
      on May 18, 2020
    13. 33 remaining items

    14. isidentical commented on May 21, 2021

      @isidentical
      SponsorMember

      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.

    15. stevendaprano commented on Oct 17, 2021

      @stevendaprano
      Member

      Now that we're in 3.11, people are starting to notice that stringy annotations are not the default (see bpo-45499 for example).

      What can we do to get PEP-649 moving forward?

    16. serhiy-storchaka commented on Oct 17, 2021

      @serhiy-storchaka
      Member

      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.

    17. added and removed on Nov 4, 2021
    18. transferred this issue fromon Apr 10, 2022
    19. vstinner commented on Nov 3, 2022

      @vstinner
      MemberAuthor

      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.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions