smarie/python-autoclass

error with python 3.5.2

antvig opened this issue · 3 comments

Hi,

I'm using python 3.5.2
The import of autoclass.autoprops raise the following error:
(ps. I updated the module typing)

Traceback (most recent call last):
  File "C:/Users/~/Desktop/test_autoclass.py", line 1, in <module>
    from autoclass import autoargs, autoprops, setter_override
  File "C:\Program Files\Anaconda3\lib\site-packages\autoclass\__init__.py", line 2, in <module>
    from autoclass.autoprops import *
  File "C:\Program Files\Anaconda3\lib\site-packages\autoclass\autoprops.py", line 169, in <module>
    def _get_getter_fun(object_type: Type, property_name: str, property_type: Optional[Type], private_property_name: str):
  File "C:\Program Files\Anaconda3\lib\typing.py", line 649, in __getitem__
    return Union[arg, type(None)]
  File "C:\Program Files\Anaconda3\lib\typing.py", line 552, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "C:\Program Files\Anaconda3\lib\typing.py", line 512, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "C:\Program Files\Anaconda3\lib\typing.py", line 512, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "C:\Program Files\Anaconda3\lib\typing.py", line 1077, in __subclasscheck__
    if super().__subclasscheck__(cls):
  File "C:\Program Files\Anaconda3\lib\abc.py", line 225, in __subclasscheck__
    for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument

Apparently this is due to the fact that conda still relies on the base module and not the backport. A solution (really not the best but it seems to work) is to delete the Lib/typing.py file (the base one) in your conda environment so that conda now searches in site-packages and finds the backport at site-packages/typing.py. Does it work for you ?

Just want to let others know, deleting Lib/typing.py is necessary as @smarie said.

Thanks for the confirmation ! I'll close the issue in this project as it is not related to autoclass per se, but let's keep an eye on the answer on python/typing :)