Skip to content

Commit ac2d85a

Browse files
authored
gh-104050: Argument clinic: annotate format_docstring() (#107200)
1 parent e5d5522 commit ac2d85a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: Tools/clinic/clinic.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -5294,8 +5294,10 @@ def state_function_docstring(self, line):
52945294
new_docstring += line
52955295
self.function.docstring = new_docstring
52965296

5297-
def format_docstring(self):
5297+
def format_docstring(self) -> str:
52985298
f = self.function
5299+
assert f is not None
5300+
assert f.full_name is not None
52995301

53005302
new_or_init = f.kind.new_or_init
53015303
if new_or_init and not f.docstring:
@@ -5338,7 +5340,7 @@ def format_docstring(self):
53385340

53395341
right_bracket_count = 0
53405342

5341-
def fix_right_bracket_count(desired):
5343+
def fix_right_bracket_count(desired: int) -> str:
53425344
nonlocal right_bracket_count
53435345
s = ''
53445346
while right_bracket_count < desired:
@@ -5372,7 +5374,7 @@ def fix_right_bracket_count(desired):
53725374
last_p = parameters[-1]
53735375
line_length = len(''.join(text))
53745376
indent = " " * line_length
5375-
def add_parameter(text):
5377+
def add_parameter(text: str) -> None:
53765378
nonlocal line_length
53775379
nonlocal first_parameter
53785380
if first_parameter:
@@ -5488,9 +5490,9 @@ def add_parameter(text):
54885490
add(p.name)
54895491
add('\n')
54905492
add(textwrap.indent(rstrip_lines(p.docstring.rstrip()), " "))
5491-
parameters = output()
5492-
if parameters:
5493-
parameters += '\n'
5493+
parameters_output = output()
5494+
if parameters_output:
5495+
parameters_output += '\n'
54945496

54955497
##
54965498
## docstring body
@@ -5538,7 +5540,7 @@ def add_parameter(text):
55385540
add(docstring)
55395541
docstring = output()
55405542

5541-
docstring = linear_format(docstring, parameters=parameters)
5543+
docstring = linear_format(docstring, parameters=parameters_output)
55425544
docstring = docstring.rstrip()
55435545

55445546
return docstring

0 commit comments

Comments
 (0)