[issue45081] dataclasses that inherit from Protocol subclasses have wrong __init__
Ian Good
report at bugs.python.org
Sat Sep 11 17:01:11 EDT 2021
Ian Good <icgood at gmail.com> added the comment:
I believe this was a deeper issue that affected all classes inheriting Protocol, causing a TypeError on even the most basic case (see attached):
Traceback (most recent call last):
File "/.../test.py", line 14, in <module>
MyClass()
File "/.../test.py", line 11, in __init__
super().__init__()
File "/usr/local/Cellar/python at 3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 1083, in _no_init
raise TypeError('Protocols cannot be instantiated')
TypeError: Protocols cannot be instantiated
This was a new regression in 3.9.7 and seems to be resolved by this fix. The desired behavior should be supported according to PEP 544: https://www.python.org/dev/peps/pep-0544/#explicitly-declaring-implementation
----------
nosy: +icgood
Added file: https://bugs.python.org/file50277/test.py
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45081>
_______________________________________
More information about the Python-bugs-list
mailing list