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

Strange failure in _recursion_check with "AttributeError: type object 'Empty' has no attribute '__origin__'" #88

Closed dbarnett closed 4 years ago

dbarnett commented 4 years ago

I'm running into a lot of errors like this on python 3.7.3:

Traceback (most recent call last):
  File "tests/test_bom.py", line 80, in test_minimal
    self.assertSequenceEqual(b.most_common_parts(5), [])
  File "/lib/python3.7/site-packages/pytypes/typechecker.py", line 883, in checker_tp
    slf or clsm, parent_class, True, prop_getter, bound_typevars=bound_typevars)
  File "/lib/python3.7/site-packages/pytypes/typechecker.py", line 707, in _checkfuncresult
    _recursion_check, False, func)
  File "/lib/python3.7/site-packages/pytypes/typechecker.py", line 671, in _checkinstance
    bound_typevars_readonly, follow_fwd_refs, _recursion_check), obj
  File "/lib/python3.7/site-packages/pytypes/type_util.py", line 1904, in _isinstance
    bound_typevars_readonly, follow_fwd_refs, _recursion_check)
  File "/lib/python3.7/site-packages/pytypes/type_util.py", line 1769, in _issubclass
    bound_typevars_readonly, follow_fwd_refs, _recursion_check)
  File "/lib/python3.7/site-packages/pytypes/type_util.py", line 1799, in _issubclass_2
    bound_typevars_readonly, follow_fwd_refs, _recursion_check)
  File "/lib/python3.7/site-packages/pytypes/type_util.py", line 1310, in _issubclass_Generic
    bound_typevars_readonly, follow_fwd_refs, _recursion_check):
  File "/lib/python3.7/site-packages/pytypes/type_util.py", line 1769, in _issubclass
    bound_typevars_readonly, follow_fwd_refs, _recursion_check)
  File "/lib/python3.7/site-packages/pytypes/type_util.py", line 1799, in _issubclass_2
    bound_typevars_readonly, follow_fwd_refs, _recursion_check)
  File "/lib/python3.7/site-packages/pytypes/type_util.py", line 1293, in _issubclass_Generic
    if subclass.__origin__ is None:
AttributeError: type object 'Empty' has no attribute '__origin__'

I saw a similar error reported in #59 and I am using py 3.7, but not using is_of_type or anything like that. What does this error mean, and what options do I have if I see it?

Stewori commented 4 years ago

Are you using pytypes from pip? If so, that doesn't support Python 3.7. Current master supports 3.7 and 3.8 mostly, see #40.

dbarnett commented 4 years ago

Ohhhh, okay, I misread the "not python 3.7 ready yet" comment in #59. This is a duplicate then. I'll just need to figure out how to install from master and/or get python 3.8 on my pixelbook.

Stewori commented 4 years ago

get python 3.8 on my pixelbook

3.8 is the same situation as 3.7. Only 3.6 or .5 would make a difference.

pip install git+https://github.com/Stewori/pytypes.git should install the master branch, but I personally never tested this way.

dbarnett commented 4 years ago

Perfect, thanks! I confirmed pip install git+https://github.com/Stewori/pytypes.git works and does fix the issues I was running into.

Feel free to dupe this to #40.