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

Fix false-positive error on multiple enum base classes #12963

Merged
merged 1 commit into from
Jul 8, 2022

Conversation

AlexWaygood
Copy link
Member

Description

Fixes #12787.

Mypy currently emits a false-positive error for this snippet of code, even though it works fine at runtime (and this exact inheritance structure is used in enum.py in the stdlib):

from enum import Enum, Flag
class ReprEnum(Enum): ...
class MyFlag(ReprEnum, Flag): ...

This PR fixes that.

Test Plan

I added several tests to make sure the behaviour is correct here.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2022

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

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks good.

@JukkaL JukkaL merged commit 1fedf2c into python:master Jul 8, 2022
@AlexWaygood AlexWaygood deleted the enum-inheritance branch July 8, 2022 13:40
Gobot1234 pushed a commit to Gobot1234/mypy that referenced this pull request Aug 12, 2022
Fixes python#12787.

Mypy currently emits a false-positive error for this snippet of code, even though it works fine at runtime (and this exact inheritance structure is used in enum.py in the stdlib):

```
from enum import Enum, Flag
class ReprEnum(Enum): ...
class MyFlag(ReprEnum, Flag): ...
```

This PR fixes that.
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.

Enums: false-positive "No base classes allowed after ReprEnum" error
2 participants