archrelease: copy trunk to community-any
[ArchLinux/community.git] / monkeytype / trunk / py3.9.patch
blob485736c452d55febef253162e4f2581f805c2aa3
1 commit 6a60845958efffcec987ed1c6ce90e74cf7c8456
2 Author: Felix Yan <felixonmars@archlinux.org>
3 Date: Sat Nov 21 05:50:14 2020 +0800
5 Fix compatibility with Python 3.9
7 Fixes #205, all tests are passing here.
9 diff --git a/monkeytype/compat.py b/monkeytype/compat.py
10 index 01d5007..111d28e 100644
11 --- a/monkeytype/compat.py
12 +++ b/monkeytype/compat.py
13 @@ -22,8 +22,16 @@ try:
14 def is_union(typ: Any) -> bool:
15 return typ is Union or is_generic(typ) and typ.__origin__ is Union
17 - def is_generic(typ: Any) -> bool:
18 - return typ is Union or isinstance(typ, _GenericAlias)
19 + try:
20 + # Python 3.9
21 + from typing import _SpecialGenericAlias
23 + def is_generic(typ: Any) -> bool:
24 + return typ is Union or isinstance(typ, _GenericAlias) or isinstance(typ, _SpecialGenericAlias)
26 + except ImportError:
27 + def is_generic(typ: Any) -> bool:
28 + return typ is Union or isinstance(typ, _GenericAlias)
30 def is_generic_of(typ: Any, gen: Any) -> bool:
31 return is_generic(typ) and typ.__origin__ is gen.__origin__