@@ -79,6 +79,8 @@ def analyze_typeddict_classdef(self, defn: ClassDef) -> tuple[bool, TypeInfo | N
7979 """
8080 possible = False
8181 for base_expr in defn .base_type_exprs :
82+ if isinstance (base_expr , CallExpr ):
83+ base_expr = base_expr .callee
8284 if isinstance (base_expr , IndexExpr ):
8385 base_expr = base_expr .base
8486 if isinstance (base_expr , RefExpr ):
@@ -117,7 +119,13 @@ def analyze_typeddict_classdef(self, defn: ClassDef) -> tuple[bool, TypeInfo | N
117119 typeddict_bases : list [Expression ] = []
118120 typeddict_bases_set = set ()
119121 for expr in defn .base_type_exprs :
120- if isinstance (expr , RefExpr ) and expr .fullname in TPDICT_NAMES :
122+ ok , maybe_type_info , _ = self .check_typeddict (expr , None , False )
123+ if ok and maybe_type_info is not None :
124+ # expr is a CallExpr
125+ info = maybe_type_info
126+ typeddict_bases_set .add (info .fullname )
127+ typeddict_bases .append (expr )
128+ elif isinstance (expr , RefExpr ) and expr .fullname in TPDICT_NAMES :
121129 if "TypedDict" not in typeddict_bases_set :
122130 typeddict_bases_set .add ("TypedDict" )
123131 else :
@@ -176,19 +184,22 @@ def add_keys_and_types_from_base(
176184 required_keys : set [str ],
177185 ctx : Context ,
178186 ) -> None :
187+ base_args : list [Type ] = []
179188 if isinstance (base , RefExpr ):
180189 assert isinstance (base .node , TypeInfo )
181190 info = base .node
182- base_args : list [Type ] = []
183- else :
184- assert isinstance (base , IndexExpr )
191+ elif isinstance (base , IndexExpr ):
185192 assert isinstance (base .base , RefExpr )
186193 assert isinstance (base .base .node , TypeInfo )
187194 info = base .base .node
188195 args = self .analyze_base_args (base , ctx )
189196 if args is None :
190197 return
191198 base_args = args
199+ else :
200+ assert isinstance (base , CallExpr )
201+ assert isinstance (base .analyzed , TypedDictExpr )
202+ info = base .analyzed .info
192203
193204 assert info .typeddict_type is not None
194205 base_typed_dict = info .typeddict_type
0 commit comments