Skip to content

Be strict about arg names in LSP checks #18355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
7 changes: 3 additions & 4 deletions mypy/checker.py
Original file line number Diff line number Diff line change
@@ -2155,7 +2155,7 @@ def check_method_override_for_base_with_name(
and original_node
and codes.MUTABLE_OVERRIDE in self.options.enabled_error_codes
and self.is_writable_attribute(original_node)
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
@@ -2166,8 +2166,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 (
@@ -2293,7 +2292,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