Skip to content

enum: More changes for 3.11 - #7862

Merged
JelleZijlstra merged 3 commits into
python:masterfrom
AlexWaygood:enum311
May 19, 2022
Merged

JelleZijlstra merged 3 commits into
python:masterfrom
AlexWaygood:enum311

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented May 18, 2022 •

Copy link
Copy Markdown
Member

In 3.11+, enum.Flags are iterable and sized:

C:\Users\alexw\coding\cpython>python
Running Debug|x64 interpreter...
Python 3.12.0a0 (main, May 17 2022, 16:54:26) [MSC v.1931 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from enum import *
>>> class Foo(Flag):
...     X = 1
...     Y = 2
...     Z = X | Y
...
>>> len(Foo.X)
1
>>> len(Foo.Z)
2
>>> list(Foo.X)
[<Foo.X: 1>]
>>> list(Foo.Z)
[<Foo.X: 1>, <Foo.Y: 2>]

CPython changes:

Comment thread stdlib/enum.pyi Resolved
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra
JelleZijlstra merged commit 04dde4d into python:master May 19, 2022
@AlexWaygood
AlexWaygood deleted the enum311 branch May 19, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants