Skip to content

Commit

Permalink
allow more dups
Browse files Browse the repository at this point in the history
  • Loading branch information
ikonst committed May 20, 2023
1 parent 3135c0f commit a008448
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
24 changes: 20 additions & 4 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,9 @@ def signature_incompatible_with_supertype(
# note: def f(self) -> str
# note: Subclass:
# note: def f(self, x: str) -> None
self.note("Superclass:", context, offset=ALIGN_OFFSET + OFFSET, code=code)
self.note(
"Superclass:", context, offset=ALIGN_OFFSET + OFFSET, allow_dups=ALLOW_DUPS, code=code
)
if isinstance(original, (CallableType, Overloaded)):
self.pretty_callable_or_overload(
original,
Expand All @@ -1168,9 +1170,17 @@ def signature_incompatible_with_supertype(
code=code,
)
else:
self.note(original_str, context, offset=ALIGN_OFFSET + 2 * OFFSET, code=code)
self.note(
original_str,
context,
offset=ALIGN_OFFSET + 2 * OFFSET,
allow_dups=ALLOW_DUPS,
code=code,
)

self.note("Subclass:", context, offset=ALIGN_OFFSET + OFFSET, code=code)
self.note(
"Subclass:", context, offset=ALIGN_OFFSET + OFFSET, allow_dups=ALLOW_DUPS, code=code
)
if isinstance(override, (CallableType, Overloaded)):
self.pretty_callable_or_overload(
override,
Expand All @@ -1181,7 +1191,13 @@ def signature_incompatible_with_supertype(
code=code,
)
else:
self.note(override_str, context, offset=ALIGN_OFFSET + 2 * OFFSET, code=code)
self.note(
override_str,
context,
offset=ALIGN_OFFSET + 2 * OFFSET,
allow_dups=ALLOW_DUPS,
code=code,
)

def pretty_callable_or_overload(
self,
Expand Down
26 changes: 26 additions & 0 deletions test-data/unit/check-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,32 @@ class B(A):
@dec
def h(self) -> str: pass

[case testOverrideIncompatibleWithMultipleSupertypes]
class A:
def f(self, *, a: int) -> None:
return

class B(A):
def f(self, *, b: int) -> None: # E: Signature of "f" incompatible with supertype "A" \
# N: Superclass: \
# N: def f(self, *, a: int) -> None \
# N: Subclass: \
# N: def f(self, *, b: int) -> None
return

class C(B):
def f(self, *, c: int) -> None: # E: Signature of "f" incompatible with supertype "B" \
# N: Superclass: \
# N: def f(self, *, b: int) -> None \
# N: Subclass: \
# N: def f(self, *, c: int) -> None \
# E: Signature of "f" incompatible with supertype "A" \
# N: Superclass: \
# N: def f(self, *, a: int) -> None \
# N: Subclass: \
# N: def f(self, *, c: int) -> None
return

[case testOverrideStaticMethodWithStaticMethod]
class A:
@staticmethod
Expand Down

0 comments on commit a008448

Please sign in to comment.