-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as duplicate of#11969
Closed as duplicate of#11969
Copy link
Labels
bugmypy got something wrongmypy got something wrongtopic-overlapOverlapping equality checkOverlapping equality check
Description
Bug Report
The same issue as #10910 is occurring with enum.StrEnum in v1.18.1 even after #19422 .
To Reproduce
Gist URL: https://gist.github.com/mypy-play/2b3ca1612b3efc83cc712252610dfdf0
Playground URL: https://mypy-play.net/?mypy=master&python=3.13&flags=strict&gist=2b3ca1612b3efc83cc712252610dfdf0
import enum
from dataclasses import dataclass
class Status(enum.StrEnum):
ALIVE = "alive"
KILLED = "killed"
STALE = "stale"
REJECTED = "rejected"
@dataclass
class SomeThing:
status: Status
def status_updater(some_thing: SomeThing) -> None:
some_thing.status = Status.KILLED
the_thing = SomeThing(status=Status.ALIVE)
assert the_thing.status == Status.ALIVE
status_updater(the_thing)
assert the_thing.status == Status.KILLEDExpected Behavior
When running with mypy --strict, this should not result in an error because the status could change in the status_updater. This would make StrEnum work like Enum
Actual Behavior
main.py:27: error: Non-overlapping equality check (left operand type: "Literal[Status.ALIVE]", right operand type: "Literal[Status.KILLED]") [comparison-overlap]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.18.1 (compiled: yes)
- Mypy command-line flags:
--strict - Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: Python 3.13.7
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-overlapOverlapping equality checkOverlapping equality check