You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue using Protocol as a base class with Python 3.5.2 #734
Seems that _generic_new implementation from typing_extensions module is outdated or incorrect. When typing_extensions relies on its own implementation of _generic_new I get the following error.
Script to reproduce:
import abc
from typing_extensions import Protocol, runtime_checkable
@runtime_checkable
class Proto(Protocol):
@abc.abstractmethod
def foo(self):
pass
class SomeClass(Proto):
def __init__(self, some_arg):
pass
def foo(self):
return 5
x = SomeClass(3)
Traceback:
Traceback (most recent call last):
File "/Users/dikobraz/repro.py", line 20, in <module>
x = SomeClass(3)
File "/Users/dikobraz/env-py-3.5-tf-2/lib/python3.5/site-packages/typing_extensions.py", line 1357, in __new__
return _generic_new(cls.__next_in_mro__, cls, *args, **kwds)
File "/Users/dikobraz/env-py-3.5-tf-2/lib/python3.5/site-packages/typing_extensions.py", line 87, in _generic_new
return base_cls.__new__(cls, *args, **kwargs)
TypeError: object() takes no parameters
Could you try this with a newer version? 3.5 is nearing its end of life, and the latest version is 3.5.9. The latest version for which I can find downloadable binaries is 3.5.4: https://www.python.org/downloads/release/python-354/
If your problem is specifically with 3.5.2, I'm not sure that we can do much for you unless you can come up with a fix (I don't even have 3.5 installed on my machine any more).
Thank you @gvanrossum for the quick reply. I've verified that it works with 3.5.9 because it comes with newer typing module and typing_extensions module is just using _generic_new from typing.
Maybe we can just use _generic_new from more recent version of typing module before it was removed completely in this PR (python/cpython#4906):
However, since Python 3.5 nearing its end of life maybe it's not worth it. We just have 3.5.2 baked in our Docker images. What is your advise? Submit a PR for typing_extensions and see if it works or drop it? Worth noting though that Python 3.5.2 is default for Ubuntu 16.04 which is still widely used for deployment.
Activity
gvanrossum commentedon Jun 24, 2020
Could you try this with a newer version? 3.5 is nearing its end of life, and the latest version is 3.5.9. The latest version for which I can find downloadable binaries is 3.5.4: https://www.python.org/downloads/release/python-354/
If your problem is specifically with 3.5.2, I'm not sure that we can do much for you unless you can come up with a fix (I don't even have 3.5 installed on my machine any more).
Slonegg commentedon Jun 24, 2020
Thank you @gvanrossum for the quick reply. I've verified that it works with 3.5.9 because it comes with newer
typingmodule andtyping_extensionsmodule is just using_generic_newfromtyping.Maybe we can just use
_generic_newfrom more recent version oftypingmodule before it was removed completely in this PR (python/cpython#4906):However, since Python 3.5 nearing its end of life maybe it's not worth it. We just have 3.5.2 baked in our Docker images. What is your advise? Submit a PR for
typing_extensionsand see if it works or drop it? Worth noting though that Python 3.5.2 is default for Ubuntu 16.04 which is still widely used for deployment.gvanrossum commentedon Jun 24, 2020
I strongly advise you to upgrade your Python version.