@@ -125,7 +125,8 @@ def tuple_fallback(typ: TupleType) -> Instance:
125
125
)
126
126
127
127
128
- def get_self_type (func : CallableType , default_self : Instance | TupleType ) -> Type | None :
128
+ def get_self_type (func : CallableType , def_info : TypeInfo ) -> Type | None :
129
+ default_self = fill_typevars (def_info )
129
130
if isinstance (get_proper_type (func .ret_type ), UninhabitedType ):
130
131
return func .ret_type
131
132
elif func .arg_types and func .arg_types [0 ] != default_self and func .arg_kinds [0 ] == ARG_POS :
@@ -227,9 +228,8 @@ def type_object_type_from_function(
227
228
# self-types only in the defining class, similar to __new__ (but not exactly the same,
228
229
# see comment in class_callable below). This is mostly useful for annotating library
229
230
# classes such as subprocess.Popen.
230
- default_self = fill_typevars (info )
231
231
if not is_new and not info .is_newtype :
232
- orig_self_types = [get_self_type (it , default_self ) for it in signature .items ]
232
+ orig_self_types = [get_self_type (it , def_info ) for it in signature .items ]
233
233
else :
234
234
orig_self_types = [None ] * len (signature .items )
235
235
@@ -245,7 +245,7 @@ def type_object_type_from_function(
245
245
# We need to map B's __init__ to the type (List[T]) -> None.
246
246
signature = bind_self (
247
247
signature ,
248
- original_type = default_self ,
248
+ original_type = fill_typevars ( info ) ,
249
249
is_classmethod = is_new ,
250
250
# Explicit instance self annotations have special handling in class_callable(),
251
251
# we don't need to bind any type variables in them if they are generic.
0 commit comments