|
rdobuilder |
96a44c |
From 1913db5ae20e95e636471cc79208330dfe7a1d72 Mon Sep 17 00:00:00 2001
|
|
rdobuilder |
96a44c |
From: Noel Evans <noelevans@gmail.com>
|
|
rdobuilder |
96a44c |
Date: Wed, 25 Nov 2020 22:09:44 +0000
|
|
rdobuilder |
96a44c |
Subject: [PATCH 1/3] Fix tests failing with 3.10.0a2+
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
---
|
|
rdobuilder |
96a44c |
.../src_py3/test_typing_extensions.py | 39 ++++++++++++++++---
|
|
rdobuilder |
96a44c |
1 file changed, 33 insertions(+), 6 deletions(-)
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
diff --git a/typing_extensions/src_py3/test_typing_extensions.py b/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
index 0222303..89c3037 100644
|
|
rdobuilder |
96a44c |
--- a/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
+++ b/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
@@ -9,7 +9,7 @@
|
|
rdobuilder |
96a44c |
from unittest import TestCase, main, skipUnless, skipIf
|
|
rdobuilder |
96a44c |
from typing import TypeVar, Optional
|
|
rdobuilder |
96a44c |
from typing import T, KT, VT # Not in __all__.
|
|
rdobuilder |
96a44c |
-from typing import Tuple, List, Dict, Iterator
|
|
rdobuilder |
96a44c |
+from typing import ForwardRef, Tuple, List, Dict, Iterator
|
|
rdobuilder |
96a44c |
from typing import Generic
|
|
rdobuilder |
96a44c |
from typing import no_type_check
|
|
rdobuilder |
96a44c |
from typing_extensions import NoReturn, ClassVar, Final, IntVar, Literal, Type, NewType, TypedDict
|
|
rdobuilder |
96a44c |
@@ -71,6 +71,9 @@
|
|
rdobuilder |
96a44c |
# For checks reliant on Python 3.6 syntax changes (e.g. classvar)
|
|
rdobuilder |
96a44c |
PY36 = sys.version_info[:2] >= (3, 6)
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
+# For checks reliant on Python 3.10
|
|
rdobuilder |
96a44c |
+PY3_10 = sys.version_info[:2] >= (3, 10)
|
|
rdobuilder |
96a44c |
+
|
|
rdobuilder |
96a44c |
# Protocols are hard to backport to the original version of typing 3.5.0
|
|
rdobuilder |
96a44c |
HAVE_PROTOCOLS = sys.version_info[:3] != (3, 5, 0)
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
@@ -1516,7 +1519,6 @@ def test_typeddict_errors(self):
|
|
rdobuilder |
96a44c |
def test_py36_class_syntax_usage(self):
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__name__, 'LabelPoint2D')
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__module__, __name__)
|
|
rdobuilder |
96a44c |
- self.assertEqual(LabelPoint2D.__annotations__, {'x': int, 'y': int, 'label': str})
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__bases__, (dict,))
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__total__, True)
|
|
rdobuilder |
96a44c |
self.assertNotIsSubclass(LabelPoint2D, typing.Sequence)
|
|
rdobuilder |
96a44c |
@@ -1525,6 +1527,13 @@ def test_py36_class_syntax_usage(self):
|
|
rdobuilder |
96a44c |
self.assertEqual(not_origin['y'], 1)
|
|
rdobuilder |
96a44c |
other = LabelPoint2D(x=0, y=1, label='hi')
|
|
rdobuilder |
96a44c |
self.assertEqual(other['label'], 'hi')
|
|
rdobuilder |
96a44c |
+ if PY3_10:
|
|
rdobuilder |
96a44c |
+ self.assertEqual(LabelPoint2D.__annotations__, {
|
|
rdobuilder |
96a44c |
+ 'x': ForwardRef('int'),
|
|
rdobuilder |
96a44c |
+ 'y': ForwardRef('int'),
|
|
rdobuilder |
96a44c |
+ 'label': str})
|
|
rdobuilder |
96a44c |
+ else:
|
|
rdobuilder |
96a44c |
+ self.assertEqual(LabelPoint2D.__annotations__, {'x': int, 'y': int, 'label': str})
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
def test_pickle(self):
|
|
rdobuilder |
96a44c |
global EmpD # pickle wants to reference the class by name
|
|
rdobuilder |
96a44c |
@@ -1565,18 +1574,21 @@ def test_optional_keys(self):
|
|
rdobuilder |
96a44c |
def test_keys_inheritance(self):
|
|
rdobuilder |
96a44c |
assert BaseAnimal.__required_keys__ == frozenset(['name'])
|
|
rdobuilder |
96a44c |
assert BaseAnimal.__optional_keys__ == frozenset([])
|
|
rdobuilder |
96a44c |
- assert BaseAnimal.__annotations__ == {'name': str}
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
assert Animal.__required_keys__ == frozenset(['name'])
|
|
rdobuilder |
96a44c |
assert Animal.__optional_keys__ == frozenset(['tail', 'voice'])
|
|
rdobuilder |
96a44c |
+
|
|
rdobuilder |
96a44c |
+ assert Cat.__required_keys__ == frozenset(['name', 'fur_color'])
|
|
rdobuilder |
96a44c |
+ assert Cat.__optional_keys__ == frozenset(['tail', 'voice'])
|
|
rdobuilder |
96a44c |
+
|
|
rdobuilder |
96a44c |
+ @skipUnless(PY36 and not PY3_10, 'Python 3.6 and < 3.10 required')
|
|
rdobuilder |
96a44c |
+ def test_keys_inheritance_before_postponed_annotation_eval(self):
|
|
rdobuilder |
96a44c |
+ assert BaseAnimal.__annotations__ == {'name': str}
|
|
rdobuilder |
96a44c |
assert Animal.__annotations__ == {
|
|
rdobuilder |
96a44c |
'name': str,
|
|
rdobuilder |
96a44c |
'tail': bool,
|
|
rdobuilder |
96a44c |
'voice': str,
|
|
rdobuilder |
96a44c |
}
|
|
rdobuilder |
96a44c |
-
|
|
rdobuilder |
96a44c |
- assert Cat.__required_keys__ == frozenset(['name', 'fur_color'])
|
|
rdobuilder |
96a44c |
- assert Cat.__optional_keys__ == frozenset(['tail', 'voice'])
|
|
rdobuilder |
96a44c |
assert Cat.__annotations__ == {
|
|
rdobuilder |
96a44c |
'fur_color': str,
|
|
rdobuilder |
96a44c |
'name': str,
|
|
rdobuilder |
96a44c |
@@ -1584,6 +1596,21 @@ def test_keys_inheritance(self):
|
|
rdobuilder |
96a44c |
'voice': str,
|
|
rdobuilder |
96a44c |
}
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
+ @skipUnless(PY3_10, 'Python 3.10 required')
|
|
rdobuilder |
96a44c |
+ def test_keys_inheritance_with_postponed_annotation_eval(self):
|
|
rdobuilder |
96a44c |
+ assert BaseAnimal.__annotations__ == {'name': ForwardRef('str')}
|
|
rdobuilder |
96a44c |
+ assert Animal.__annotations__ == {
|
|
rdobuilder |
96a44c |
+ 'name': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ 'tail': ForwardRef('bool'),
|
|
rdobuilder |
96a44c |
+ 'voice': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ }
|
|
rdobuilder |
96a44c |
+ assert Cat.__annotations__ == {
|
|
rdobuilder |
96a44c |
+ 'fur_color': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ 'name': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ 'tail': ForwardRef('bool'),
|
|
rdobuilder |
96a44c |
+ 'voice': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ }
|
|
rdobuilder |
96a44c |
+
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
@skipUnless(TYPING_3_5_3, "Python >= 3.5.3 required")
|
|
rdobuilder |
96a44c |
class AnnotatedTests(BaseTestCase):
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
From a6b50a9788cb071ff11c408a7212bef1bad9b233 Mon Sep 17 00:00:00 2001
|
|
rdobuilder |
96a44c |
From: Noel Evans <noelevans@gmail.com>
|
|
rdobuilder |
96a44c |
Date: Wed, 25 Nov 2020 22:34:12 +0000
|
|
rdobuilder |
96a44c |
Subject: [PATCH 2/3] Fix import issue
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
---
|
|
rdobuilder |
96a44c |
.../src_py3/test_typing_extensions.py | 24 +++++++++----------
|
|
rdobuilder |
96a44c |
1 file changed, 12 insertions(+), 12 deletions(-)
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
diff --git a/typing_extensions/src_py3/test_typing_extensions.py b/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
index 89c3037..1c02877 100644
|
|
rdobuilder |
96a44c |
--- a/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
+++ b/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
@@ -9,7 +9,7 @@
|
|
rdobuilder |
96a44c |
from unittest import TestCase, main, skipUnless, skipIf
|
|
rdobuilder |
96a44c |
from typing import TypeVar, Optional
|
|
rdobuilder |
96a44c |
from typing import T, KT, VT # Not in __all__.
|
|
rdobuilder |
96a44c |
-from typing import ForwardRef, Tuple, List, Dict, Iterator
|
|
rdobuilder |
96a44c |
+from typing import Tuple, List, Dict, Iterator
|
|
rdobuilder |
96a44c |
from typing import Generic
|
|
rdobuilder |
96a44c |
from typing import no_type_check
|
|
rdobuilder |
96a44c |
from typing_extensions import NoReturn, ClassVar, Final, IntVar, Literal, Type, NewType, TypedDict
|
|
rdobuilder |
96a44c |
@@ -35,7 +35,7 @@
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
OLD_GENERICS = False
|
|
rdobuilder |
96a44c |
try:
|
|
rdobuilder |
96a44c |
- from typing import _type_vars, _next_in_mro, _type_check # noqa
|
|
rdobuilder |
96a44c |
+ from typing import _type_vars, _next_in_mro, _type_check # noqa
|
|
rdobuilder |
96a44c |
except ImportError:
|
|
rdobuilder |
96a44c |
OLD_GENERICS = True
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
@@ -1529,8 +1529,8 @@ def test_py36_class_syntax_usage(self):
|
|
rdobuilder |
96a44c |
self.assertEqual(other['label'], 'hi')
|
|
rdobuilder |
96a44c |
if PY3_10:
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__annotations__, {
|
|
rdobuilder |
96a44c |
- 'x': ForwardRef('int'),
|
|
rdobuilder |
96a44c |
- 'y': ForwardRef('int'),
|
|
rdobuilder |
96a44c |
+ 'x': typing.ForwardRef('int'),
|
|
rdobuilder |
96a44c |
+ 'y': typing.ForwardRef('int'),
|
|
rdobuilder |
96a44c |
'label': str})
|
|
rdobuilder |
96a44c |
else:
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__annotations__, {'x': int, 'y': int, 'label': str})
|
|
rdobuilder |
96a44c |
@@ -1598,17 +1598,17 @@ def test_keys_inheritance_before_postponed_annotation_eval(self):
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
@skipUnless(PY3_10, 'Python 3.10 required')
|
|
rdobuilder |
96a44c |
def test_keys_inheritance_with_postponed_annotation_eval(self):
|
|
rdobuilder |
96a44c |
- assert BaseAnimal.__annotations__ == {'name': ForwardRef('str')}
|
|
rdobuilder |
96a44c |
+ assert BaseAnimal.__annotations__ == {'name': typing.ForwardRef('str')}
|
|
rdobuilder |
96a44c |
assert Animal.__annotations__ == {
|
|
rdobuilder |
96a44c |
- 'name': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
- 'tail': ForwardRef('bool'),
|
|
rdobuilder |
96a44c |
- 'voice': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ 'name': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ 'tail': typing.ForwardRef('bool'),
|
|
rdobuilder |
96a44c |
+ 'voice': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
}
|
|
rdobuilder |
96a44c |
assert Cat.__annotations__ == {
|
|
rdobuilder |
96a44c |
- 'fur_color': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
- 'name': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
- 'tail': ForwardRef('bool'),
|
|
rdobuilder |
96a44c |
- 'voice': ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ 'fur_color': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ 'name': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
+ 'tail': typing.ForwardRef('bool'),
|
|
rdobuilder |
96a44c |
+ 'voice': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
}
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
From 762584effacd447b23688acf9cbc70e453fd9601 Mon Sep 17 00:00:00 2001
|
|
rdobuilder |
96a44c |
From: Noel Evans <noelevans@gmail.com>
|
|
rdobuilder |
96a44c |
Date: Wed, 25 Nov 2020 23:35:59 +0000
|
|
rdobuilder |
96a44c |
Subject: [PATCH 3/3] Simplify change using get_type_hints
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
---
|
|
rdobuilder |
96a44c |
.../src_py3/test_typing_extensions.py | 43 ++++---------------
|
|
rdobuilder |
96a44c |
1 file changed, 8 insertions(+), 35 deletions(-)
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
diff --git a/typing_extensions/src_py3/test_typing_extensions.py b/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
index 1c02877..b89b396 100644
|
|
rdobuilder |
96a44c |
--- a/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
+++ b/typing_extensions/src_py3/test_typing_extensions.py
|
|
rdobuilder |
96a44c |
@@ -35,7 +35,7 @@
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
OLD_GENERICS = False
|
|
rdobuilder |
96a44c |
try:
|
|
rdobuilder |
96a44c |
- from typing import _type_vars, _next_in_mro, _type_check # noqa
|
|
rdobuilder |
96a44c |
+ from typing import _type_vars, _next_in_mro, _type_check # noqa
|
|
rdobuilder |
96a44c |
except ImportError:
|
|
rdobuilder |
96a44c |
OLD_GENERICS = True
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
@@ -71,9 +71,6 @@
|
|
rdobuilder |
96a44c |
# For checks reliant on Python 3.6 syntax changes (e.g. classvar)
|
|
rdobuilder |
96a44c |
PY36 = sys.version_info[:2] >= (3, 6)
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
-# For checks reliant on Python 3.10
|
|
rdobuilder |
96a44c |
-PY3_10 = sys.version_info[:2] >= (3, 10)
|
|
rdobuilder |
96a44c |
-
|
|
rdobuilder |
96a44c |
# Protocols are hard to backport to the original version of typing 3.5.0
|
|
rdobuilder |
96a44c |
HAVE_PROTOCOLS = sys.version_info[:3] != (3, 5, 0)
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
@@ -1519,6 +1516,7 @@ def test_typeddict_errors(self):
|
|
rdobuilder |
96a44c |
def test_py36_class_syntax_usage(self):
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__name__, 'LabelPoint2D')
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__module__, __name__)
|
|
rdobuilder |
96a44c |
+ self.assertEqual(get_type_hints(LabelPoint2D), {'x': int, 'y': int, 'label': str})
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__bases__, (dict,))
|
|
rdobuilder |
96a44c |
self.assertEqual(LabelPoint2D.__total__, True)
|
|
rdobuilder |
96a44c |
self.assertNotIsSubclass(LabelPoint2D, typing.Sequence)
|
|
rdobuilder |
96a44c |
@@ -1527,13 +1525,6 @@ def test_py36_class_syntax_usage(self):
|
|
rdobuilder |
96a44c |
self.assertEqual(not_origin['y'], 1)
|
|
rdobuilder |
96a44c |
other = LabelPoint2D(x=0, y=1, label='hi')
|
|
rdobuilder |
96a44c |
self.assertEqual(other['label'], 'hi')
|
|
rdobuilder |
96a44c |
- if PY3_10:
|
|
rdobuilder |
96a44c |
- self.assertEqual(LabelPoint2D.__annotations__, {
|
|
rdobuilder |
96a44c |
- 'x': typing.ForwardRef('int'),
|
|
rdobuilder |
96a44c |
- 'y': typing.ForwardRef('int'),
|
|
rdobuilder |
96a44c |
- 'label': str})
|
|
rdobuilder |
96a44c |
- else:
|
|
rdobuilder |
96a44c |
- self.assertEqual(LabelPoint2D.__annotations__, {'x': int, 'y': int, 'label': str})
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
def test_pickle(self):
|
|
rdobuilder |
96a44c |
global EmpD # pickle wants to reference the class by name
|
|
rdobuilder |
96a44c |
@@ -1574,43 +1565,25 @@ def test_optional_keys(self):
|
|
rdobuilder |
96a44c |
def test_keys_inheritance(self):
|
|
rdobuilder |
96a44c |
assert BaseAnimal.__required_keys__ == frozenset(['name'])
|
|
rdobuilder |
96a44c |
assert BaseAnimal.__optional_keys__ == frozenset([])
|
|
rdobuilder |
96a44c |
+ assert get_type_hints(BaseAnimal) == {'name': str}
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
assert Animal.__required_keys__ == frozenset(['name'])
|
|
rdobuilder |
96a44c |
assert Animal.__optional_keys__ == frozenset(['tail', 'voice'])
|
|
rdobuilder |
96a44c |
-
|
|
rdobuilder |
96a44c |
- assert Cat.__required_keys__ == frozenset(['name', 'fur_color'])
|
|
rdobuilder |
96a44c |
- assert Cat.__optional_keys__ == frozenset(['tail', 'voice'])
|
|
rdobuilder |
96a44c |
-
|
|
rdobuilder |
96a44c |
- @skipUnless(PY36 and not PY3_10, 'Python 3.6 and < 3.10 required')
|
|
rdobuilder |
96a44c |
- def test_keys_inheritance_before_postponed_annotation_eval(self):
|
|
rdobuilder |
96a44c |
- assert BaseAnimal.__annotations__ == {'name': str}
|
|
rdobuilder |
96a44c |
- assert Animal.__annotations__ == {
|
|
rdobuilder |
96a44c |
+ assert get_type_hints(Animal) == {
|
|
rdobuilder |
96a44c |
'name': str,
|
|
rdobuilder |
96a44c |
'tail': bool,
|
|
rdobuilder |
96a44c |
'voice': str,
|
|
rdobuilder |
96a44c |
}
|
|
rdobuilder |
96a44c |
- assert Cat.__annotations__ == {
|
|
rdobuilder |
96a44c |
+
|
|
rdobuilder |
96a44c |
+ assert Cat.__required_keys__ == frozenset(['name', 'fur_color'])
|
|
rdobuilder |
96a44c |
+ assert Cat.__optional_keys__ == frozenset(['tail', 'voice'])
|
|
rdobuilder |
96a44c |
+ assert get_type_hints(Cat) == {
|
|
rdobuilder |
96a44c |
'fur_color': str,
|
|
rdobuilder |
96a44c |
'name': str,
|
|
rdobuilder |
96a44c |
'tail': bool,
|
|
rdobuilder |
96a44c |
'voice': str,
|
|
rdobuilder |
96a44c |
}
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
- @skipUnless(PY3_10, 'Python 3.10 required')
|
|
rdobuilder |
96a44c |
- def test_keys_inheritance_with_postponed_annotation_eval(self):
|
|
rdobuilder |
96a44c |
- assert BaseAnimal.__annotations__ == {'name': typing.ForwardRef('str')}
|
|
rdobuilder |
96a44c |
- assert Animal.__annotations__ == {
|
|
rdobuilder |
96a44c |
- 'name': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
- 'tail': typing.ForwardRef('bool'),
|
|
rdobuilder |
96a44c |
- 'voice': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
- }
|
|
rdobuilder |
96a44c |
- assert Cat.__annotations__ == {
|
|
rdobuilder |
96a44c |
- 'fur_color': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
- 'name': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
- 'tail': typing.ForwardRef('bool'),
|
|
rdobuilder |
96a44c |
- 'voice': typing.ForwardRef('str'),
|
|
rdobuilder |
96a44c |
- }
|
|
rdobuilder |
96a44c |
-
|
|
rdobuilder |
96a44c |
|
|
rdobuilder |
96a44c |
@skipUnless(TYPING_3_5_3, "Python >= 3.5.3 required")
|
|
rdobuilder |
96a44c |
class AnnotatedTests(BaseTestCase):
|