-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Match on Enum with dataclass decorator #114803
Comments
Can you please explain your use-case a little bit more? It is uncommon to use |
Agreed with @sobolevn: it's not clear why you'd want to do this. But if it is important, we'd probably need to add a parameter to |
@ericvsmith, I tried deleting >>> Color.Red == Color.Green
True Perhaps the better solution is to reject enums as dataclasses? I am unclear on what benefit a dataclass-enum would offer, since all members are already defined by the time the decorator gets control. |
I don't think Honestly, this isn't an issue with |
Hello,
That makes sense to me. |
I can clearly see that this is reasonable. However, this will come with several downsides:
So, maybe just close the issue for now? If this problem prooves to be common, we can get back to it. |
Perhaps a doc update stating that the proper way to use The link in the enum HowTo document is |
…H-114891) Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Ethan Furman <[email protected]>
…nums (pythonGH-114891) Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Ethan Furman <[email protected]>
…nums (pythonGH-114891) Co-authored-by: Kirill Podoprigora <[email protected]> Co-authored-by: Ethan Furman <[email protected]>
Bug report
Bug description:
Hello,
when Enum with @DataClass decorator is used in a match statement, the results seem to be wrong. Consider this example:
I think it should print:
but it prints:
I would suggest this either prints the expected result, or at least produces some error instead of the current behaviour.
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Linked PRs
@dataclass
should not be applied on enums #114891The text was updated successfully, but these errors were encountered: