@@ -125,7 +125,8 @@ def tuple_fallback(typ: TupleType) -> Instance:
125125 )
126126
127127
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 )
129130 if isinstance (get_proper_type (func .ret_type ), UninhabitedType ):
130131 return func .ret_type
131132 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(
227228 # self-types only in the defining class, similar to __new__ (but not exactly the same,
228229 # see comment in class_callable below). This is mostly useful for annotating library
229230 # classes such as subprocess.Popen.
230- default_self = fill_typevars (info )
231231 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 ]
233233 else :
234234 orig_self_types = [None ] * len (signature .items )
235235
@@ -245,7 +245,7 @@ def type_object_type_from_function(
245245 # We need to map B's __init__ to the type (List[T]) -> None.
246246 signature = bind_self (
247247 signature ,
248- original_type = default_self ,
248+ original_type = fill_typevars ( info ) ,
249249 is_classmethod = is_new ,
250250 # Explicit instance self annotations have special handling in class_callable(),
251251 # we don't need to bind any type variables in them if they are generic.
0 commit comments