From 82cbd1b2a2328a92e47ad32da0751ef42462dca3 Mon Sep 17 00:00:00 2001 From: Shantanu Jain Date: Sat, 28 Dec 2024 17:50:48 -0800 Subject: [PATCH 1/2] Be strict about arg names in LSP checks Python 3.7 has been dead for a long time, people can use PEP 570. Let's see primer, this might need to be an option --- mypy/checker.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mypy/checker.py b/mypy/checker.py index b2c4f2263262..9d974bed456a 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -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,7 +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) + is_subtype(typ, orig_typ) for orig_typ in original_type.items ): # This method is a subtype of at least one union variant. @@ -2293,7 +2293,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 From 208dddf0eaa3766cfb9b7662c365206c5eea2d69 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 29 Dec 2024 01:58:06 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypy/checker.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypy/checker.py b/mypy/checker.py index 9d974bed456a..31402bf48f33 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -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) - 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 (