Skip to content
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

enum: update for py310 #5314

Merged
merged 1 commit into from
May 4, 2021
Merged

enum: update for py310 #5314

merged 1 commit into from
May 4, 2021

Conversation

hauntsaninja
Copy link
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.
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
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
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
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
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