From 42e217835ca1e2cf0cfc81ed9f367e2e19b7946a Mon Sep 17 00:00:00 2001 From: LeoLomardo Date: Tue, 4 Nov 2025 08:12:11 -0300 Subject: [PATCH 1/5] refactor --- long_functions.csv | 122 +++++++++++++++++++++++++++++++++++++++++++++ mypy/test/data.py | 108 +++++++++++++++++++++++---------------- 2 files changed, 186 insertions(+), 44 deletions(-) create mode 100644 long_functions.csv diff --git a/long_functions.csv b/long_functions.csv new file mode 100644 index 000000000000..915c608868b8 --- /dev/null +++ b/long_functions.csv @@ -0,0 +1,122 @@ +path,name,length,start,end +mypy/main.py,define_options,880,465,1344 +mypy/options.py,__init__,329,93,421 +mypy/meet.py,is_overlapping_types,322,324,645 +mypy/checker.py,check_func_def,303,1296,1598 +mypy/constraints.py,visit_instance,274,762,1035 +mypy/test/teststubtest.py,test_has_runtime_final_decorator,254,1778,2031 +mypyc/irbuild/ll_builder.py,_construct_varargs,234,723,956 +mypy/messages.py,format_type_inner,228,2555,2782 +mypy/messages.py,report_protocol_problems,228,2118,2345 +mypy/plugins/dataclasses.py,collect_attributes,228,523,750 +mypy/messages.py,incompatible_argument,224,620,843 +mypy/modulefinder.py,_find_module,220,399,618 +mypy/typeanal.py,visit_unbound_type_nonoptional,216,298,513 +mypy/main.py,process_options,212,1347,1558 +mypy/messages.py,has_no_attr,206,362,567 +mypyc/build.py,mypycify,206,481,686 +mypy/semanal.py,check_and_set_up_type_alias,203,3956,4158 +mypyc/test/test_run.py,run_case_step,202,195,396 +mypy/checkmember.py,analyze_class_attribute_access,200,1132,1331 +mypy/typeanal.py,try_analyze_special_unbound_type,200,589,788 +mypy/test/typefixture.py,__init__,200,48,247 +mypy/subtypes.py,are_parameters_compatible,194,1747,1940 +mypy/exprtotype.py,expr_to_unanalyzed_type,189,64,252 +mypy/test/teststubtest.py,test_type_alias,188,1152,1339 +mypy/test/data.py,parse_test_case,186,57,242 +mypy/checker.py,find_isinstance_check_helper,183,6286,6468 +mypy/checker.py,check_assignment,181,3225,3405 +mypy/checkexpr.py,check_callable_call,180,1652,1831 +mypy/plugins/functools.py,handle_partial_with_callee,180,151,330 +mypy/checker.py,check_method_override_for_base_with_name,178,2269,2446 +mypyc/codegen/emitclass.py,generate_class,178,224,401 +mypy/checkexpr.py,check_op_reversible,175,3954,4128 +mypy/plugins/dataclasses.py,transform,174,231,404 +mypyc/codegen/emit.py,emit_cast,168,556,723 +mypy/build.py,load_graph,167,3098,3264 +mypy/constraints.py,infer_constraints_for_callable,167,110,276 +mypy/subtypes.py,visit_instance,167,475,641 +mypy/stubdoc.py,add_token,165,188,352 +mypy/checker.py,check_override,163,2464,2626 +mypy/checkpattern.py,visit_class_pattern,163,536,698 +mypy/semanal_namedtuple.py,build_namedtuple_typeinfo,163,502,664 +mypyc/codegen/emit.py,emit_unbox,161,838,998 +mypy/constraints.py,visit_callable_type,160,1078,1237 +mypy/fastparse.py,do_func_def,160,929,1088 +mypyc/irbuild/for_helpers.py,make_for_loop_generator,157,413,569 +mypy/test/teststubgen.py,test_infer_sig_from_docstring,157,222,378 +misc/perf_compare.py,main,155,115,269 +mypy/subtypes.py,is_callable_compatible,153,1567,1719 +mypy/checkexpr.py,visit_call_expr_inner,151,507,657 +mypy/checkexpr.py,visit_comparison_expr,148,3561,3708 +mypy/fastparse.py,fix_function_overloads,147,638,784 +mypy/typeanal.py,instantiate_type_alias,145,2091,2235 +mypy/checkexpr.py,check_overload_call,142,2672,2813 +mypy/semanal.py,visit_call_expr,142,5741,5882 +mypy/test/teststubtest.py,test_enum,142,1343,1484 +mypy/build.py,validate_meta,141,1455,1595 +mypyc/codegen/emitmodule.py,generate_shared_lib_init,141,772,912 +mypy/checkexpr.py,check_argument_types,139,2486,2624 +mypy/checkexpr.py,infer_function_type_arguments,138,2057,2194 +mypy/checker.py,refine_identity_comparison_expression,137,6837,6973 +mypyc/codegen/emitmodule.py,generate_c_for_modules,137,540,676 +mypyc/ir/class_ir.py,__init__,137,88,224 +mypy/stubgen.py,parse_options,136,1898,2033 +mypy/stubtest.py,test_stubs,135,2224,2358 +mypy/checkmember.py,analyze_member_var_access,132,522,653 +mypy/test/teststubtest.py,test_overload,132,745,876 +mypy/checker.py,check_overlapping_overloads,130,874,1003 +mypy/checkexpr.py,dangerous_comparison,130,3726,3855 +mypy/build.py,__init__,129,633,761 +mypy/build.py,write_cache,128,1607,1734 +mypy/stubtest.py,get_mypy_type_of_runtime_value,127,1875,2001 +mypy/checkpattern.py,visit_sequence_pattern,125,230,354 +mypy/dmypy_server.py,fine_grained_increment_follow_imports,125,601,725 +mypyc/irbuild/statement.py,emit_yield_from_or_await,125,1101,1225 +mypy/typeanal.py,analyze_unbound_type_without_type_info,122,912,1033 +mypy/checkexpr.py,check_call,121,1530,1650 +mypy/subtypes.py,is_protocol_implementation,120,1158,1277 +mypyc/irbuild/classdef.py,transform_class_def,120,88,207 +mypyc/irbuild/function.py,gen_func_item,120,169,288 +mypy/server/update.py,update_module_isolated,120,561,680 +mypy/checker.py,refine_parent_types,119,6699,6817 +mypy/semanal_namedtuple.py,parse_namedtuple_args,119,338,456 +mypy/stubtest.py,_verify_signature,118,1055,1172 +mypy/test/meta/test_update_data.py,test_update_data,116,20,135 +mypy/semanal.py,analyze_func_def,115,934,1048 +mypy/checker.py,comparison_type_narrowing_helper,114,6470,6583 +mypy/main.py,main,114,62,175 +mypy/build.py,__init__,113,1961,2073 +mypy/checker.py,check_return_stmt,113,4895,5007 +mypyc/irbuild/ll_builder.py,binary_op,113,1393,1505 +mypy/test/test_find_sources.py,test_find_sources_exclude,113,264,376 +mypy/semanal_typeddict.py,analyze_typeddict_classdef,111,70,180 +mypy/plugins/enums.py,enum_value_callback,111,160,270 +mypy/semanal.py,visit_type_alias_stmt,110,5551,5660 +mypy/checkexpr.py,check_op,109,4130,4238 +mypyc/analysis/dataflow.py,run_analysis,109,514,622 +misc/incremental_checker.py,main,108,395,502 +mypy/checker.py,check_simple_assignment,108,4587,4694 +mypy/checkexpr.py,visit_op_expr,108,3452,3559 +mypy/semanal_namedtuple.py,check_namedtuple,108,222,329 +mypy/stubgenc.py,infer_c_method_args,108,939,1046 +mypyc/irbuild/prepare.py,prepare_class_def,108,348,455 +mypy/checkmember.py,analyze_descriptor_access,107,664,770 +mypy/config_parser.py,parse_section,107,483,589 +mypy/stubgenc.py,get_default_function_sig,107,270,376 +mypy/constraints.py,_infer_constraints,106,323,428 +mypy/join.py,join_tuples,106,455,560 +mypyc/irbuild/statement.py,transform_try_finally_stmt_async,106,758,863 +mypy/meet.py,narrow_declared_type,105,116,220 +mypy/stubgenc.py,generate_class_stub,105,804,908 +mypy/test/teststubtest.py,test_property,105,880,984 +mypy/build.py,process_stale_scc,104,3458,3561 +mypy/checkexpr.py,visit_tuple_expr,104,5147,5250 +mypy/messages.py,pretty_callable,103,2951,3053 +mypy/semanal_enum.py,parse_enum_call_args,102,157,258 +mypy/stubtest.py,verify_typeinfo,102,609,710 +mypy/checker.py,intersect_instances,101,5810,5910 +mypy/checkexpr.py,union_overload_result,101,3017,3117 +mypy/constraints.py,visit_tuple_type,101,1250,1350 +mypy/errors.py,add_error_info,101,603,703 +mypy/server/astdiff.py,snapshot_definition,101,231,331 diff --git a/mypy/test/data.py b/mypy/test/data.py index 5b0ad84c0ba7..ea41c194f34f 100644 --- a/mypy/test/data.py +++ b/mypy/test/data.py @@ -14,7 +14,7 @@ from dataclasses import dataclass from pathlib import Path from re import Pattern -from typing import Any, Final, NamedTuple, NoReturn, Union +from typing import Any, Callable, Final, NamedTuple, NoReturn, Union from typing_extensions import TypeAlias as _TypeAlias import pytest @@ -54,6 +54,66 @@ def _file_arg_to_module(filename: str) -> str: return ".".join(parts) +def _handle_out_section( + item: TestItem, + case: DataDrivenTestCase, + output: list[str], + output2: dict[int, list[str]], + out_section_missing: bool, + item_fail: Callable[[str], NoReturn], +) -> bool: + """Handle an "out" / "outN" section from a test item. + + Mutates `output` (in-place) or `output2` and returns the updated + `out_section_missing` flag. + """ + if item.arg is None: + args = [] + else: + args = item.arg.split(",") + + version_check = True + for arg in args: + if arg.startswith("version"): + compare_op = arg[7:9] + if compare_op not in {">=", "=="}: + item_fail("Only >= and == version checks are currently supported") + version_str = arg[9:] + try: + version = tuple(int(x) for x in version_str.split(".")) + except ValueError: + item_fail(f"{version_str!r} is not a valid python version") + if compare_op == ">=": + if version <= defaults.PYTHON3_VERSION: + item_fail( + f"{arg} always true since minimum runtime version is {defaults.PYTHON3_VERSION}" + ) + version_check = sys.version_info >= version + elif compare_op == "==": + if version < defaults.PYTHON3_VERSION: + item_fail( + f"{arg} always false since minimum runtime version is {defaults.PYTHON3_VERSION}" + ) + if not 1 < len(version) < 4: + item_fail( + f'Only minor or patch version checks are currently supported with "==": {version_str!r}' + ) + version_check = sys.version_info[: len(version)] == version + if version_check: + tmp_output = [expand_variables(line) for line in item.data] + if os.path.sep == "\\" and case.normalize_output: + tmp_output = [fix_win_path(line) for line in tmp_output] + if item.id == "out" or item.id == "out1": + # modify in place so caller's `output` reference is preserved + output[:] = tmp_output + else: + passnum = int(item.id[len("out") :]) + assert passnum > 1 + output2[passnum] = tmp_output + out_section_missing = False + return out_section_missing + + def parse_test_case(case: DataDrivenTestCase) -> None: """Parse and prepare a single case from suite with test case descriptions. @@ -150,49 +210,9 @@ def _item_fail(msg: str) -> NoReturn: full = join(base_path, m.group(1)) deleted_paths.setdefault(num, set()).add(full) elif re.match(r"out[0-9]*$", item.id): - if item.arg is None: - args = [] - else: - args = item.arg.split(",") - - version_check = True - for arg in args: - if arg.startswith("version"): - compare_op = arg[7:9] - if compare_op not in {">=", "=="}: - _item_fail("Only >= and == version checks are currently supported") - version_str = arg[9:] - try: - version = tuple(int(x) for x in version_str.split(".")) - except ValueError: - _item_fail(f"{version_str!r} is not a valid python version") - if compare_op == ">=": - if version <= defaults.PYTHON3_VERSION: - _item_fail( - f"{arg} always true since minimum runtime version is {defaults.PYTHON3_VERSION}" - ) - version_check = sys.version_info >= version - elif compare_op == "==": - if version < defaults.PYTHON3_VERSION: - _item_fail( - f"{arg} always false since minimum runtime version is {defaults.PYTHON3_VERSION}" - ) - if not 1 < len(version) < 4: - _item_fail( - f'Only minor or patch version checks are currently supported with "==": {version_str!r}' - ) - version_check = sys.version_info[: len(version)] == version - if version_check: - tmp_output = [expand_variables(line) for line in item.data] - if os.path.sep == "\\" and case.normalize_output: - tmp_output = [fix_win_path(line) for line in tmp_output] - if item.id == "out" or item.id == "out1": - output = tmp_output - else: - passnum = int(item.id[len("out") :]) - assert passnum > 1 - output2[passnum] = tmp_output - out_section_missing = False + out_section_missing = _handle_out_section( + item, case, output, output2, out_section_missing, _item_fail + ) elif item.id == "triggered" and item.arg is None: triggered = item.data else: From a6a19a96864168a00924544b417110a8544a9832 Mon Sep 17 00:00:00 2001 From: LeoLomardo Date: Mon, 8 Dec 2025 20:22:41 -0300 Subject: [PATCH 2/5] feature: new error message for decorator incompatible type --- mypy/messages.py | 26 +++++++++++++++++++++----- test-data/unit/check-functions.test | 10 ++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/mypy/messages.py b/mypy/messages.py index 9fdfb748b288..fb4f063da8c7 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -45,6 +45,7 @@ ClassDef, Context, Expression, + Decorator, FuncDef, IndexExpr, MypyFile, @@ -772,13 +773,27 @@ def incompatible_argument( actual_type_str, expected_type_str ) else: - if self.prefer_simple_messages(): + try: + expected_type = callee.arg_types[m - 1] + except IndexError: # Varargs callees + expected_type = callee.arg_types[-1] + + decorator_context = callee_name is None and isinstance(outer_context, Decorator) + simple_message = self.prefer_simple_messages() and not decorator_context + + if decorator_context: + arg_type_str, expected_type_str = format_type_distinctly( + arg_type, expected_type, bare=True, options=self.options + ) + func_name = outer_context.func.name + msg = ( + f'Decorated function "{func_name}" has incompatible type ' + f'{quote_type_string(arg_type_str)}; expected ' + f'{quote_type_string(expected_type_str)}' + ) + elif simple_message: msg = "Argument has incompatible type" else: - try: - expected_type = callee.arg_types[m - 1] - except IndexError: # Varargs callees - expected_type = callee.arg_types[-1] arg_type_str, expected_type_str = format_type_distinctly( arg_type, expected_type, bare=True, options=self.options ) @@ -822,6 +837,7 @@ def incompatible_argument( quote_type_string(arg_type_str), quote_type_string(expected_type_str), ) + if not simple_message: expected_type = get_proper_type(expected_type) if isinstance(expected_type, UnionType): expected_types = list(expected_type.items) diff --git a/test-data/unit/check-functions.test b/test-data/unit/check-functions.test index 1882f235f7e3..ee85a084cb98 100644 --- a/test-data/unit/check-functions.test +++ b/test-data/unit/check-functions.test @@ -959,6 +959,16 @@ def dec2(f: Callable[[Any, Any], None]) -> Callable[[Any], None]: pass @dec2 def f(x, y): pass +[case testDecoratorFactoryApplicationErrorMessage] +from typing import Callable + +def decorator(f: object) -> Callable[[Callable[[int], object]], None]: ... +def f(a: int) -> None: ... + +@decorator(f) # E: Decorated function "something" has incompatible type "Callable[[], None]"; expected "Callable[[int], object]" +def something() -> None: + pass + [case testNoTypeCheckDecoratorOnMethod1] from typing import no_type_check From b69c7d9d742d91b3bca4314394ef7cf911b263d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 23:28:11 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypy/messages.py | 6 +++--- mypy/test/data.py | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mypy/messages.py b/mypy/messages.py index c527e94d8d44..dd0bd19ef5a4 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -44,8 +44,8 @@ CallExpr, ClassDef, Context, - Expression, Decorator, + Expression, FuncDef, IndexExpr, MypyFile, @@ -788,8 +788,8 @@ def incompatible_argument( func_name = outer_context.func.name msg = ( f'Decorated function "{func_name}" has incompatible type ' - f'{quote_type_string(arg_type_str)}; expected ' - f'{quote_type_string(expected_type_str)}' + f"{quote_type_string(arg_type_str)}; expected " + f"{quote_type_string(expected_type_str)}" ) elif simple_message: msg = "Argument has incompatible type" diff --git a/mypy/test/data.py b/mypy/test/data.py index 21a1461dd8b5..f60b3adabe17 100644 --- a/mypy/test/data.py +++ b/mypy/test/data.py @@ -10,12 +10,10 @@ import sys import tempfile from abc import abstractmethod -from collections.abc import Iterator +from collections.abc import Callable, Iterator from dataclasses import dataclass from pathlib import Path from re import Pattern -from typing import Any, Callable, Final, NamedTuple, NoReturn, Union -from typing_extensions import TypeAlias as _TypeAlias from typing import Any, Final, NamedTuple, NoReturn, TypeAlias as _TypeAlias import pytest From bb2b468a0866c25a6e28af8dfd68ce71a4cd2d90 Mon Sep 17 00:00:00 2001 From: Leo Lomardo <80079076+LeoLomardo@users.noreply.github.com> Date: Tue, 9 Dec 2025 13:59:36 +0000 Subject: [PATCH 4/5] Changes to be committed: deleted: long_functions.csv removed long_functions.csv because it is no longer needed in the project. --- long_functions.csv | 122 --------------------------------------------- 1 file changed, 122 deletions(-) delete mode 100644 long_functions.csv diff --git a/long_functions.csv b/long_functions.csv deleted file mode 100644 index 915c608868b8..000000000000 --- a/long_functions.csv +++ /dev/null @@ -1,122 +0,0 @@ -path,name,length,start,end -mypy/main.py,define_options,880,465,1344 -mypy/options.py,__init__,329,93,421 -mypy/meet.py,is_overlapping_types,322,324,645 -mypy/checker.py,check_func_def,303,1296,1598 -mypy/constraints.py,visit_instance,274,762,1035 -mypy/test/teststubtest.py,test_has_runtime_final_decorator,254,1778,2031 -mypyc/irbuild/ll_builder.py,_construct_varargs,234,723,956 -mypy/messages.py,format_type_inner,228,2555,2782 -mypy/messages.py,report_protocol_problems,228,2118,2345 -mypy/plugins/dataclasses.py,collect_attributes,228,523,750 -mypy/messages.py,incompatible_argument,224,620,843 -mypy/modulefinder.py,_find_module,220,399,618 -mypy/typeanal.py,visit_unbound_type_nonoptional,216,298,513 -mypy/main.py,process_options,212,1347,1558 -mypy/messages.py,has_no_attr,206,362,567 -mypyc/build.py,mypycify,206,481,686 -mypy/semanal.py,check_and_set_up_type_alias,203,3956,4158 -mypyc/test/test_run.py,run_case_step,202,195,396 -mypy/checkmember.py,analyze_class_attribute_access,200,1132,1331 -mypy/typeanal.py,try_analyze_special_unbound_type,200,589,788 -mypy/test/typefixture.py,__init__,200,48,247 -mypy/subtypes.py,are_parameters_compatible,194,1747,1940 -mypy/exprtotype.py,expr_to_unanalyzed_type,189,64,252 -mypy/test/teststubtest.py,test_type_alias,188,1152,1339 -mypy/test/data.py,parse_test_case,186,57,242 -mypy/checker.py,find_isinstance_check_helper,183,6286,6468 -mypy/checker.py,check_assignment,181,3225,3405 -mypy/checkexpr.py,check_callable_call,180,1652,1831 -mypy/plugins/functools.py,handle_partial_with_callee,180,151,330 -mypy/checker.py,check_method_override_for_base_with_name,178,2269,2446 -mypyc/codegen/emitclass.py,generate_class,178,224,401 -mypy/checkexpr.py,check_op_reversible,175,3954,4128 -mypy/plugins/dataclasses.py,transform,174,231,404 -mypyc/codegen/emit.py,emit_cast,168,556,723 -mypy/build.py,load_graph,167,3098,3264 -mypy/constraints.py,infer_constraints_for_callable,167,110,276 -mypy/subtypes.py,visit_instance,167,475,641 -mypy/stubdoc.py,add_token,165,188,352 -mypy/checker.py,check_override,163,2464,2626 -mypy/checkpattern.py,visit_class_pattern,163,536,698 -mypy/semanal_namedtuple.py,build_namedtuple_typeinfo,163,502,664 -mypyc/codegen/emit.py,emit_unbox,161,838,998 -mypy/constraints.py,visit_callable_type,160,1078,1237 -mypy/fastparse.py,do_func_def,160,929,1088 -mypyc/irbuild/for_helpers.py,make_for_loop_generator,157,413,569 -mypy/test/teststubgen.py,test_infer_sig_from_docstring,157,222,378 -misc/perf_compare.py,main,155,115,269 -mypy/subtypes.py,is_callable_compatible,153,1567,1719 -mypy/checkexpr.py,visit_call_expr_inner,151,507,657 -mypy/checkexpr.py,visit_comparison_expr,148,3561,3708 -mypy/fastparse.py,fix_function_overloads,147,638,784 -mypy/typeanal.py,instantiate_type_alias,145,2091,2235 -mypy/checkexpr.py,check_overload_call,142,2672,2813 -mypy/semanal.py,visit_call_expr,142,5741,5882 -mypy/test/teststubtest.py,test_enum,142,1343,1484 -mypy/build.py,validate_meta,141,1455,1595 -mypyc/codegen/emitmodule.py,generate_shared_lib_init,141,772,912 -mypy/checkexpr.py,check_argument_types,139,2486,2624 -mypy/checkexpr.py,infer_function_type_arguments,138,2057,2194 -mypy/checker.py,refine_identity_comparison_expression,137,6837,6973 -mypyc/codegen/emitmodule.py,generate_c_for_modules,137,540,676 -mypyc/ir/class_ir.py,__init__,137,88,224 -mypy/stubgen.py,parse_options,136,1898,2033 -mypy/stubtest.py,test_stubs,135,2224,2358 -mypy/checkmember.py,analyze_member_var_access,132,522,653 -mypy/test/teststubtest.py,test_overload,132,745,876 -mypy/checker.py,check_overlapping_overloads,130,874,1003 -mypy/checkexpr.py,dangerous_comparison,130,3726,3855 -mypy/build.py,__init__,129,633,761 -mypy/build.py,write_cache,128,1607,1734 -mypy/stubtest.py,get_mypy_type_of_runtime_value,127,1875,2001 -mypy/checkpattern.py,visit_sequence_pattern,125,230,354 -mypy/dmypy_server.py,fine_grained_increment_follow_imports,125,601,725 -mypyc/irbuild/statement.py,emit_yield_from_or_await,125,1101,1225 -mypy/typeanal.py,analyze_unbound_type_without_type_info,122,912,1033 -mypy/checkexpr.py,check_call,121,1530,1650 -mypy/subtypes.py,is_protocol_implementation,120,1158,1277 -mypyc/irbuild/classdef.py,transform_class_def,120,88,207 -mypyc/irbuild/function.py,gen_func_item,120,169,288 -mypy/server/update.py,update_module_isolated,120,561,680 -mypy/checker.py,refine_parent_types,119,6699,6817 -mypy/semanal_namedtuple.py,parse_namedtuple_args,119,338,456 -mypy/stubtest.py,_verify_signature,118,1055,1172 -mypy/test/meta/test_update_data.py,test_update_data,116,20,135 -mypy/semanal.py,analyze_func_def,115,934,1048 -mypy/checker.py,comparison_type_narrowing_helper,114,6470,6583 -mypy/main.py,main,114,62,175 -mypy/build.py,__init__,113,1961,2073 -mypy/checker.py,check_return_stmt,113,4895,5007 -mypyc/irbuild/ll_builder.py,binary_op,113,1393,1505 -mypy/test/test_find_sources.py,test_find_sources_exclude,113,264,376 -mypy/semanal_typeddict.py,analyze_typeddict_classdef,111,70,180 -mypy/plugins/enums.py,enum_value_callback,111,160,270 -mypy/semanal.py,visit_type_alias_stmt,110,5551,5660 -mypy/checkexpr.py,check_op,109,4130,4238 -mypyc/analysis/dataflow.py,run_analysis,109,514,622 -misc/incremental_checker.py,main,108,395,502 -mypy/checker.py,check_simple_assignment,108,4587,4694 -mypy/checkexpr.py,visit_op_expr,108,3452,3559 -mypy/semanal_namedtuple.py,check_namedtuple,108,222,329 -mypy/stubgenc.py,infer_c_method_args,108,939,1046 -mypyc/irbuild/prepare.py,prepare_class_def,108,348,455 -mypy/checkmember.py,analyze_descriptor_access,107,664,770 -mypy/config_parser.py,parse_section,107,483,589 -mypy/stubgenc.py,get_default_function_sig,107,270,376 -mypy/constraints.py,_infer_constraints,106,323,428 -mypy/join.py,join_tuples,106,455,560 -mypyc/irbuild/statement.py,transform_try_finally_stmt_async,106,758,863 -mypy/meet.py,narrow_declared_type,105,116,220 -mypy/stubgenc.py,generate_class_stub,105,804,908 -mypy/test/teststubtest.py,test_property,105,880,984 -mypy/build.py,process_stale_scc,104,3458,3561 -mypy/checkexpr.py,visit_tuple_expr,104,5147,5250 -mypy/messages.py,pretty_callable,103,2951,3053 -mypy/semanal_enum.py,parse_enum_call_args,102,157,258 -mypy/stubtest.py,verify_typeinfo,102,609,710 -mypy/checker.py,intersect_instances,101,5810,5910 -mypy/checkexpr.py,union_overload_result,101,3017,3117 -mypy/constraints.py,visit_tuple_type,101,1250,1350 -mypy/errors.py,add_error_info,101,603,703 -mypy/server/astdiff.py,snapshot_definition,101,231,331 From d8388e199536824525b3281779841e3e12a8a3aa Mon Sep 17 00:00:00 2001 From: LeoLomardo Date: Tue, 9 Dec 2025 12:54:11 -0300 Subject: [PATCH 5/5] chore: changes to pass the tests --- mypy/messages.py | 3 ++- test-data/unit/check-functions.test | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mypy/messages.py b/mypy/messages.py index dd0bd19ef5a4..774c7a8ee024 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -782,10 +782,11 @@ def incompatible_argument( simple_message = self.prefer_simple_messages() and not decorator_context if decorator_context: + decorator = cast(Decorator, outer_context) arg_type_str, expected_type_str = format_type_distinctly( arg_type, expected_type, bare=True, options=self.options ) - func_name = outer_context.func.name + func_name = decorator.func.name msg = ( f'Decorated function "{func_name}" has incompatible type ' f"{quote_type_string(arg_type_str)}; expected " diff --git a/test-data/unit/check-functions.test b/test-data/unit/check-functions.test index 93f95d20c6d7..f73be88a5596 100644 --- a/test-data/unit/check-functions.test +++ b/test-data/unit/check-functions.test @@ -3534,7 +3534,7 @@ def decorator2(f: Callable[P, None]) -> Callable[ def key2(x: int) -> None: ... -@decorator2(key2) # E: Argument 1 has incompatible type "def foo2(y: int) -> Coroutine[Any, Any, None]"; expected "def (x: int) -> Awaitable[None]" +@decorator2(key2) # E: Decorated function "foo2" has incompatible type "def foo2(y: int) -> Coroutine[Any, Any, None]"; expected "def (x: int) -> Awaitable[None]" async def foo2(y: int) -> None: ...