@@ -792,11 +792,14 @@ def docstring_for_c_string(
792792 add ('"' )
793793 return '' .join (text )
794794
795- def output_templates (self , f ):
795+ def output_templates (
796+ self ,
797+ f : Function
798+ ) -> dict [str , str ]:
796799 parameters = list (f .parameters .values ())
797800 assert parameters
798- assert isinstance ( parameters [ 0 ]. converter , self_converter )
799- del parameters [ 0 ]
801+ first_param = parameters . pop ( 0 )
802+ assert isinstance ( first_param . converter , self_converter )
800803 requires_defining_class = False
801804 if parameters and isinstance (parameters [0 ].converter , defining_class_converter ):
802805 requires_defining_class = True
@@ -809,7 +812,7 @@ def output_templates(self, f):
809812
810813 new_or_init = f .kind .new_or_init
811814
812- vararg = NO_VARARG
815+ vararg : int | str = NO_VARARG
813816 pos_only = min_pos = max_pos = min_kw_only = pseudo_args = 0
814817 for i , p in enumerate (parameters , 1 ):
815818 if p .is_keyword_only ():
@@ -897,7 +900,7 @@ def output_templates(self, f):
897900
898901 # parser_body_fields remembers the fields passed in to the
899902 # previous call to parser_body. this is used for an awful hack.
900- parser_body_fields = ()
903+ parser_body_fields : tuple [ str , ...] = ()
901904 def parser_body (
902905 prototype : str ,
903906 * fields : str ,
@@ -932,6 +935,7 @@ def parser_body(
932935 return linear_format (output (), parser_declarations = declarations )
933936
934937 if not parameters :
938+ parser_code : list [str ] | None
935939 if not requires_defining_class :
936940 # no parameters, METH_NOARGS
937941 flags = "METH_NOARGS"
@@ -1165,7 +1169,7 @@ def parser_body(
11651169 flags = 'METH_METHOD|' + flags
11661170 parser_prototype = parser_prototype_def_class
11671171
1168- add_label = None
1172+ add_label : str | None = None
11691173 for i , p in enumerate (parameters ):
11701174 if isinstance (p .converter , defining_class_converter ):
11711175 raise ValueError ("defining_class should be the first "
@@ -1308,6 +1312,8 @@ def parser_body(
13081312 cpp_if = "#if " + conditional
13091313 cpp_endif = "#endif /* " + conditional + " */"
13101314
1315+ assert clinic is not None
1316+ assert f .full_name is not None
13111317 if methoddef_define and f .full_name not in clinic .ifndef_symbols :
13121318 clinic .ifndef_symbols .add (f .full_name )
13131319 methoddef_ifndef = normalize_snippet ("""
0 commit comments