summaryrefslogtreecommitdiff
path: root/gnu/packages/patches/python-typing-inspect-fix.patch
blob: e6e28981b7ba9c5d0351c3e89314f1e9818e9d86 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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