Stewori / pytypes

Typing-toolbox for Python 3 _and_ 2.7 w.r.t. PEP 484.
Apache License 2.0
200 stars 20 forks source link

RecursionError on is_subtype() #84

Closed jtrakk closed 4 years ago

jtrakk commented 4 years ago

I am getting an exception when trying to check for subtype. The result I expected is True.

In [22]: pytypes.is_subtype(typing.List[str], typing.Iterable)                                                                                                                                                                                                                                         
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
~/Documents/python-project/src/project/app.py in <module>
----> 1 pytypes.is_subtype(typing.List[str], typing.Iterable)

~/.cache/pypoetry/virtualenvs/project-x52CiU9p-py3.7/lib/python3.7/site-packages/pytypes/type_util.py in _issubclass(subclass, superclass, bound_Generic, bound_typevars, bound_typevars_readonly, follow_fwd_refs, _recursion_check)
   1767         return False
   1768     res = _issubclass_2(subclass, superclass, bound_Generic, bound_typevars,
-> 1769             bound_typevars_readonly, follow_fwd_refs, _recursion_check)
   1770     return res
   1771 

~/.cache/pypoetry/virtualenvs/project-x52CiU9p-py3.7/lib/python3.7/site-packages/pytypes/type_util.py in _issubclass_2(subclass, superclass, bound_Generic, bound_typevars, bound_typevars_readonly, follow_fwd_refs, _recursion_check)
   1797         else:
   1798             return _issubclass_Generic(subclass, superclass, bound_Generic, bound_typevars,
-> 1799                     bound_typevars_readonly, follow_fwd_refs, _recursion_check)
   1800     if subclass in _extra_dict:
   1801         subclass = _extra_dict[subclass]

~/.cache/pypoetry/virtualenvs/project-x52CiU9p-py3.7/lib/python3.7/site-packages/pytypes/type_util.py in _issubclass_Generic(subclass, superclass, bound_Generic, bound_typevars, bound_typevars_readonly, follow_fwd_refs, _recursion_check)
   1308                 _issubclass(_origin(subclass), origin, bound_Generic, bound_typevars,
   1309                         # In Python 3.7 this can currently cause infinite recursion.
-> 1310                         bound_typevars_readonly, follow_fwd_refs, _recursion_check):
   1311 #                               _issubclass(subclass.__origin__, origin, bound_Generic, bound_typevars,
   1312 #                                               bound_typevars_readonly, follow_fwd_refs, _recursion_check):

... last 3 frames repeated, from the frame below ...

~/.cache/pypoetry/virtualenvs/project-x52CiU9p-py3.7/lib/python3.7/site-packages/pytypes/type_util.py in _issubclass(subclass, superclass, bound_Generic, bound_typevars, bound_typevars_readonly, follow_fwd_refs, _recursion_check)
   1767         return False
   1768     res = _issubclass_2(subclass, superclass, bound_Generic, bound_typevars,
-> 1769             bound_typevars_readonly, follow_fwd_refs, _recursion_check)
   1770     return res
   1771 

RecursionError: maximum recursion depth exceeded in comparison

pytypes 1.0b5 cpython 3.7.3

Stewori commented 4 years ago

Please try this with current master. Many Python 3.7 compatibility issues were fixed since last release. No released pytypes version supports Python 3.7.

Stewori commented 4 years ago

A Python 3.7 and 3.8 compliant release is somewhat close but the last issue is nasty and requires some serious time that I cannot allocate at the moment. I really hope to file this compatibility release this year but cannot promise. Until then, master is your best bet.

jtrakk commented 4 years ago

It is fixed. Thank you.