Accepting request 880397 from home:bnavigator:branches:devel:languages:python
- Add typing_inspect-pr69-py39-GenericAlias.patch to support Python 3.9 -- gh#ilevkivskyi/typing_inspect#69 OBS-URL: https://build.opensuse.org/request/show/880397 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-typing-inspect?expand=0&rev=3
This commit is contained in:
parent
1828143089
commit
b53468ef28
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Sun Mar 21 13:52:12 UTC 2021 - Ben Greiner <code@bnavigator.de>
|
||||
|
||||
- Add typing_inspect-pr69-py39-GenericAlias.patch to support
|
||||
Python 3.9 -- gh#ilevkivskyi/typing_inspect#69
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Jul 4 03:54:20 AM UTC 2020 - John Vandenberg <jayvdb@gmail.com>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-typing-inspect
|
||||
#
|
||||
# Copyright (c) 2020 SUSE LLC
|
||||
# Copyright (c) 2021 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -25,6 +25,8 @@ 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
|
||||
@ -43,7 +45,7 @@ BuildRequires: %{python_module typing_extensions >= 3.7.4}
|
||||
Python runtime inspection utilities for typing module.
|
||||
|
||||
%prep
|
||||
%setup -q -n typing_inspect-%{version}
|
||||
%autosetup -p1 -n typing_inspect-%{version}
|
||||
|
||||
%build
|
||||
%python_build
|
||||
|
88
typing_inspect-pr69-py39-GenericAlias.patch
Normal file
88
typing_inspect-pr69-py39-GenericAlias.patch
Normal file
@ -0,0 +1,88 @@
|
||||
diff --git a/typing_inspect.py b/typing_inspect.py
|
||||
index 2444027..896f1a9 100644
|
||||
--- a/typing_inspect.py
|
||||
+++ b/typing_inspect.py
|
||||
@@ -23,6 +23,11 @@ if NEW_TYPING:
|
||||
Generic, Callable, Union, TypeVar, ClassVar, Tuple, _GenericAlias, ForwardRef
|
||||
)
|
||||
from typing_extensions import Literal
|
||||
+ if sys.version_info[:3] >= (3, 9, 0):
|
||||
+ from typing import _SpecialGenericAlias
|
||||
+ typingGenericAlias = (_GenericAlias, _SpecialGenericAlias)
|
||||
+ else:
|
||||
+ typingGenericAlias = (_GenericAlias, )
|
||||
else:
|
||||
from typing import (
|
||||
Callable, CallableMeta, Union, Tuple, TupleMeta, TypeVar, GenericMeta, _ForwardRef
|
||||
@@ -74,7 +79,7 @@ def is_generic_type(tp):
|
||||
"""
|
||||
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 +105,7 @@ def is_callable_type(tp):
|
||||
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 +131,7 @@ def is_tuple_type(tp):
|
||||
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))
|
||||
@@ -164,14 +169,14 @@ def is_union_type(tp):
|
||||
"""
|
||||
if NEW_TYPING:
|
||||
return (tp is Union or
|
||||
- isinstance(tp, _GenericAlias) and tp.__origin__ is Union)
|
||||
+ isinstance(tp, typingGenericAlias) and tp.__origin__ is Union)
|
||||
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)
|
||||
+ isinstance(tp, typingGenericAlias) and tp.__origin__ is Literal)
|
||||
return WITH_LITERAL and type(tp) is _Literal
|
||||
|
||||
|
||||
@@ -196,7 +201,7 @@ def is_classvar(tp):
|
||||
"""
|
||||
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:
|
||||
@@ -262,7 +267,7 @@ def get_origin(tp):
|
||||
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
|
||||
@@ -327,7 +332,7 @@ def get_parameters(tp):
|
||||
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__
|
||||
|
Loading…
Reference in New Issue
Block a user