In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Commit 37f225a0 authored by eckhart's avatar eckhart

- toolkit.issubtype: Bugs for Python 3.7 fixed

parent d008de94
......@@ -112,20 +112,23 @@ def is_filename(strg: str) -> bool:
def issubtype(sub_type, base_type):
if sys.version_info.major <= 3 and sys.version_info.minor <= 6:
return issubclass(sub_type, base_type)
try:
base_type = base_type.__origin__
except AttributeError:
pass
try:
mro = inspect.getmro(sub_type)
except AttributeError:
mro = []
for t in sub_type.__mro_entries__([sub_type]):
mro.extend(inspect.getmro(t))
# print(" " if base_type in mro else "!", base_type, sub_type, mro)
return base_type in mro
# if sys.version_info.major <= 3 and sys.version_info.minor <= 6:
# return issubclass(sub_type, base_type)
# try:
# base_type = base_type.__origin__
# except AttributeError:
# pass
# try:
# sub_type = sub_type.__origin__
# except AttributeError:
# pass
def origin(t):
try:
ot = t.__origin__
except AttributeError:
return t
return ot if ot is not None else t
return issubclass(origin(sub_type), origin(base_type))
def isgenerictype(t):
......
......@@ -153,7 +153,7 @@ class TestStringHelpers:
class TestTypeSystemSupport:
def test_issubtype(self):
assert issubtype(typing.List, typing.List)
assert issubtype(typing.List, collections.abc.Sequence)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment