11 files changed

+233
-229
lines changed
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from mypy.constraints import SUPERTYPE_OF
2626
from mypy.erasetype import erase_type, erase_typevars, remove_instance_last_known_values
2727
from mypy.errorcodes import TYPE_VAR, UNUSED_AWAITABLE, UNUSED_COROUTINE, ErrorCode
28-
from mypy.errors import Errors, ErrorWatcher, LoopErrorWatcher, report_internal_error
28+
from mypy.errors import ErrorInfo, Errors, ErrorWatcher, LoopErrorWatcher, report_internal_error
2929
from mypy.expandtype import expand_type
3030
from mypy.literals import Key, extract_var_from_literal_hash, literal, literal_hash
3131
from mypy.maptype import map_instance_to_supertype
@@ -7181,7 +7181,7 @@ def check_subtype(
71817181
if extra_info:
71827182
msg = msg.with_additional_msg(" (" + ", ".join(extra_info) + ")")
71837183

7184-
self.fail(msg, context)
7184+
error = self.fail(msg, context)
71857185
for note in notes:
71867186
self.msg.note(note, context, code=msg.code)
71877187
if note_msg:
@@ -7192,7 +7192,7 @@ def check_subtype(
71927192
and supertype.type.is_protocol
71937193
and isinstance(subtype, (CallableType, Instance, TupleType, TypedDictType))
71947194
):
7195-
self.msg.report_protocol_problems(subtype, supertype, context, code=msg.code)
7195+
self.msg.report_protocol_problems(subtype, supertype, context, parent_error=error)
71967196
if isinstance(supertype, CallableType) and isinstance(subtype, Instance):
71977197
call = find_member("__call__", subtype, subtype, is_operator=True)
71987198
if call:
@@ -7521,12 +7521,11 @@ def temp_node(self, t: Type, context: Context | None = None) -> TempNode:
75217521

75227522
def fail(
75237523
self, msg: str | ErrorMessage, context: Context, *, code: ErrorCode | None = None
7524-
) -> None:
7524+
) -> ErrorInfo:
75257525
"""Produce an error message."""
75267526
if isinstance(msg, ErrorMessage):
7527-
self.msg.fail(msg.value, context, code=msg.code)
7528-
return
7529-
self.msg.fail(msg, context, code=code)
7527+
return self.msg.fail(msg.value, context, code=msg.code)
7528+
return self.msg.fail(msg, context, code=code)
75307529

75317530
def note(
75327531
self,
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,7 @@ def check_arg(
26682668
elif self.has_abstract_type_part(caller_type, callee_type):
26692669
self.msg.concrete_only_call(callee_type, context)
26702670
elif not is_subtype(caller_type, callee_type, options=self.chk.options):
2671-
code = self.msg.incompatible_argument(
2671+
error = self.msg.incompatible_argument(
26722672
n,
26732673
m,
26742674
callee,
@@ -2679,10 +2679,12 @@ def check_arg(
26792679
outer_context=outer_context,
26802680
)
26812681
self.msg.incompatible_argument_note(
2682-
original_caller_type, callee_type, context, code=code
2682+
original_caller_type, callee_type, context, parent_error=error
26832683
)
26842684
if not self.msg.prefer_simple_messages():
2685-
self.chk.check_possible_missing_await(caller_type, callee_type, context, code)
2685+
self.chk.check_possible_missing_await(
2686+
caller_type, callee_type, context, error.code
2687+
)
26862688

26872689
def check_overload_call(
26882690
self,

0 commit comments

Comments
 (0)