Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-99304: [Enum] clarify what constitutes a flag alias #99395

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 18 commits into from
Nov 12, 2022

Conversation

ethanfurman
Copy link
Member

@ethanfurman ethanfurman commented Nov 11, 2022

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Some low-level suggestions, and a couple high-level questions:

  • Shouldn't there be a .. versionchanged notice stating that the behavior of listing alias flags when iterating Flag enums was changed in 3.11? Per my testing, aliases for Flag enums are listed in 3.10 and before, but not in 3.11, and I can't find that explicitly noted anywhere in a versionchanged, at least that I can find.

  • Conversely, I can't seem to reproduce a change in the Flag inversion behavior comparing 3.11/3.12 with 3.10 or 3.9; all the previous versions had the same behavior stated here, as far as I could tell. The following is on Python 3.9:

    >>> from enum import Flag, auto
    >>> class Color(Flag):
    ...     RED = auto()
    ...     GREEN = auto()
    ...     BLUE = auto()
    ...
    >>> purple = Color.RED | Color.BLUE
    >>> white = Color.RED | Color.GREEN | Color.BLUE
    >>> ~white
    <Color.0: 0>
    >>> ~purple
    <Color.GREEN: 2>
    >>> ~Color.RED
    <Color.BLUE|GREEN: 6>

    Aside from the very small difference in the repr of white, this duplicates the 3.11+ results exactly, as far as I can tell. I get the same result on 3.10, too. Is there something I'm missing here?

@ethanfurman
Copy link
Member Author

@CAM-Gerlach Wow, a thousand thanks for that review! I added a version change note for the aliases, and negative numbers on inversion was an IntFlag issue, so I moved the note down to that section.

If you could double-check the last couple changes I would be grateful!

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some similar fixes as above, otherwise LGTM. Thanks @ethanfurman !

@CAM-Gerlach
Copy link
Member

Just FYI, if you want to avoid individually committing every suggestion, you can go to the Files Changed tab, click Add to batch on each suggestion you want, and then click Commit to commit them all in one go.

@ethanfurman ethanfurman merged commit 73a921b into python:main Nov 12, 2022
@miss-islington
Copy link
Contributor

Thanks @ethanfurman for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 12, 2022
…H-99395)

(cherry picked from commit 73a921b)

Co-authored-by: Ethan Furman <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
@bedevere-bot
Copy link

GH-99415 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Nov 12, 2022
ethanfurman added a commit that referenced this pull request Nov 12, 2022
…) (GH-99415)

gh-99304: [Enum] clarify what constitutes a flag alias (GH-99395)
(cherry picked from commit 73a921b)

Co-authored-by: Ethan Furman <[email protected]>
Co-authored-by: C.A.M. Gerlach <[email protected]>
@ethanfurman ethanfurman deleted the enum-docs branch November 12, 2022 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 only security fixes docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants