|
33 | 33 | from mypy.maptype import map_instance_to_supertype |
34 | 34 | from mypy.meet import is_overlapping_types, narrow_declared_type |
35 | 35 | from mypy.message_registry import ErrorMessage |
36 | | -from mypy.messages import MessageBuilder, format_type |
| 36 | +from mypy.messages import MessageBuilder, format_type, format_type_distinctly |
37 | 37 | from mypy.nodes import ( |
38 | 38 | ARG_NAMED, |
39 | 39 | ARG_POS, |
@@ -2387,12 +2387,19 @@ def check_call_arguments( |
2387 | 2387 | has_type_errors = type_error_watcher.has_new_errors() |
2388 | 2388 |
|
2389 | 2389 | if shift_info is not None: |
2390 | | - _, param_name, expected_type, high_confidence = shift_info |
| 2390 | + shift_position, param_name, expected_type, high_confidence = shift_info |
2391 | 2391 | if high_confidence and param_name: |
2392 | | - type_str = format_type(expected_type, self.chk.options) |
| 2392 | + positional_arg_types = [ |
| 2393 | + arg_types[i] for i, k in enumerate(arg_kinds) if k == nodes.ARG_POS |
| 2394 | + ] |
| 2395 | + actual_type = positional_arg_types[shift_position - 1] |
| 2396 | + actual_str, expected_str = format_type_distinctly( |
| 2397 | + actual_type, expected_type, options=self.chk.options |
| 2398 | + ) |
2393 | 2399 | self.msg.fail( |
2394 | | - f'Expected {type_str} for parameter "{param_name}"; ' |
2395 | | - f'did you forget argument "{param_name}"?', |
| 2400 | + f'Argument {shift_position} to "{func_name}" has incompatible type ' |
| 2401 | + f'{actual_str}; expected {expected_str} ' |
| 2402 | + f'(did you forget argument "{param_name}"?)', |
2396 | 2403 | context, |
2397 | 2404 | code=codes.CALL_ARG, |
2398 | 2405 | ) |
|
0 commit comments