diff --git a/mypy/checker.py b/mypy/checker.py index 0fb37450a015..1a4ee285f7eb 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -2403,7 +2403,7 @@ def check_method_override_for_base_with_name( and codes.MUTABLE_OVERRIDE in self.options.enabled_error_codes and self.is_writable_attribute(original_node) and not always_allow_covariant - and not is_subtype(original_type, typ, ignore_pos_arg_names=True) + and not is_subtype(original_type, typ) ): base_str, override_str = format_type_distinctly( original_type, typ, options=self.options @@ -2414,8 +2414,7 @@ def check_method_override_for_base_with_name( ) self.fail(msg, context) elif isinstance(original_type, UnionType) and any( - is_subtype(typ, orig_typ, ignore_pos_arg_names=True) - for orig_typ in original_type.items + is_subtype(typ, orig_typ) for orig_typ in original_type.items ): # This method is a subtype of at least one union variant. if ( @@ -2497,7 +2496,7 @@ def check_override( # Use boolean variable to clarify code. fail = False op_method_wider_note = False - if not is_subtype(override, original, ignore_pos_arg_names=True): + if not is_subtype(override, original): fail = True elif isinstance(override, Overloaded) and self.is_forward_op_method(name): # Operator method overrides cannot extend the domain, as diff --git a/test-data/unit/check-functions.test b/test-data/unit/check-functions.test index b54dffe836b8..3e6d355f2905 100644 --- a/test-data/unit/check-functions.test +++ b/test-data/unit/check-functions.test @@ -3074,11 +3074,11 @@ class B(A): class C(A): @overload - def f(self, y: int) -> str: pass + def f(self, x: int) -> str: pass @override @overload - def f(self, y: str) -> str: pass - def f(self, y: int | str) -> str: pass + def f(self, x: str) -> str: pass + def f(self, x: int | str) -> str: pass [typing fixtures/typing-override.pyi] [case explicitOverrideOnMultipleOverloads] @@ -3099,12 +3099,12 @@ class B(A): class C(A): @overload - def f(self, y: int) -> str: pass + def f(self, x: int) -> str: pass @override @overload - def f(self, y: str) -> str: pass + def f(self, x: str) -> str: pass @override - def f(self, y: int | str) -> str: pass + def f(self, x: int | str) -> str: pass [typing fixtures/typing-override.pyi] [case explicitOverrideCyclicDependency] @@ -3142,13 +3142,13 @@ class A: class B(A): @override - def f(self, y: int) -> str: pass + def f(self, x: int) -> str: pass class C(A): - def f(self, y: int) -> str: pass # E: Method "f" is not using @override but is overriding a method in class "__main__.A" + def f(self, x: int) -> str: pass # E: Method "f" is not using @override but is overriding a method in class "__main__.A" class D(B): - def f(self, y: int) -> str: pass # E: Method "f" is not using @override but is overriding a method in class "__main__.B" + def f(self, x: int) -> str: pass # E: Method "f" is not using @override but is overriding a method in class "__main__.B" [typing fixtures/typing-override.pyi] [case requireExplicitOverrideSpecialMethod] @@ -3221,26 +3221,26 @@ class A: class B(A): @overload - def f(self, y: int) -> str: ... + def f(self, x: int) -> str: ... @overload - def f(self, y: str) -> str: ... + def f(self, x: str) -> str: ... @override - def f(self, y): pass + def f(self, x): pass class C(A): @overload @override - def f(self, y: int) -> str: ... + def f(self, x: int) -> str: ... @overload - def f(self, y: str) -> str: ... - def f(self, y): pass + def f(self, x: str) -> str: ... + def f(self, x): pass class D(A): @overload - def f(self, y: int) -> str: ... + def f(self, x: int) -> str: ... @overload - def f(self, y: str) -> str: ... - def f(self, y): pass # E: Method "f" is not using @override but is overriding a method in class "__main__.A" + def f(self, x: str) -> str: ... + def f(self, x): pass # E: Method "f" is not using @override but is overriding a method in class "__main__.A" [typing fixtures/typing-override.pyi] [case requireExplicitOverrideMultipleInheritance] @@ -3250,14 +3250,14 @@ from typing import override class A: def f(self, x: int) -> str: pass class B: - def f(self, y: int) -> str: pass + def f(self, x: int) -> str: pass class C(A, B): @override - def f(self, z: int) -> str: pass + def f(self, x: int) -> str: pass class D(A, B): - def f(self, z: int) -> str: pass # E: Method "f" is not using @override but is overriding a method in class "__main__.A" + def f(self, x: int) -> str: pass # E: Method "f" is not using @override but is overriding a method in class "__main__.A" [typing fixtures/typing-override.pyi] [case testExplicitOverrideAllowedForPrivate] diff --git a/test-data/unit/check-super.test b/test-data/unit/check-super.test index 8816322a270a..9caf4d930e11 100644 --- a/test-data/unit/check-super.test +++ b/test-data/unit/check-super.test @@ -237,7 +237,7 @@ class A: def f(self, s: str) -> None: pass class B(A): - def f(self, i: Union[int, str]) -> None: pass + def f(self, s: Union[int, str]) -> None: pass class C: def g(self, b: B) -> None: @@ -251,7 +251,7 @@ class A: def f(self, s: str) -> None: pass class B(A): - def f(self, i: Union[int, str]) -> None: pass + def f(self, s: Union[int, str]) -> None: pass def g(b: B) -> None: super(B, b).f('42')