Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-103596: [Enum] do not shadow mixed-in methods/attributes#103600

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanfurman merged 2 commits intopython:mainfromethanfurman:enum-no_shadow
Apr 18, 2023

Conversation

ethanfurman
Copy link
Member

@ethanfurmanethanfurman commentedApr 17, 2023
edited
Loading

For example:

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

but

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

Using upper-case member names avoids any possible confusion.

samypr100 reacted with rocket emoji
For example:    class Book(StrEnum):        title = auto()        author = auto()        desc = auto()    Book.author.desc is Book.descbut    Book.author.title() == 'Author'Using upper-case member names means this isn't an issue in practice.
@ethanfurmanethanfurman added type-bugAn unexpected behavior, bug, or error type-featureA feature request or enhancement stdlibPython modules in the Lib dir 3.12only security fixes labelsApr 17, 2023
@ethanfurmanethanfurman self-assigned thisApr 17, 2023
@ethanfurman
Copy link
MemberAuthor

Note that performance is only impacted when there is a name clash between member and existing attribute/method.

Co-authored-by: samypr100 <3933065+samypr100@users.noreply.github.com>
@ethanfurmanethanfurman merged commit700ec65 intopython:mainApr 18, 2023
@ethanfurmanethanfurman deleted the enum-no_shadow branchApril 18, 2023 23:19
carljm added a commit to carljm/cpython that referenced this pull requestApr 20, 2023
* main: (24 commits)pythongh-98040: Move the Single-Phase Init Tests Out of test_imp (pythongh-102561)pythongh-83861: Fix datetime.astimezone() method (pythonGH-101545)pythongh-102856: Clean some of the PEP 701 tokenizer implementation (python#103634)pythongh-102856: Skip test_mismatched_parens in WASI builds (python#103633)pythongh-102856: Initial implementation of PEP 701 (python#102855)pythongh-103583: Add ref. dependency between multibytecodec modules (python#103589)pythongh-83004: Harden msvcrt further (python#103420)pythonGH-88342: clarify that `asyncio.as_completed` accepts generators yielding tasks (python#103626)pythongh-102778: IDLE - make sys.last_exc available in Shell after traceback (python#103314)pythongh-103582: Remove last references to `argparse.REMAINDER` from docs (python#103586)pythongh-103583: Always pass multibyte codec structs as const (python#103588)pythongh-103617: Fix compiler warning in _iomodule.c (python#103618)pythongh-103596: [Enum] do not shadow mixed-in methods/attributes (pythonGH-103600)pythonGH-100530: Change the error message for non-class class patterns (pythonGH-103576)pythongh-95299: Remove lingering setuptools reference in installer scripts (pythonGH-103613)  [Doc] Fix a typo in optparse.rst (python#103504)pythongh-101100: Fix broken reference `__format__` in `string.rst` (python#103531)pythongh-95299: Stop installing setuptools as a part of ensurepip and venv (python#101039)pythonGH-103484: Docs: add linkcheck allowed redirects entries for most cases (python#103569)pythongh-67230: update whatsnew note for csv changes (python#103598)  ...
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@samypr100samypr100samypr100 left review comments

Assignees

@ethanfurmanethanfurman

Labels
3.12only security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or errortype-featureA feature request or enhancement
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@ethanfurman@samypr100@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp