Skip to content

Commit 3ee9c95

Browse files
committed
And only do this if we actually have a selftype annotation
1 parent 369a100 commit 3ee9c95

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

mypy/checkexpr.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2917,11 +2917,20 @@ def infer_overload_return_type(
29172917
# check. Pretend that we're checking `Foo.func(instance, ...)` instead of
29182918
# `instance.func(...)`.
29192919
p_object_type = get_proper_type(object_type) if object_type is not None else None
2920+
2921+
def is_trivial_self(t: CallableType) -> bool:
2922+
if isinstance(t.definition, FuncDef):
2923+
return t.definition.is_trivial_self
2924+
if isinstance(t.definition, Decorator):
2925+
return t.definition.func.is_trivial_self
2926+
return False
2927+
29202928
prepend_self = (
29212929
isinstance(p_object_type, Instance)
29222930
and has_any_type(p_object_type)
29232931
and any(
2924-
typ.is_bound and typ.original_self_type is not None for typ in plausible_targets
2932+
typ.is_bound and typ.original_self_type is not None and not is_trivial_self(typ)
2933+
for typ in plausible_targets
29252934
)
29262935
)
29272936
if prepend_self:

0 commit comments

Comments
 (0)