Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert "Check names of positional arguments for @OverRide"
This reverts commit 94840af.
  • Loading branch information
tmke8 committed May 8, 2023
commit f949dd4c8cb0f5767dcfd35aa7eb93478f894c51
6 changes: 1 addition & 5 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1971,9 +1971,6 @@ def check_method_override_for_base_with_name(
original_class_or_static,
override_class_or_static,
context,
ignore_pos_arg_names=(
not context.is_explicit_override if isinstance(context, FuncDef) else True
),
)
elif is_equivalent(original_type, typ):
# Assume invariance for a non-callable attribute here. Note
Expand Down Expand Up @@ -2061,7 +2058,6 @@ def check_override(
original_class_or_static: bool,
override_class_or_static: bool,
node: Context,
ignore_pos_arg_names: bool,
) -> None:
"""Check a method override with given signatures.

Expand All @@ -2075,7 +2071,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=ignore_pos_arg_names):
if not is_subtype(override, original, ignore_pos_arg_names=True):
fail = True
elif isinstance(override, Overloaded) and self.is_forward_op_method(name):
# Operator method overrides cannot extend the domain, as
Expand Down
8 changes: 3 additions & 5 deletions test-data/unit/check-functions.test
Original file line number Diff line number Diff line change
Expand Up @@ -2742,11 +2742,9 @@ class B(A):

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

class D(A): pass
Expand Down