[Python-checkins] bpo-41314: fixed annotations __future__ version (GH-21616)

Miss Islington (bot) webhook-mailer at python.org
Sat Jul 25 18:00:24 EDT 2020


https://github.com/python/cpython/commit/b99f770230e0db390aa80c5135b1053f3be48e19
commit: b99f770230e0db390aa80c5135b1053f3be48e19
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-07-25T15:00:17-07:00
summary:

bpo-41314: fixed annotations __future__ version (GH-21616)


PEP 563 was updated to change the release where `from __future__ import annotations` becomes the default (and only) behavior from 4.0 to 3.10. Update `__future__.py` and its docs to reflect this.
(cherry picked from commit 0028c14073109595e7532ec00bb1e8bf39ecfb4d)

Co-authored-by: YoSTEALTH <35307184+YoSTEALTH at users.noreply.github.com>

files:
A Misc/NEWS.d/next/Documentation/2020-07-25-14-20-00.bpo-41314.yrjko0.rst
M Doc/library/__future__.rst
M Lib/__future__.py

diff --git a/Doc/library/__future__.rst b/Doc/library/__future__.rst
index e3d749e601784..41399942d3030 100644
--- a/Doc/library/__future__.rst
+++ b/Doc/library/__future__.rst
@@ -90,7 +90,7 @@ language using this mechanism:
 | generator_stop   | 3.5.0b1     | 3.7          | :pep:`479`:                                 |
 |                  |             |              | *StopIteration handling inside generators*  |
 +------------------+-------------+--------------+---------------------------------------------+
-| annotations      | 3.7.0b1     | 4.0          | :pep:`563`:                                 |
+| annotations      | 3.7.0b1     | 3.10         | :pep:`563`:                                 |
 |                  |             |              | *Postponed evaluation of annotations*       |
 +------------------+-------------+--------------+---------------------------------------------+
 
diff --git a/Lib/__future__.py b/Lib/__future__.py
index d7cb8ac5f4974..0e7b555234335 100644
--- a/Lib/__future__.py
+++ b/Lib/__future__.py
@@ -66,18 +66,20 @@
 # code.h and used by compile.h, so that an editor search will find them here.
 # However, they're not exported in __all__, because they don't really belong to
 # this module.
-CO_NESTED            = 0x0010   # nested_scopes
-CO_GENERATOR_ALLOWED = 0        # generators (obsolete, was 0x1000)
-CO_FUTURE_DIVISION   = 0x20000   # division
-CO_FUTURE_ABSOLUTE_IMPORT = 0x40000 # perform absolute imports by default
-CO_FUTURE_WITH_STATEMENT  = 0x80000   # with statement
-CO_FUTURE_PRINT_FUNCTION  = 0x100000   # print function
-CO_FUTURE_UNICODE_LITERALS = 0x200000 # unicode string literals
+CO_NESTED = 0x0010                      # nested_scopes
+CO_GENERATOR_ALLOWED = 0                # generators (obsolete, was 0x1000)
+CO_FUTURE_DIVISION = 0x20000            # division
+CO_FUTURE_ABSOLUTE_IMPORT = 0x40000     # perform absolute imports by default
+CO_FUTURE_WITH_STATEMENT = 0x80000      # with statement
+CO_FUTURE_PRINT_FUNCTION = 0x100000     # print function
+CO_FUTURE_UNICODE_LITERALS = 0x200000   # unicode string literals
 CO_FUTURE_BARRY_AS_BDFL = 0x400000
-CO_FUTURE_GENERATOR_STOP  = 0x800000 # StopIteration becomes RuntimeError in generators
-CO_FUTURE_ANNOTATIONS     = 0x1000000  # annotations become strings at runtime
+CO_FUTURE_GENERATOR_STOP = 0x800000     # StopIteration becomes RuntimeError in generators
+CO_FUTURE_ANNOTATIONS = 0x1000000       # annotations become strings at runtime
+
 
 class _Feature:
+
     def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):
         self.optional = optionalRelease
         self.mandatory = mandatoryRelease
@@ -88,7 +90,6 @@ def getOptionalRelease(self):
 
         This is a 5-tuple, of the same form as sys.version_info.
         """
-
         return self.optional
 
     def getMandatoryRelease(self):
@@ -97,7 +98,6 @@ def getMandatoryRelease(self):
         This is a 5-tuple, of the same form as sys.version_info, or, if
         the feature was dropped, is None.
         """
-
         return self.mandatory
 
     def __repr__(self):
@@ -105,6 +105,7 @@ def __repr__(self):
                                   self.mandatory,
                                   self.compiler_flag))
 
+
 nested_scopes = _Feature((2, 1, 0, "beta",  1),
                          (2, 2, 0, "alpha", 0),
                          CO_NESTED)
@@ -142,5 +143,5 @@ def __repr__(self):
                           CO_FUTURE_GENERATOR_STOP)
 
 annotations = _Feature((3, 7, 0, "beta", 1),
-                       (4, 0, 0, "alpha", 0),
+                       (3, 10, 0, "alpha", 0),
                        CO_FUTURE_ANNOTATIONS)
diff --git a/Misc/NEWS.d/next/Documentation/2020-07-25-14-20-00.bpo-41314.yrjko0.rst b/Misc/NEWS.d/next/Documentation/2020-07-25-14-20-00.bpo-41314.yrjko0.rst
new file mode 100644
index 0000000000000..48f9c933828b0
--- /dev/null
+++ b/Misc/NEWS.d/next/Documentation/2020-07-25-14-20-00.bpo-41314.yrjko0.rst
@@ -0,0 +1 @@
+Changed the release when ``from __future__ import annotations`` becomes the default from ``4.0`` to ``3.10`` (following a change in PEP 563).



More information about the Python-checkins mailing list