@@ -1094,9 +1094,13 @@ def process_typeddict(self, lvalue: NameExpr, rvalue: CallExpr) -> None:
10941094 if not isinstance (rvalue .args [0 ], StrExpr ):
10951095 self .annotate_as_incomplete (lvalue )
10961096 return
1097+ if len (rvalue .args ) > 2 and rvalue .arg_kinds [2 ] != ARG_NAMED :
1098+ self .annotate_as_incomplete (lvalue )
1099+ return
10971100
10981101 items : list [tuple [str , Expression ]] = []
10991102 total : Expression | None = None
1103+ closed : Expression | None = None
11001104 if len (rvalue .args ) > 1 and rvalue .arg_kinds [1 ] == ARG_POS :
11011105 if not isinstance (rvalue .args [1 ], DictExpr ):
11021106 self .annotate_as_incomplete (lvalue )
@@ -1106,11 +1110,14 @@ def process_typeddict(self, lvalue: NameExpr, rvalue: CallExpr) -> None:
11061110 self .annotate_as_incomplete (lvalue )
11071111 return
11081112 items .append ((attr_name .value , attr_type ))
1109- if len (rvalue .args ) > 2 :
1110- if rvalue .arg_kinds [2 ] != ARG_NAMED or rvalue .arg_names [2 ] != "total" :
1113+ for arg_name , arg in zip (rvalue .arg_names [2 :], rvalue .args [2 :]):
1114+ if arg_name == "total" :
1115+ total = arg
1116+ elif arg_name == "closed" :
1117+ closed = arg
1118+ else :
11111119 self .annotate_as_incomplete (lvalue )
11121120 return
1113- total = rvalue .args [2 ]
11141121 else :
11151122 for arg_name , arg in zip (rvalue .arg_names [1 :], rvalue .args [1 :]):
11161123 if not isinstance (arg_name , str ):
@@ -1130,6 +1137,8 @@ def process_typeddict(self, lvalue: NameExpr, rvalue: CallExpr) -> None:
11301137 # TODO: Add support for generic TypedDicts. Requires `Generic` as base class.
11311138 if total is not None :
11321139 bases += f", total={ total .accept (p )} "
1140+ if closed is not None :
1141+ bases += f", closed={ closed .accept (p )} "
11331142 class_def = f"{ self ._indent } class { lvalue .name } ({ bases } ):"
11341143 if len (items ) == 0 :
11351144 self .add (f"{ class_def } ...\n " )
0 commit comments