File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -497,13 +497,30 @@ the :meth:`~Enum.__repr__` omits the inherited class' name. For example::
497
497
>>> Creature.DOG
498
498
<Creature.DOG: size='medium', legs=4>
499
499
500
- Use the :func: `! dataclass ` argument ``repr=False ``
500
+ Use the :func: `~dataclasses. dataclass ` argument ``repr=False ``
501
501
to use the standard :func: `repr `.
502
502
503
503
.. versionchanged :: 3.12
504
504
Only the dataclass fields are shown in the value area, not the dataclass'
505
505
name.
506
506
507
+ .. note ::
508
+
509
+ Adding :func: `~dataclasses.dataclass ` decorator to :class: `Enum `
510
+ and its subclasses is not supported. It will not raise any errors,
511
+ but it will produce very strange results at runtime, such as members
512
+ being equal to each other::
513
+
514
+ >>> @dataclass # don't do this: it does not make any sense
515
+ ... class Color(Enum):
516
+ ... RED = 1
517
+ ... BLUE = 2
518
+ ...
519
+ >>> Color.RED is Color.BLUE
520
+ False
521
+ >>> Color.RED == Color.BLUE # problem is here: they should not be equal
522
+ True
523
+
507
524
508
525
Pickling
509
526
--------
You can’t perform that action at this time.
0 commit comments