Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,9 @@ def signature_incompatible_with_supertype(
)
else:
self.note(override_str, context, offset=ALIGN_OFFSET + 2 * OFFSET, parent_error=error)
self.note(
"This violates the Liskov substitution principle", context, parent_error=error
)

def pretty_callable_or_overload(
self,
Expand Down
8 changes: 8 additions & 0 deletions test-data/unit/check-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -9412,3 +9412,11 @@ from typ import NT
def f() -> NT:
return NT(x='')
[builtins fixtures/tuple.pyi]

[case testLSPOverrideNote]
class A:
def f(self, x: object) -> object: ...
class B(A):
def f(self, x: int) -> int: ... # E: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "object" \
# N: This violates the Liskov substitution principle \
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
Loading