Skip to content

Fix false positive for enum members shadowing base properties#20807

Open
emmanuel-ferdman wants to merge 1 commit intopython:masterfrom
emmanuel-ferdman:fix-enum-value-member
Open

Fix false positive for enum members shadowing base properties#20807
emmanuel-ferdman wants to merge 1 commit intopython:masterfrom
emmanuel-ferdman:fix-enum-value-member

Conversation

@emmanuel-ferdman
Copy link

PR Summary:
Defining an enum member called value or name using auto() caused mypy to incorrectly report an incompatible types error, as if overriding the base Enum.value property. These are just regular enum members that happen to shadow the property name, not actual overrides. The fix skips the compatibility check for that case.

Fixes #20247

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

discord.py (https://github.com/Rapptz/discord.py)
- discord/enums.py:960: error: Incompatible types in assignment (expression has type "int", base class "Enum" defined the type as "str")  [assignment]

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.

Enum with a value named value assigned with auto gives incompatible types in assignment

1 participant