10000 gh-114803: Mention that `@dataclass` should not be applied on enums by sobolevn · Pull Request #114891 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-114803: Mention that @dataclass should not be applied on enums #114891

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

Merged
merged 5 commits into from
Feb 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review
  • Loading branch information
sobolevn committed Feb 3, 2024
commit d13dd7f350a6236b091fb3814ba7bb77959949de
12 changes: 9 additions & 3 deletions Doc/howto/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,15 @@ to use the standard :func:`repr`.
and its subclasses is not supported. It will not raise any errors,
but it will produce very strange results at runtime::

@dataclass # don't do this: it does not make any sense
class Colors(Enum):
red = 'red'
>>> @dataclass # don't do this: it does not make any sense
... class Color(Enum):
... RED = 1
... BLUE = 2
...
>>> Color.RED is Color.BLUE
False
>>> Color.RED == Color.BLUE # problem is here: they should not be equal
True


Pickling
Expand Down
0