-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: descriptor '__subclasses__' of 'type' object needs an argument #266
Comments
FWIW a sufficient repro is
I also have a tentative fix -- simply don't inherit Type from type. That makes this problem go away and still passes the test. But I'm not sure how comfortable I am with that. Then again, I don't think subclassing Type[] is valid anyways, nor would using it in an isinstance() call. And I'm willing to give up subclass() calls too. @ilevkivskyi What do you think? |
@gvanrossum I am fine with your fix. I would say that for every class from In any case, we could fine-tune some details later (if necessary) in the process of resolution of #136 |
OK, that's sound reasoning. I will merge the fix. |
Due to unforeseen circumstances, readthedocs cannot render our documentation because we use a certain typing construction that errors on the Python 3.5 version that ReadTheDocs uses. We need to import pylint in order to construct the dynamic list of features, so the only choice right now is to remove these annotations from the codebase, although it would be great if ReadTheDocs would use a more recent version of Python: python/typing#266
Older typing versions don't allow what we did[1]. We don't really need to be that precise here anyway. The error: $ python Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import zeroconf Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/scraper/venv/lib/python3.5/site-packages/zeroconf.py", line 320, in <module> OptionalExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] File "/usr/lib/python3.5/typing.py", line 649, in __getitem__ return Union[arg, type(None)] File "/usr/lib/python3.5/typing.py", line 552, in __getitem__ dict(self.__dict__), parameters, _root=True) File "/usr/lib/python3.5/typing.py", line 512, in __new__ for t2 in all_params - {t1} if not isinstance(t2, TypeVar)): File "/usr/lib/python3.5/typing.py", line 512, in <genexpr> for t2 in all_params - {t1} if not isinstance(t2, TypeVar)): File "/usr/lib/python3.5/typing.py", line 1077, in __subclasscheck__ if super().__subclasscheck__(cls): File "/usr/lib/python3.5/abc.py", line 225, in __subclasscheck__ for scls in cls.__subclasses__(): TypeError: descriptor '__subclasses__' of 'type' object needs an argument Closes #141 Fixes: 1f33c4f ("Introduce some static type analysis to the codebase") [1] python/typing#266
This is still an issue on Python 3.5, mypy 0.641. |
@devxpy: Do you have an example of code that fails. At least the second examples by @gvanrossum above pass fine for me with Python 3.5.6. What version of Python 3.5 were you using? |
@srittau Sorry for not providing this earlier
Will update to 3.5.6 now.. |
@devxpy, |
I am on an Ubuntu 16.04.6 system, and I am getting this error for python 3.5.6 |
PiperOrigin-RevId: 264469211
PiperOrigin-RevId: 264469211
On Ubuntu 16.04, which has Python 3.5.2, this raised `TypeError: descriptor '__subclasses__' of 'type' object needs an argument` (python/typing#266). Signed-off-by: Anders Kaseorg <[email protected]>
On Ubuntu 16.04, which has Python 3.5.2, this raised `TypeError: descriptor '__subclasses__' of 'type' object needs an argument` (python/typing#266). Signed-off-by: Anders Kaseorg <[email protected]>
With Python 3.5.2 (which is shipped with Ubuntu 16.04), placing a typing.Type into Union/Optional causes: TypeError: descriptor '__subclasses__' of 'type' object needs an argument This was fixed in Python 3.5.3 via: python/typing#266 Fixes #5099
Per python/typing#266, the issue was fixed in versions > 3.5.3.
Bump typing dependency because of python/typing#266. Signed-off-by: Filipe Laíns <[email protected]>
Bump typing dependency because of python/typing#266. Signed-off-by: Filipe Laíns <[email protected]>
Bump typing dependency because of python/typing#266. Signed-off-by: Filipe Laíns <[email protected]>
Behold:
produces a traceback:
The text was updated successfully, but these errors were encountered: