@@ -792,11 +792,14 @@ def docstring_for_c_string(
792
792
add ('"' )
793
793
return '' .join (text )
794
794
795
- def output_templates (self , f ):
795
+ def output_templates (
796
+ self ,
797
+ f : Function
798
+ ) -> dict [str , str ]:
796
799
parameters = list (f .parameters .values ())
797
800
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 )
800
803
requires_defining_class = False
801
804
if parameters and isinstance (parameters [0 ].converter , defining_class_converter ):
802
805
requires_defining_class = True
@@ -809,7 +812,7 @@ def output_templates(self, f):
809
812
810
813
new_or_init = f .kind .new_or_init
811
814
812
- vararg = NO_VARARG
815
+ vararg : int | str = NO_VARARG
813
816
pos_only = min_pos = max_pos = min_kw_only = pseudo_args = 0
814
817
for i , p in enumerate (parameters , 1 ):
815
818
if p .is_keyword_only ():
@@ -897,7 +900,7 @@ def output_templates(self, f):
897
900
898
901
# parser_body_fields remembers the fields passed in to the
899
902
# previous call to parser_body. this is used for an awful hack.
900
- parser_body_fields = ()
903
+ parser_body_fields : tuple [ str , ...] = ()
901
904
def parser_body (
902
905
prototype : str ,
903
906
* fields : str ,
@@ -932,6 +935,7 @@ def parser_body(
932
935
return linear_format (output (), parser_declarations = declarations )
933
936
934
937
if not parameters :
938
+ parser_code : list [str ] | None
935
939
if not requires_defining_class :
936
940
# no parameters, METH_NOARGS
937
941
flags = "METH_NOARGS"
@@ -1165,7 +1169,7 @@ def parser_body(
1165
1169
flags = 'METH_METHOD|' + flags
1166
1170
parser_prototype = parser_prototype_def_class
1167
1171
1168
- add_label = None
1172
+ add_label : str | None = None
1169
1173
for i , p in enumerate (parameters ):
1170
1174
if isinstance (p .converter , defining_class_converter ):
1171
1175
raise ValueError ("defining_class should be the first "
@@ -1308,6 +1312,8 @@ def parser_body(
1308
1312
cpp_if = "#if " + conditional
1309
1313
cpp_endif = "#endif /* " + conditional + " */"
1310
1314
1315
+ assert clinic is not None
1316
+ assert f .full_name is not None
1311
1317
if methoddef_define and f .full_name not in clinic .ifndef_symbols :
1312
1318
clinic .ifndef_symbols .add (f .full_name )
1313
1319
methoddef_ifndef = normalize_snippet ("""
0 commit comments