-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongneeds discussionpriority-1-normaltopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides
Description
- Are you reporting a bug, or opening a feature request?
Bug report
class ParentA:
def get_description(self, s: str): ...
class ParentB:
def get_description(self, i: int): ...
# This is a Liskov violation and needs to be ignored.
class ParentViolation(ParentA, ParentB): # type: ignore
...
class ShouldBeIrrelevant:
...
# Inheriting from a violating parent, showing no error
class NoViolation(ParentViolation):
...
# Inheriting from a violating parent, but an extra class makes a violation appear
class SpuriousViolation(ParentViolation, ShouldBeIrrelevant):
...- What is the actual behavior/output?
The NoViolation class line has no errors.
The SpuriousViolation class line has an error of:
error: Definition of "get_description" in base class "ParentA" is incompatible with definition in base class "ParentB"
- What is the behavior/output you expect?
Either they should both error, or neither should. Personally, I would prefer it if neither errored, since the Liskov violation has already been explicitly ignored by the ParentViolation class. However, I also don't have enough context to know whether this is actually the correct solution.
- What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
mypy 0.720, and verified with mypy 0.730+dev.17a93eac7d1d78e31fc9b347682d86d8d53fe02b
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongneeds discussionpriority-1-normaltopic-inheritanceInheritance and incompatible overridesInheritance and incompatible overrides