Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-typing-inspect for 
openSUSE:Factory checked in at 2023-01-08 21:25:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-typing-inspect (Old)
 and      /work/SRC/openSUSE:Factory/.python-typing-inspect.new.1563 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-typing-inspect"

Sun Jan  8 21:25:36 2023 rev:3 rq:1056831 version:0.8.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-typing-inspect/python-typing-inspect.changes  
    2021-03-29 18:21:14.414229238 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-typing-inspect.new.1563/python-typing-inspect.changes
    2023-01-08 21:25:37.059274959 +0100
@@ -1,0 +2,11 @@
+Sat Jan  7 16:17:47 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 0.8.0:
+  * Python 3.9 support
+  * support PEO 591
+  * Require newer typing extension
+  * Python 3.10 support
+  * Add support for UnionType in get_args 
+- drop typing_inspect-pr69-py39-GenericAlias.patch (upstream)
+
+-------------------------------------------------------------------

Old:
----
  typing_inspect-0.6.0.tar.gz
  typing_inspect-pr69-py39-GenericAlias.patch

New:
----
  typing_inspect-0.8.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-typing-inspect.spec ++++++
--- /var/tmp/diff_new_pack.WqMttU/_old  2023-01-08 21:25:38.163281517 +0100
+++ /var/tmp/diff_new_pack.WqMttU/_new  2023-01-08 21:25:38.167281542 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-typing-inspect
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,15 +18,13 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-typing-inspect
-Version:        0.6.0
+Version:        0.8.0
 Release:        0
 Summary:        Python runtime inspection utilities for typing
 License:        MIT
 Group:          Development/Languages/Python
 URL:            https://github.com/ilevkivskyi/typing_inspect
 Source:         
https://files.pythonhosted.org/packages/source/t/typing_inspect/typing_inspect-%{version}.tar.gz
-# PATCH-FIX-UPSTREAM typing_inspect-pr69-py39-GenericAlias.patch -- backport 
of gh#ilevkivskyi/typing_inspect#69
-Patch0:         typing_inspect-pr69-py39-GenericAlias.patch
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros

++++++ typing_inspect-0.6.0.tar.gz -> typing_inspect-0.8.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_inspect-0.6.0/PKG-INFO 
new/typing_inspect-0.8.0/PKG-INFO
--- old/typing_inspect-0.6.0/PKG-INFO   2020-05-02 12:12:22.554987000 +0200
+++ new/typing_inspect-0.8.0/PKG-INFO   2022-08-17 15:58:06.028567300 +0200
@@ -1,19 +1,12 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: typing_inspect
-Version: 0.6.0
+Version: 0.8.0
 Summary: Runtime inspection utilities for typing module.
 Home-page: https://github.com/ilevkivskyi/typing_inspect
 Author: Ivan Levkivskyi
 Author-email: [email protected]
 License: MIT
-Description: Typing Inspect
-        ==============
-        
-        The "typing_inspect" module defines experimental API for runtime
-        inspection of types defined in the standard "typing" module.
-        
 Keywords: typing function annotations type hints hinting checking checker 
typehints typehinting typechecking inspect reflection introspection
-Platform: UNKNOWN
 Classifier: Development Status :: 3 - Alpha
 Classifier: Environment :: Console
 Classifier: Intended Audience :: Developers
@@ -27,4 +20,13 @@
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
 Classifier: Topic :: Software Development
+License-File: LICENSE
+
+Typing Inspect
+==============
+
+The "typing_inspect" module defines experimental API for runtime
+inspection of types defined in the standard "typing" module.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_inspect-0.6.0/README.md 
new/typing_inspect-0.8.0/README.md
--- old/typing_inspect-0.6.0/README.md  2020-05-02 11:57:55.000000000 +0200
+++ new/typing_inspect-0.8.0/README.md  2022-08-17 15:50:05.000000000 +0200
@@ -44,6 +44,10 @@
   Test if ``tp`` is a union type.
 * ``is_optional_type(tp)``:
   Test if ``tp`` is an optional type (either ``type(None)`` or a direct union 
to it such as in ``Optional[int]``). Nesting and ``TypeVar``s are not 
unfolded/inspected in this process.
+* ``is_literal_type(tp)``:
+  Test if ``tp`` is a literal type.
+* ``is_final_type(tp)``:
+  Test if ``tp`` is a final type.
 * ``is_typevar(tp)``:
   Test if ``tp`` represents a type variable.
 * ``is_new_type(tp)``:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_inspect-0.6.0/setup.py 
new/typing_inspect-0.8.0/setup.py
--- old/typing_inspect-0.6.0/setup.py   2020-05-02 12:05:50.000000000 +0200
+++ new/typing_inspect-0.8.0/setup.py   2022-08-17 15:52:41.000000000 +0200
@@ -5,7 +5,7 @@
 import sys
 from setuptools import setup
 
-version = '0.6.0'
+version = '0.8.0'
 description = 'Runtime inspection utilities for typing module.'
 long_description = '''
 Typing Inspect
@@ -29,6 +29,8 @@
     'Programming Language :: Python :: 3.5',
     'Programming Language :: Python :: 3.6',
     'Programming Language :: Python :: 3.7',
+    'Programming Language :: Python :: 3.8',
+    'Programming Language :: Python :: 3.9',
     'Topic :: Software Development',
 ]
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_inspect-0.6.0/test_typing_inspect.py 
new/typing_inspect-0.8.0/test_typing_inspect.py
--- old/typing_inspect-0.6.0/test_typing_inspect.py     2020-05-02 
11:57:55.000000000 +0200
+++ new/typing_inspect-0.8.0/test_typing_inspect.py     2022-08-17 
15:50:05.000000000 +0200
@@ -1,27 +1,25 @@
 import sys
+
+import pytest
+
 from typing_inspect import (
     is_generic_type, is_callable_type, is_new_type, is_tuple_type, 
is_union_type,
-    is_optional_type, is_literal_type, is_typevar, is_classvar, is_forward_ref,
-    get_origin, get_parameters, get_last_args, get_args, get_bound, 
get_constraints,
-    get_generic_type, get_generic_bases, get_last_origin, typed_dict_keys,
-    get_forward_arg, WITH_LITERAL, LEGACY_TYPING)
+    is_optional_type, is_final_type, is_literal_type, is_typevar, is_classvar,
+    is_forward_ref, get_origin, get_parameters, get_last_args, get_args, 
get_bound,
+    get_constraints, get_generic_type, get_generic_bases, get_last_origin,
+    typed_dict_keys, get_forward_arg, WITH_FINAL, WITH_LITERAL, LEGACY_TYPING, 
WITH_NEWTYPE,
+)
 from unittest import TestCase, main, skipIf, skipUnless
 from typing import (
     Union, Callable, Optional, TypeVar, Sequence, AnyStr, Mapping,
     MutableMapping, Iterable, Generic, List, Any, Dict, Tuple, NamedTuple,
 )
 
-from mypy_extensions import TypedDict
+from mypy_extensions import TypedDict as METypedDict
+from typing_extensions import TypedDict as TETypedDict
+from typing_extensions import Final
 from typing_extensions import Literal
-
-# Does this raise an exception ?
-#      from typing import NewType
-if sys.version_info < (3, 5, 2):
-    WITH_NEWTYPE = False
-else:
-    from typing import NewType
-    WITH_NEWTYPE = True
-
+from typing_extensions import NewType as NewType_
 
 # Does this raise an exception ?
 #      from typing import ClassVar
@@ -101,7 +99,10 @@
 NEW_TYPING = sys.version_info[:3] >= (3, 7, 0)  # PEP 560
 
 PY36_TESTS = """
-class TD(TypedDict):
+class TDM(METypedDict):
+    x: int
+    y: int
+class TDE(TETypedDict):
     x: int
     y: int
 class Other(dict):
@@ -110,10 +111,21 @@
 """
 
 PY36 = sys.version_info[:3] >= (3, 6, 0)
+PY39 = sys.version_info[:3] >= (3, 9, 0)
 if PY36:
     exec(PY36_TESTS)
-else:
-    TD = Other = object  # for linters
+
+
+# It is important for the test that this function is called 'NewType' to 
simulate the same __qualname__
+# - which is "NewType.<locals>.new_type" - as typing.NewType has, i.e. it 
should be checked that is_new_type
+# still do not accept a function which has the same __qualname__ and an 
attribute called __supertype__.
+def NewType(name, tp):
+    def new_type(x):
+        return x
+
+    new_type.__name__ = name
+    new_type.__supertype__ = tp
+    return new_type
 
 
 class IsUtilityTestCase(TestCase):
@@ -128,6 +140,8 @@
         T = TypeVar('T')
         samples = [Generic, Generic[T], Iterable[int], Mapping,
                    MutableMapping[T, List[int]], Sequence[Union[str, bytes]]]
+        if PY39:
+            samples.extend([list[int], dict[str, list[int]]])
         nonsamples = [int, Union[int, str], Union[int, T], Callable[..., T],
                       Optional, bytes, list] + CLASSVAR_GENERIC
         self.sample_test(is_generic_type, samples, nonsamples)
@@ -146,6 +160,8 @@
 
     def test_tuple(self):
         samples = [Tuple, Tuple[str, int], Tuple[Iterable, ...]]
+        if PY39:
+            samples.append(tuple[int, str])
         nonsamples = [int, tuple, 42, List[int], NamedTuple('N', [('x', int)])]
         self.sample_test(is_tuple_type, samples, nonsamples)
         if SUBCLASSABLE_TUPLES:
@@ -160,6 +176,14 @@
         nonsamples = [int, Union[int, int], [], Iterable[Any]]
         self.sample_test(is_union_type, samples, nonsamples)
 
+    @pytest.mark.skipif(sys.version_info < (3, 10), reason="requires 3.10 or 
higher")
+    def test_union_pep604(self):
+        T = TypeVar('T')
+        S = TypeVar('S')
+        samples = [T | int, int | (T | S), int | str]
+        nonsamples = [int, int | int, [], Iterable[Any]]
+        self.sample_test(is_union_type, samples, nonsamples)
+
     def test_optional_type(self):
         T = TypeVar('T')
         samples = [type(None),                # none type
@@ -191,6 +215,22 @@
                        ]
         self.sample_test(is_optional_type, samples, nonsamples)
 
+    @skipIf(not WITH_FINAL, "Final is not available")
+    def test_final_type(self):
+        samples = [
+            Final,
+            Final[int],
+        ]
+        nonsamples = [
+            "v",
+            1,
+            (1, 2, 3),
+            int,
+            str,
+            Union["u", "v"],
+        ]
+        self.sample_test(is_final_type, samples, nonsamples)
+
     @skipIf(not WITH_LITERAL, "Literal is not available")
     def test_literal_type(self):
         samples = [
@@ -224,13 +264,22 @@
     @skipIf(not WITH_NEWTYPE, "NewType is not present")
     def test_new_type(self):
         T = TypeVar('T')
+
+        class WithAttrSuperTypeCls:
+            __supertype__ = str
+
+        class WithAttrSuperTypeObj:
+            def __init__(self):
+                self.__supertype__ = str
+
         samples = [
-            NewType('A', int),
-            NewType('B', complex),
-            NewType('C', List[int]),
-            NewType('D', Union['p', 'y', 't', 'h', 'o', 'n']),
-            NewType('E', List[Dict[str, float]]),
-            NewType('F', NewType('F_', int)),
+            NewType_,
+            NewType_('A', int),
+            NewType_('B', complex),
+            NewType_('C', List[int]),
+            NewType_('D', Union['p', 'y', 't', 'h', 'o', 'n']),
+            NewType_('E', List[Dict[str, float]]),
+            NewType_('F', NewType('F_', int)),
         ]
         nonsamples = [
             int,
@@ -240,6 +289,12 @@
             Union["u", "v"],
             type,
             T,
+            NewType,
+            NewType('N', int),
+            WithAttrSuperTypeCls,
+            WithAttrSuperTypeCls(),
+            WithAttrSuperTypeObj,
+            WithAttrSuperTypeObj(),
         ]
         self.sample_test(is_new_type, samples, nonsamples)
 
@@ -282,6 +337,10 @@
             self.assertEqual(get_origin(ClassVar[int]), None)
         self.assertEqual(get_origin(Generic), Generic)
         self.assertEqual(get_origin(Generic[T]), Generic)
+        # Cannot use assertEqual on Py3.5.2.
+        self.assertIs(get_origin(Literal[42]), Literal)
+        if PY39:
+            self.assertEqual(get_origin(list[int]), list)
         if GENERIC_TUPLE_PARAMETRIZABLE:
             tp = List[Tuple[T, T]][int]
             self.assertEqual(get_origin(tp), list if NEW_TYPING else List)
@@ -304,6 +363,8 @@
         if EXISTING_UNIONS_SUBSCRIPTABLE:
             self.assertEqual(get_parameters(Union[S_co, Tuple[T, T]][int, U]), 
(U,))
         self.assertEqual(get_parameters(Mapping[T, Tuple[S_co, T]]), (T, S_co))
+        if PY39:
+            self.assertEqual(get_parameters(dict[int, T]), (T,))
 
     @skipIf(NEW_TYPING, "Not supported in Python 3.7")
     def test_last_args(self):
@@ -359,12 +420,28 @@
             self.assertEqual(get_args(ClassVar, evaluate=True), ())
             self.assertEqual(get_args(ClassVar[int], evaluate=True), (int,))
 
+        # Final special-casing
+        if WITH_FINAL:
+            self.assertEqual(get_args(Final, evaluate=True), ())
+            self.assertEqual(get_args(Final[int], evaluate=True), (int,))
+
         # Literal special-casing
         if WITH_LITERAL:
             self.assertEqual(get_args(Literal, evaluate=True), ())
             self.assertEqual(get_args(Literal["value"], evaluate=True), 
("value",))
             self.assertEqual(get_args(Literal[1, 2, 3], evaluate=True), (1, 2, 
3))
 
+        if PY39:
+            self.assertEqual(get_args(list[int]), (int,))
+            self.assertEqual(get_args(tuple[int, str]), (int, str))
+            self.assertEqual(get_args(list[list[int]]), (list[int],))
+            # This would return (~T,) before Python 3.9.
+            self.assertEqual(get_args(List), ())
+
+        if sys.version_info >= (3, 10):
+            self.assertEqual(get_args(int | str), (int, str))
+            self.assertEqual(get_args((int | tuple[T, int])[str]), (int, 
tuple[str, int]))
+
     def test_bound(self):
         T = TypeVar('T')
         TB = TypeVar('TB', bound=int)
@@ -397,13 +474,22 @@
         self.assertEqual(get_generic_bases(int), ())
 
     @skipUnless(PY36, "Python 3.6 required")
-    def test_typed_dict(self):
-        TDOld = TypedDict("TDOld", {'x': int, 'y': int})
-        self.assertEqual(typed_dict_keys(TD), {'x': int, 'y': int})
+    def test_typed_dict_mypy_extension(self):
+        TDOld = METypedDict("TDOld", {'x': int, 'y': int})
+        self.assertEqual(typed_dict_keys(TDM), {'x': int, 'y': int})
+        self.assertEqual(typed_dict_keys(TDOld), {'x': int, 'y': int})
+        self.assertIs(typed_dict_keys(dict), None)
+        self.assertIs(typed_dict_keys(Other), None)
+        self.assertIsNot(typed_dict_keys(TDM), TDM.__annotations__)
+
+    @skipUnless(PY36, "Python 3.6 required")
+    def test_typed_dict_typing_extension(self):
+        TDOld = TETypedDict("TDOld", {'x': int, 'y': int})
+        self.assertEqual(typed_dict_keys(TDE), {'x': int, 'y': int})
         self.assertEqual(typed_dict_keys(TDOld), {'x': int, 'y': int})
         self.assertIs(typed_dict_keys(dict), None)
         self.assertIs(typed_dict_keys(Other), None)
-        self.assertIsNot(typed_dict_keys(TD), TD.__annotations__)
+        self.assertIsNot(typed_dict_keys(TDE), TDE.__annotations__)
 
     @skipIf(
         (3, 5, 2) > sys.version_info[:3] >= (3, 5, 0),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/typing_inspect-0.6.0/typing_inspect.egg-info/PKG-INFO 
new/typing_inspect-0.8.0/typing_inspect.egg-info/PKG-INFO
--- old/typing_inspect-0.6.0/typing_inspect.egg-info/PKG-INFO   2020-05-02 
12:12:22.000000000 +0200
+++ new/typing_inspect-0.8.0/typing_inspect.egg-info/PKG-INFO   2022-08-17 
15:58:06.000000000 +0200
@@ -1,19 +1,12 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: typing-inspect
-Version: 0.6.0
+Version: 0.8.0
 Summary: Runtime inspection utilities for typing module.
 Home-page: https://github.com/ilevkivskyi/typing_inspect
 Author: Ivan Levkivskyi
 Author-email: [email protected]
 License: MIT
-Description: Typing Inspect
-        ==============
-        
-        The "typing_inspect" module defines experimental API for runtime
-        inspection of types defined in the standard "typing" module.
-        
 Keywords: typing function annotations type hints hinting checking checker 
typehints typehinting typechecking inspect reflection introspection
-Platform: UNKNOWN
 Classifier: Development Status :: 3 - Alpha
 Classifier: Environment :: Console
 Classifier: Intended Audience :: Developers
@@ -27,4 +20,13 @@
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
 Classifier: Topic :: Software Development
+License-File: LICENSE
+
+Typing Inspect
+==============
+
+The "typing_inspect" module defines experimental API for runtime
+inspection of types defined in the standard "typing" module.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/typing_inspect-0.6.0/typing_inspect.py 
new/typing_inspect-0.8.0/typing_inspect.py
--- old/typing_inspect-0.6.0/typing_inspect.py  2020-05-02 11:57:55.000000000 
+0200
+++ new/typing_inspect-0.8.0/typing_inspect.py  2022-08-17 15:50:05.000000000 
+0200
@@ -8,24 +8,51 @@
 # NOTE: This module must support Python 2.7 in addition to Python 3.x
 
 import sys
-from mypy_extensions import _TypedDictMeta
+import types
+
+from mypy_extensions import _TypedDictMeta as _TypedDictMeta_Mypy
+
+# See comments in typing_extensions source on why the switch is at 3.9.2
+if (3, 4, 0) <= sys.version_info[:3] < (3, 9, 2):
+    from typing_extensions import _TypedDictMeta as _TypedDictMeta_TE
+elif sys.version_info[:3] >= (3, 9, 2):
+    # Situation with typing_extensions.TypedDict is complicated.
+    # Use the one defined in typing_extentions, and if there is none,
+    # fall back to typing.
+    try:
+        from typing_extensions import _TypedDictMeta as _TypedDictMeta_TE
+    except ImportError:
+        from typing import _TypedDictMeta as _TypedDictMeta_TE
+else:
+    # typing_extensions.TypedDict is a re-export from typing.
+    from typing import TypedDict
+    _TypedDictMeta_TE = type(TypedDict)
 
 NEW_TYPING = sys.version_info[:3] >= (3, 7, 0)  # PEP 560
 if NEW_TYPING:
     import collections.abc
 
+WITH_FINAL = True
 WITH_LITERAL = True
 WITH_CLASSVAR = True
+WITH_NEWTYPE = True
 LEGACY_TYPING = False
 
 if NEW_TYPING:
     from typing import (
-        Generic, Callable, Union, TypeVar, ClassVar, Tuple, _GenericAlias, 
ForwardRef
+        Generic, Callable, Union, TypeVar, ClassVar, Tuple, _GenericAlias,
+        ForwardRef, NewType,
     )
-    from typing_extensions import Literal
+    from typing_extensions import Final, Literal
+    if sys.version_info[:3] >= (3, 9, 0):
+        from typing import _SpecialGenericAlias
+        typingGenericAlias = (_GenericAlias, _SpecialGenericAlias, 
types.GenericAlias)
+    else:
+        typingGenericAlias = (_GenericAlias,)
 else:
     from typing import (
-        Callable, CallableMeta, Union, Tuple, TupleMeta, TypeVar, GenericMeta, 
_ForwardRef
+        Callable, CallableMeta, Union, Tuple, TupleMeta, TypeVar, GenericMeta,
+        _ForwardRef,
     )
     try:
         from typing import _Union, _ClassVar
@@ -36,13 +63,29 @@
         LEGACY_TYPING = True
 
     try:  # python 3.6
-        from typing_extensions import _Literal
+        from typing_extensions import _Final
     except ImportError:  # python 2.7
         try:
-            from typing import _Literal
+            from typing import _Final
+        except ImportError:
+            WITH_FINAL = False
+
+    try:  # python 3.6
+        from typing_extensions import Literal
+    except ImportError:  # python 2.7
+        try:
+            from typing import Literal
         except ImportError:
             WITH_LITERAL = False
 
+    try:  # python < 3.5.2
+        from typing_extensions import NewType
+    except ImportError:
+        try:
+            from typing import NewType
+        except ImportError:
+            WITH_NEWTYPE = False
+
 
 def _gorg(cls):
     """This function exists for compatibility with old typing versions."""
@@ -74,7 +117,7 @@
     """
     if NEW_TYPING:
         return (isinstance(tp, type) and issubclass(tp, Generic) or
-                isinstance(tp, _GenericAlias) and
+                isinstance(tp, typingGenericAlias) and
                 tp.__origin__ not in (Union, tuple, ClassVar, 
collections.abc.Callable))
     return (isinstance(tp, GenericMeta) and not
             isinstance(tp, (CallableMeta, TupleMeta)))
@@ -100,7 +143,7 @@
         get_origin(tp) is collections.abc.Callable  # Callable prior to Python 
3.7
     """
     if NEW_TYPING:
-        return (tp is Callable or isinstance(tp, _GenericAlias) and
+        return (tp is Callable or isinstance(tp, typingGenericAlias) and
                 tp.__origin__ is collections.abc.Callable or
                 isinstance(tp, type) and issubclass(tp, Generic) and
                 issubclass(tp, collections.abc.Callable))
@@ -126,7 +169,7 @@
         get_origin(tp) is tuple  # Tuple prior to Python 3.7
     """
     if NEW_TYPING:
-        return (tp is Tuple or isinstance(tp, _GenericAlias) and
+        return (tp is Tuple or isinstance(tp, typingGenericAlias) and
                 tp.__origin__ is tuple or
                 isinstance(tp, type) and issubclass(tp, Generic) and
                 issubclass(tp, tuple))
@@ -154,6 +197,25 @@
         return False
 
 
+def is_final_type(tp):
+    """Test if the type is a final type. Examples::
+
+        is_final_type(int) == False
+        is_final_type(Final) == True
+        is_final_type(Final[int]) == True
+    """
+    if NEW_TYPING:
+        return (tp is Final or
+                isinstance(tp, typingGenericAlias) and tp.__origin__ is Final)
+    return WITH_FINAL and type(tp) is _Final
+
+
+try:
+    MaybeUnionType = types.UnionType
+except AttributeError:
+    MaybeUnionType = None
+
+
 def is_union_type(tp):
     """Test if the type is a union type. Examples::
 
@@ -161,18 +223,21 @@
         is_union_type(Union) == True
         is_union_type(Union[int, int]) == False
         is_union_type(Union[T, int]) == True
+        is_union_type(int | int) == False
+        is_union_type(T | int) == True
     """
     if NEW_TYPING:
         return (tp is Union or
-                isinstance(tp, _GenericAlias) and tp.__origin__ is Union)
+                (isinstance(tp, typingGenericAlias) and tp.__origin__ is 
Union) or
+                (MaybeUnionType and isinstance(tp, MaybeUnionType)))
     return type(tp) is _Union
 
 
 def is_literal_type(tp):
     if NEW_TYPING:
         return (tp is Literal or
-                isinstance(tp, _GenericAlias) and tp.__origin__ is Literal)
-    return WITH_LITERAL and type(tp) is _Literal
+                isinstance(tp, typingGenericAlias) and tp.__origin__ is 
Literal)
+    return WITH_LITERAL and type(tp) is type(Literal)
 
 
 def is_typevar(tp):
@@ -196,7 +261,7 @@
     """
     if NEW_TYPING:
         return (tp is ClassVar or
-                isinstance(tp, _GenericAlias) and tp.__origin__ is ClassVar)
+                isinstance(tp, typingGenericAlias) and tp.__origin__ is 
ClassVar)
     elif WITH_CLASSVAR:
         return type(tp) is _ClassVar
     else:
@@ -207,10 +272,24 @@
     """Tests if the type represents a distinct type. Examples::
 
         is_new_type(int) == False
+        is_new_type(NewType) == True
         is_new_type(NewType('Age', int)) == True
         is_new_type(NewType('Scores', List[Dict[str, float]])) == True
     """
-    return getattr(tp, '__supertype__', None) is not None
+    if not WITH_NEWTYPE:
+        return False
+    elif sys.version_info[:3] >= (3, 10, 0) and sys.version_info.releaselevel 
!= 'beta':
+        return tp is NewType or isinstance(tp, NewType)
+    elif sys.version_info[:3] >= (3, 0, 0):
+        return (tp is NewType or
+                (getattr(tp, '__supertype__', None) is not None and
+                 getattr(tp, '__qualname__', '') == 
'NewType.<locals>.new_type' and
+                 tp.__module__ in ('typing', 'typing_extensions')))
+    else:  # python 2
+        # __qualname__ is not available in python 2, so we simplify the test 
here
+        return (tp is NewType or
+                (getattr(tp, '__supertype__', None) is not None and
+                 tp.__module__ in ('typing', 'typing_extensions')))
 
 
 def is_forward_ref(tp):
@@ -262,7 +341,7 @@
         get_origin(List[Tuple[T, T]][int]) == list  # List prior to Python 3.7
     """
     if NEW_TYPING:
-        if isinstance(tp, _GenericAlias):
+        if isinstance(tp, typingGenericAlias):
             return tp.__origin__ if tp.__origin__ is not ClassVar else None
         if tp is Generic:
             return Generic
@@ -273,6 +352,8 @@
         return Union
     if is_tuple_type(tp):
         return Tuple
+    if is_literal_type(tp):
+        return Literal
 
     return None
 
@@ -327,7 +408,7 @@
         else:
             return ()
     elif NEW_TYPING:
-        if (isinstance(tp, _GenericAlias) or
+        if (isinstance(tp, typingGenericAlias) or
                 isinstance(tp, type) and issubclass(tp, Generic) and
                 tp is not Generic):
             return tp.__parameters__
@@ -427,13 +508,16 @@
     if NEW_TYPING:
         if evaluate is not None and not evaluate:
             raise ValueError('evaluate can only be True in Python >= 3.7')
-        if isinstance(tp, _GenericAlias):
+        # Note special aliases on Python 3.9 don't have __args__.
+        if isinstance(tp, typingGenericAlias) and hasattr(tp, '__args__'):
             res = tp.__args__
             if get_origin(tp) is collections.abc.Callable and res[0] is not 
Ellipsis:
                 res = (list(res[:-1]), res[-1])
             return res
+        if MaybeUnionType and isinstance(tp, MaybeUnionType):
+            return tp.__args__
         return ()
-    if is_classvar(tp):
+    if is_classvar(tp) or is_final_type(tp):
         return (tp.__type__,) if tp.__type__ is not None else ()
     if is_literal_type(tp):
         return tp.__values__ or ()
@@ -449,7 +533,7 @@
                 # backport of union's subs_tree
                 tree = _union_subs_tree(tp)
             elif is_generic_type(tp):
-                # backport of genericmeta's subs_tree
+                # backport of GenericMeta's subs_tree
                 tree = _generic_subs_tree(tp)
             elif is_tuple_type(tp):
                 # ad-hoc (inspired by union)
@@ -547,7 +631,7 @@
         typed_dict_keys(dict) == None
         typed_dict_keys(Other) == None
     """
-    if isinstance(td, _TypedDictMeta):
+    if isinstance(td, (_TypedDictMeta_Mypy, _TypedDictMeta_TE)):
         return td.__annotations__.copy()
     return None
 

Reply via email to