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

PYI052 should ignore assignments in subclass of enum without enum members #8764

Closed
henribru opened this issue Nov 19, 2023 · 1 comment · Fixed by #8767
Closed

PYI052 should ignore assignments in subclass of enum without enum members #8764

henribru opened this issue Nov 19, 2023 · 1 comment · Fixed by #8767
Assignees
Labels
bug Something isn't working

Comments

@henribru
Copy link

henribru commented Nov 19, 2023

PYI052 correctly accepts the following code:

from enum import Enum

class Baz(Enum):
    FOO = 0
    BAR = 1

However, it flags the assignments to FOO and BAR in this code:

from enum import Enum

class Foo(Enum):
    ...

class Bar(Foo):
    FOO = 0
    BAR = 1

Inheriting from enums without enum members works at runtime and is understood by typecheckers, so I think these two examples should be treated the same. https://mypy-play.net/?mypy=latest&python=3.11&gist=cdb6a82662cbb77416bb64692606cb83

Reproduced with v0.1.6 running ruff foo.pyi --select PYI052 without any settings in pyproject.toml.

@henribru henribru changed the title PYI052 should ignore assignments in subclass of empty enum PYI052 should ignore assignments in subclass of enum without enum members Nov 19, 2023
@charliermarsh charliermarsh added the bug Something isn't working label Nov 19, 2023
@charliermarsh charliermarsh self-assigned this Nov 19, 2023
charliermarsh added a commit that referenced this issue Nov 19, 2023
…YI052`) (#8767)

We should reuse this approach in other rules, but this is a good start.

Closes #8764.
@henribru
Copy link
Author

Thanks for the prompt fix as always, you're awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants