Skip to content

Commit b22e1d6

Browse files
reparent proper_plugin note
1 parent a64f74e commit b22e1d6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

mypy/checker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7734,7 +7734,7 @@ def fail(
77347734
) -> ErrorInfo:
77357735
"""Produce an error message."""
77367736
if isinstance(msg, ErrorMessage):
7737-
return self.msg.fail(msg.value, context, code=msg.code)
7737+
msg, code = msg.value, msg.code # type: ignore[attr-defined] #TODO: https://github.com/python/mypy/issues/19891
77387738
return self.msg.fail(msg, context, code=code)
77397739

77407740
def note(
@@ -7744,12 +7744,12 @@ def note(
77447744
offset: int = 0,
77457745
*,
77467746
code: ErrorCode | None = None,
7747+
parent_error: ErrorInfo | None = None,
77477748
) -> None:
77487749
"""Produce a note."""
77497750
if isinstance(msg, ErrorMessage):
7750-
self.msg.note(msg.value, context, code=msg.code)
7751-
return
7752-
self.msg.note(msg, context, offset=offset, code=code)
7751+
msg, code = msg.value, msg.code # type: ignore[attr-defined] #TODO: https://github.com/python/mypy/issues/19891
7752+
self.msg.note(msg, context, offset=offset, code=code, parent_error=parent_error)
77537753

77547754
def iterable_item_type(
77557755
self, it: Instance | CallableType | TypeType | Overloaded, context: Context

mypy/plugins/proper_plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def isinstance_proper_hook(ctx: FunctionContext) -> Type:
6363
) and is_dangerous_target(right):
6464
if is_special_target(right):
6565
return ctx.default_return_type
66-
ctx.api.fail(
66+
parent_error = ctx.api.fail(
6767
"Never apply isinstance() to unexpanded types;"
6868
" use mypy.types.get_proper_type() first",
6969
ctx.context,
@@ -72,6 +72,7 @@ def isinstance_proper_hook(ctx: FunctionContext) -> Type:
7272
"If you pass on the original type"
7373
" after the check, always use its unexpanded version",
7474
ctx.context,
75+
parent_error=parent_error,
7576
)
7677
return ctx.default_return_type
7778

0 commit comments

Comments
 (0)