]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-103596: [Enum] do not shadow mixed-in methods/attributes (GH-103600)
authorEthan Furman <ethan@stoneleaf.us>
Tue, 18 Apr 2023 23:19:23 +0000 (16:19 -0700)
committerGitHub <noreply@github.com>
Tue, 18 Apr 2023 23:19:23 +0000 (16:19 -0700)
commit700ec657c80e78fb299963ffaa684c859ddb8f87
tree61a25f3c6ed737451201814626b8af53e23db6ba
parent07804ce24c3103ee1bb141af31b9a1a0f92f5e43
gh-103596: [Enum] do not shadow mixed-in methods/attributes (GH-103600)

For example:

    class Book(StrEnum):
        title = auto()
        author = auto()
        desc = auto()

    Book.author.desc is Book.desc

but

    Book.author.title() == 'Author'

is commonly expected.  Using upper-case member names avoids this confusion and possible performance impacts.

Co-authored-by: samypr100 <3933065+samypr100@users.noreply.github.com>
Doc/howto/enum.rst
Doc/library/enum.rst
Lib/enum.py
Lib/test/test_enum.py
Misc/NEWS.d/next/Library/2023-04-17-14-47-28.gh-issue-103596.ME1y3_.rst [new file with mode: 0644]