Skip to content

Conversation

@sobolevn
Copy link
Member

This change is enough to (at least partially) fix #10384

Why? Because mypy already had this plugin in place: https://github.com/python/mypy/blob/b995e1620789a3ab2fc5dbcf0698a9077b0f5731/mypy/plugins/enums.py#L85-L90

Source: https://github.com/python/cpython/blob/319de0b578ec3dec8d30610caee3aa93f51060c7/Lib/enum.py#L1279

So, adding it locally produces:

from enum import StrEnum, auto

class A(StrEnum):
    a = auto()

reveal_type(type(A.a))  # N: Revealed type is "Type[Literal[ex.A.a]?]"
reveal_type(type(A.a.value))  # N: Revealed type is "Type[builtins.str]"

Closes #10384

This change is enough to (at least partially) fix #10384

Why? Because `mypy` already had this plugin in place: https://github.com/python/mypy/blob/b995e1620789a3ab2fc5dbcf0698a9077b0f5731/mypy/plugins/enums.py#L85-L90

So, adding it locally produces:

```python
from enum import StrEnum, auto

class A(StrEnum):
    a = auto()

reveal_type(type(A.a))  # N: Revealed type is "Type[Literal[ex.A.a]?]"
reveal_type(type(A.a.value))  # N: Revealed type is "Type[builtins.str]"
```

Closes #10384
@AlexWaygood AlexWaygood changed the title Add _generate_next_value to StrEnum Add _generate_next_value_ to StrEnum Jun 30, 2023
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks!

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2023

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

@AlexWaygood AlexWaygood merged commit a8051fb into main Jul 1, 2023
@AlexWaygood AlexWaygood deleted the sobolevn-patch-1 branch July 1, 2023 17:28
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.

auto for StrEnum is incorrectly subclassing IntFlag

4 participants