KEMBAR78
gh-114071: [Enum] update docs and code for tuples/subclasses by ethanfurman · Pull Request #114871 · python/cpython · GitHub
Skip to content

Conversation

@ethanfurman
Copy link
Member

@ethanfurman ethanfurman commented Feb 1, 2024

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))
# 4 5 6

it made sense to also support tuple subclasses in enum definitions.

Documentation was also updated to include entries for __init__ and __new__.


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

@ethanfurman ethanfurman added docs Documentation in the Doc dir stdlib Standard Library Python modules in the Lib/ directory 3.12 only security fixes 3.13 bugs and security fixes needs backport to 3.12 only security fixes labels Feb 1, 2024
@ethanfurman ethanfurman self-assigned this Feb 1, 2024
@ethanfurman ethanfurman added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 2, 2024
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @ethanfurman for commit ed0daa7 🤖

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 2, 2024
@ethanfurman ethanfurman merged commit ff7588b into python:main Feb 4, 2024
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 4, 2024
…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>
@bedevere-app
Copy link

bedevere-app bot commented Feb 4, 2024

GH-114993 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 4, 2024
ethanfurman added a commit that referenced this pull request Feb 8, 2024
…H-114871) (GH-114993)

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>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…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))
    # 4 5 6

it made sense to also support tuple subclasses in enum definitions.
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request Feb 14, 2024
…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))
    # 4 5 6

it made sense to also support tuple subclasses in enum definitions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.12 only security fixes 3.13 bugs and security fixes docs Documentation in the Doc dir stdlib Standard Library Python modules in the Lib/ directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants