File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -925,3 +925,23 @@ Notes
925
925
>>> from enum import IntEnum
926
926
>>> class MyIntEnum(IntEnum):
927
927
... __str__ = IntEnum.__str__
928
+
929
+ Additionally, it's possible to end up shadowing a method or property from
930
+ a derived baseclass such as :meth: `str.title ` or :attr: `~numbers.Rational.numerator `,
931
+ which can cause unexpected issues at runtime.
932
+
933
+ Consider the following examples::
934
+
935
+ >>> from enum import StrEnum
936
+ >>> class MyStrEnum(StrEnum):
937
+ ... title = "RED"
938
+ >>> MyStrEnum.title.title()
939
+ Traceback (most recent call last):
940
+ ...
941
+ TypeError: 'MyStrEnum' object is not callable
942
+
943
+ >>> from enum import IntEnum
944
+ >>> class MyIntEnum(IntEnum):
945
+ ... numerator = 42
946
+ >>> MyIntEnum.numerator.numerator
947
+ <MyIntEnum.numerator: 42>
You can’t perform that action at this time.
0 commit comments