Skip to content

Commit 2f12b60

Browse files
committed
Fix inference for overloaded __call__ with generic self
Fixes python#8283
1 parent 4496a00 commit 2f12b60

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

mypy/checkmember.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,12 @@ def analyze_instance_member_access(
330330
signature = method.type
331331
signature = freshen_all_functions_type_vars(signature)
332332
if not method.is_static:
333-
if name != "__call__":
334-
# TODO: use proper treatment of special methods on unions instead
335-
# of this hack here and below (i.e. mx.self_type).
336-
dispatched_type = meet.meet_types(mx.original_type, typ)
337-
signature = check_self_arg(
338-
signature, dispatched_type, method.is_class, mx.context, name, mx.msg
339-
)
333+
# TODO: use proper treatment of special methods on unions instead
334+
# of this hack here and below (i.e. mx.self_type).
335+
dispatched_type = meet.meet_types(mx.original_type, typ)
336+
signature = check_self_arg(
337+
signature, dispatched_type, method.is_class, mx.context, name, mx.msg
338+
)
340339
signature = bind_self(signature, mx.self_type, is_classmethod=method.is_class)
341340
# TODO: should we skip these steps for static methods as well?
342341
# Since generic static methods should not be allowed.
@@ -898,7 +897,7 @@ def f(self: S) -> T: ...
898897
selfarg = get_proper_type(item.arg_types[0])
899898
if subtypes.is_subtype(dispatched_arg_type, erase_typevars(erase_to_bound(selfarg))):
900899
new_items.append(item)
901-
elif isinstance(selfarg, ParamSpecType):
900+
elif isinstance(selfarg, (ParamSpecType, TupleType)):
902901
# TODO: This is not always right. What's the most reasonable thing to do here?
903902
new_items.append(item)
904903
elif isinstance(selfarg, TypeVarTupleType):

0 commit comments

Comments
 (0)