Explicitly declaring implementation of protocol broken for dataclasses #1121
Answered
by
srittau
Germandrummer92
asked this question in
Q&A
-
Hi, Marking a dataclass as explicitly implementing a protocol (as specified in https://peps.python.org/pep-0544/#explicitly-declaring-implementation) seems to make the dataclass not instantiatable anymore. This seems like a bug to me, but I am also not sure where to open it? bugs.python.org? from typing import Protocol
from dataclasses import dataclass
class SomeProtocol(Protocol):
@property
def some_value(self) -> str: ...
@dataclass
class SomeDataclasss(SomeProtocol):
some_value: str
if __name__ == '__main__':
a = SomeDataclasss(some_value="value") # this crashes with AttributeError: can't set attribute 'some_value' |
Beta Was this translation helpful? Give feedback.
Answered by
srittau
Apr 6, 2022
Replies: 2 comments
-
Yes, this sounds like a clear bug to me. bugs.python.org is the right place indeed. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Germandrummer92
-
thanks, opened an issue: https://bugs.python.org/issue47237 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, this sounds like a clear bug to me. bugs.python.org is the right place indeed.