I believe bpo-44806: Fix __init__ in subclasses of protocols has caused a regression when using a Dataclass.
In Python 3.9.7, a dataclass that inherits from a subclass of typing.Protocol (i.e., a user-defined protocol), does not have the correct __init__.
Demonstration
fromdataclassesimportdataclassfromtypingimportProtocolclassP(Protocol):
pass@dataclassclassB(P):
value: strprint(B("test"))In 3.9.7:
Traceback (most recent call last):
File "test.py", line 11, in<module>
print(B("test"))
TypeError: B() takes no argumentsIn 3.9.6:
Affected Projects
I believe
bpo-44806: Fix __init__ in subclasses of protocolshas caused a regression when using a Dataclass.In Python
3.9.7, adataclassthat inherits from a subclass oftyping.Protocol(i.e., a user-defined protocol), does not have the correct__init__.Demonstration
In
3.9.7:In
3.9.6:B(value='test')Affected Projects