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

Appearance settings

enum: More changes for 3.11#7862

Merged
JelleZijlstra merged 3 commits into
python:masterpython/typeshed:masterfrom
AlexWaygood:enum311AlexWaygood/typeshed:enum311Copy head branch name to clipboard
May 19, 2022
Merged

enum: More changes for 3.11#7862
JelleZijlstra merged 3 commits into
python:masterpython/typeshed:masterfrom
AlexWaygood:enum311AlexWaygood/typeshed:enum311Copy head branch name to clipboard

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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.