Skip to content

enum: update for py310#5314

Merged
Akuli merged 1 commit intopython:masterfrom
hauntsaninja:enum
May 4, 2021
Merged

enum: update for py310#5314
Akuli merged 1 commit intopython:masterfrom
hauntsaninja:enum

Conversation

@hauntsaninja
Copy link
Copy Markdown
Collaborator

I remember there are some subtleties around Enum.new, that might be
relevant to StrEnum, but I'm forgetting the details.

I wasn't sure how best to handle the new enum.property. I could also
re-export, or take a more literal interpretation.

I remember there are some subtleties around Enum.__new__, that might be
relevant to StrEnum, but I'm forgetting the details.

I wasn't sure how best to handle the new enum.property. I could also
re-export, or take a more literal interpretation.
Comment thread stdlib/enum.pyi
if sys.version_info >= (3, 10):
class StrEnum(str, Enum):
def __new__(cls: Type[_T], value: Union[int, _T]) -> _T: ...
class FlagBoundary(StrEnum):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is not used anywhere. Is there no way to say "class Foo(Flag, boundary=...) takes a boundary argument of this type?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't think so: python/mypy#2653. Perhaps we can add a stub for __init_subclass__ or __new__ or whatever black magic enum is doing to implement this.

@Akuli
Copy link
Copy Markdown
Collaborator

Akuli commented May 2, 2021

In #5305 I noticed that (int, Enum) inheritance no longer had to be whitelisted, but (str, Enum) didn't change

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 2, 2021

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

@Akuli Akuli merged commit 4a45b1d into python:master May 4, 2021
@hauntsaninja hauntsaninja deleted the enum branch May 6, 2021 22:06
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