Answer the question
In order to leave comments, you need to log in
How to properly clean the generic type from parameters: List[str] -> List?
In python3.7, backwards compatibility was broken in terms of generic type checking:
$ python3.6 -c "import typing; print(issubclass(typing.List[str], typing.List))"
True
$ python3.8 -c "import typing; print(issubclass(typing.List[str], typing.List))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.8/typing.py", line 774, in __subclasscheck__
raise TypeError("Subscripted generics cannot be used with"
TypeError: Subscripted generics cannot be used with class and instance checks
And how correctly elegantly and briefly clean the type description from the parameters.
getattr(typing, List[str]._name)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question