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.
This commit is contained in:
YoSTEALTH 2020-07-25 15:42:49 -06:00 committed by GitHub
parent daff39070e
commit 0028c14073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 13 deletions

View File

@ -90,7 +90,7 @@ language using this mechanism:
| generator_stop | 3.5.0b1 | 3.7 | :pep:`479`: | | generator_stop | 3.5.0b1 | 3.7 | :pep:`479`: |
| | | | *StopIteration handling inside generators* | | | | | *StopIteration handling inside generators* |
+------------------+-------------+--------------+---------------------------------------------+ +------------------+-------------+--------------+---------------------------------------------+
| annotations | 3.7.0b1 | 4.0 | :pep:`563`: | | annotations | 3.7.0b1 | 3.10 | :pep:`563`: |
| | | | *Postponed evaluation of annotations* | | | | | *Postponed evaluation of annotations* |
+------------------+-------------+--------------+---------------------------------------------+ +------------------+-------------+--------------+---------------------------------------------+

View File

@ -77,7 +77,9 @@ CO_FUTURE_BARRY_AS_BDFL = 0x400000
CO_FUTURE_GENERATOR_STOP = 0x800000 # StopIteration becomes RuntimeError in generators CO_FUTURE_GENERATOR_STOP = 0x800000 # StopIteration becomes RuntimeError in generators
CO_FUTURE_ANNOTATIONS = 0x1000000 # annotations become strings at runtime CO_FUTURE_ANNOTATIONS = 0x1000000 # annotations become strings at runtime
class _Feature: class _Feature:
def __init__(self, optionalRelease, mandatoryRelease, compiler_flag): def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):
self.optional = optionalRelease self.optional = optionalRelease
self.mandatory = mandatoryRelease self.mandatory = mandatoryRelease
@ -88,7 +90,6 @@ class _Feature:
This is a 5-tuple, of the same form as sys.version_info. This is a 5-tuple, of the same form as sys.version_info.
""" """
return self.optional return self.optional
def getMandatoryRelease(self): def getMandatoryRelease(self):
@ -97,7 +98,6 @@ class _Feature:
This is a 5-tuple, of the same form as sys.version_info, or, if This is a 5-tuple, of the same form as sys.version_info, or, if
the feature was dropped, is None. the feature was dropped, is None.
""" """
return self.mandatory return self.mandatory
def __repr__(self): def __repr__(self):
@ -105,6 +105,7 @@ class _Feature:
self.mandatory, self.mandatory,
self.compiler_flag)) self.compiler_flag))
nested_scopes = _Feature((2, 1, 0, "beta", 1), nested_scopes = _Feature((2, 1, 0, "beta", 1),
(2, 2, 0, "alpha", 0), (2, 2, 0, "alpha", 0),
CO_NESTED) CO_NESTED)
@ -142,5 +143,5 @@ generator_stop = _Feature((3, 5, 0, "beta", 1),
CO_FUTURE_GENERATOR_STOP) CO_FUTURE_GENERATOR_STOP)
annotations = _Feature((3, 7, 0, "beta", 1), annotations = _Feature((3, 7, 0, "beta", 1),
(4, 0, 0, "alpha", 0), (3, 10, 0, "alpha", 0),
CO_FUTURE_ANNOTATIONS) CO_FUTURE_ANNOTATIONS)

View File

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