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

enable_global_annotations_decorator() crashes #77

Open jolaf opened 5 years ago

jolaf commented 5 years ago

The following code:

import pytypes
pytypes.enable_global_annotations_decorator()

crashes as follows:

Traceback (most recent call last):
  File "Test.py", line 2, in <module>
    pytypes.enable_global_annotations_decorator()
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/__init__.py", line 437, in enable_global_annotations_decorator
    _catch_up_global_annotations_decorator()
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2237, in _catch_up_global_annotations_decorator
    annotations_module(mod_name)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2198, in annotations_module
    annotations_class(memb)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2160, in annotations_class
    annotations_func(memb)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2144, in annotations_func
    infer_defaults = False)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 956, in _get_type_hints
    infer_defaults = infer_defaults)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 930, in _get_types
    clss = util.get_class_that_defined_method(func)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/util.py", line 419, in get_class_that_defined_method
    return meth.__self__
AttributeError: 'classmethod' object has no attribute '__self__'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
    import re, traceback
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/typechecker.py", line 93, in _pytypes___import__
    type_util.annotations_module(name)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2198, in annotations_module
    annotations_class(memb)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2160, in annotations_class
    annotations_func(memb)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2142, in annotations_func
    func.__annotations__ =  {}
AttributeError: 'property' object has no attribute '__annotations__'

Original exception was:
Traceback (most recent call last):
  File "Test.py", line 2, in <module>
    pytypes.enable_global_annotations_decorator()
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/__init__.py", line 437, in enable_global_annotations_decorator
    _catch_up_global_annotations_decorator()
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2237, in _catch_up_global_annotations_decorator
    annotations_module(mod_name)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2198, in annotations_module
    annotations_class(memb)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2160, in annotations_class
    annotations_func(memb)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 2144, in annotations_func
    infer_defaults = False)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 956, in _get_type_hints
    infer_defaults = infer_defaults)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/type_util.py", line 930, in _get_types
    clss = util.get_class_that_defined_method(func)
  File "/usr/local/lib/python3.6/dist-packages/pytypes-1.0b5.post23-py3.6.egg/pytypes/util.py", line 419, in get_class_that_defined_method
    return meth.__self__
AttributeError: 'classmethod' object has no attribute '__self__'