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