-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongpendingIssues that may be closedIssues that may be closedtopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides
Description
Bug Report
If I enable mutable-override
it fails as it does not understand simple unions.
To Reproduce
Turn on mutable-override
class Base:
val: bool|None = True
class Derived(Base):
val = False
Gist: https://gist.github.com/mypy-play/aeec67e97957ea9e60431ce8466d8af3
Playground: https://mypy-play.net/?mypy=latest&python=3.12&enable-error-code=mutable-override&gist=aeec67e97957ea9e60431ce8466d8af3
Expected Behavior
no error
Actual Behavior
main.py:5: error: Covariant override of a mutable attribute (base class "Base" defined the type as "bool | None", expression has type "bool") [mutable-override]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.18.2
- Mypy command-line flags:
enable-error-code="mutable-override"
- Python version used: 3.12
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongpendingIssues that may be closedIssues that may be closedtopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides