Skip to content

Commit adaaa9c

Browse files
gh-104050: Argument Clinic: Annotate output_templates()
1 parent 128a6c1 commit adaaa9c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Tools/clinic/clinic.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,10 @@ 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
798801
assert isinstance(parameters[0].converter, self_converter)
@@ -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,
@@ -1308,6 +1311,8 @@ def parser_body(
13081311
cpp_if = "#if " + conditional
13091312
cpp_endif = "#endif /* " + conditional + " */"
13101313

1314+
assert clinic is not None
1315+
assert f.full_name is not None
13111316
if methoddef_define and f.full_name not in clinic.ifndef_symbols:
13121317
clinic.ifndef_symbols.add(f.full_name)
13131318
methoddef_ifndef = normalize_snippet("""

0 commit comments

Comments
 (0)