Skip to content

Commit f949dd4

Browse files
committed
Revert "Check names of positional arguments for @OverRide"
This reverts commit 94840af.
1 parent 94840af commit f949dd4

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

mypy/checker.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,9 +1971,6 @@ def check_method_override_for_base_with_name(
19711971
original_class_or_static,
19721972
override_class_or_static,
19731973
context,
1974-
ignore_pos_arg_names=(
1975-
not context.is_explicit_override if isinstance(context, FuncDef) else True
1976-
),
19771974
)
19781975
elif is_equivalent(original_type, typ):
19791976
# Assume invariance for a non-callable attribute here. Note
@@ -2061,7 +2058,6 @@ def check_override(
20612058
original_class_or_static: bool,
20622059
override_class_or_static: bool,
20632060
node: Context,
2064-
ignore_pos_arg_names: bool,
20652061
) -> None:
20662062
"""Check a method override with given signatures.
20672063
@@ -2075,7 +2071,7 @@ def check_override(
20752071
# Use boolean variable to clarify code.
20762072
fail = False
20772073
op_method_wider_note = False
2078-
if not is_subtype(override, original, ignore_pos_arg_names=ignore_pos_arg_names):
2074+
if not is_subtype(override, original, ignore_pos_arg_names=True):
20792075
fail = True
20802076
elif isinstance(override, Overloaded) and self.is_forward_op_method(name):
20812077
# Operator method overrides cannot extend the domain, as

test-data/unit/check-functions.test

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,11 +2742,9 @@ class B(A):
27422742

27432743
class C(A):
27442744
@override
2745-
def f(self, y: int) -> str: pass # E: Signature of "f" incompatible with supertype "A" \
2746-
# N: Superclass: \
2747-
# N: def f(self, x: int) -> str \
2748-
# N: Subclass: \
2749-
# N: def f(self, y: int) -> str
2745+
def f(self, x: str) -> str: pass # E: Argument 1 of "f" is incompatible with supertype "A"; supertype defines the argument type as "int" \
2746+
# N: This violates the Liskov substitution principle \
2747+
# N: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
27502748
def g(self, x: int) -> str: pass
27512749

27522750
class D(A): pass

0 commit comments

Comments
 (0)