8000 [3.12] gh-114071: [Enum] update docs and code for tuples/subclasses (GH-114871) by miss-islington · Pull Request #114993 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.12] gh-114071: [Enum] update docs and code for tuples/subclasses (GH-114871) #114993

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 1 commit into from
Feb 8, 2024

Conversation

miss-islington
Copy link
Contributor
@miss-islington miss-islington commented Feb 4, 2024

Update documentation with __new__ and __init__ entries.

Support use of auto() in tuple subclasses on member assignment lines. Previously, auto() was only supported on the member definition line either solo or as part of a tuple:

RED = auto()
BLUE = auto(), 'azul'

However, since Python itself supports using tuple subclasses where tuples are expected, e.g.:

from collections import namedtuple
T = namedtuple('T', 'first second third')

def test(one, two, three):
    print(one, two, three)

test(*T(4, 5, 6))
GH- 4 5 6

it made sense to also support tuple subclasses in enum definitions.
(cherry picked from commit ff7588b)

Co-authored-by: Ethan Furman ethan@stoneleaf.us


📚 Documentation preview 📚: https://cpython-previews--114993.org.readthedocs.build/

…ythonGH-114871)

Update documentation with `__new__` and `__init__` entries.

Support use of `auto()` in tuple subclasses on member assignment lines.  Previously, auto() was only supported on the member definition line either solo or as part of a tuple:

    RED = auto()
    BLUE = auto(), 'azul'

However, since Python itself supports using tuple subclasses where tuples are expected, e.g.:

    from collections import namedtuple
    T = namedtuple('T', 'first second third')

    def test(one, two, three):
        print(one, two, three)

    test(*T(4, 5, 6))
    GH- 4 5 6

it made sense to also support tuple subclasses in enum definitions.
(cherry picked from commit ff7588b)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0