aboutsummaryrefslogtreecommitdiff
From 16919e21936179e53df2f376c8b59b5fc44bd2dd Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Fri, 15 Jan 2021 09:22:52 -0500
Subject: [PATCH] Fix for Python 3.9+.

Fixes <https://github.com/ilevkivskyi/typing_inspect/issues/60>.

Based on an idea in
https://github.com/ilevkivskyi/typing_inspect/issues/60#issuecomment-683187584.
---
 typing_inspect.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/typing_inspect.py b/typing_inspect.py
index 1ca68ed..31d05ee 100644
--- a/typing_inspect.py
+++ b/typing_inspect.py
@@ -21,7 +21,7 @@ LEGACY_TYPING = False
 
 if NEW_TYPING:
     from typing import (
-        Generic, Callable, Union, TypeVar, ClassVar, Tuple, _GenericAlias, ForwardRef
+        Generic, Callable, Union, TypeVar, ClassVar, Tuple, _GenericAlias, _SpecialGenericAlias, ForwardRef
     )
     from typing_extensions import Literal
 else:
@@ -75,7 +75,7 @@ def is_generic_type(tp):
     """
     if NEW_TYPING:
         return (isinstance(tp, type) and issubclass(tp, Generic) or
-                isinstance(tp, _GenericAlias) and
+                (isinstance(tp, _GenericAlias) or isinstance(tp, _SpecialGenericAlias)) and
                 tp.__origin__ not in (Union, tuple, ClassVar, collections.abc.Callable))
     return (isinstance(tp, GenericMeta) and not
             isinstance(tp, (CallableMeta, TupleMeta)))
-- 
2.29.2