summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorAlex Waygood <Alex.Waygood@Gmail.com>2023-07-24 20:29:50 (GMT)
committerGitHub <noreply@github.com>2023-07-24 20:29:50 (GMT)
commitac2d85a174d6fd0b1fd06aca6657fb002cd120f3 (patch)
tree597879b743647e2c2487be5b077c6475793d8c1b /Tools
parente5d5522612e03af3941db1d270bf6caebf330b8a (diff)
downloadcpython-ac2d85a174d6fd0b1fd06aca6657fb002cd120f3.zip
cpython-ac2d85a174d6fd0b1fd06aca6657fb002cd120f3.tar.gz
cpython-ac2d85a174d6fd0b1fd06aca6657fb002cd120f3.tar.bz2
gh-104050: Argument clinic: annotate `format_docstring()` (#107200)
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/clinic/clinic.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index c9c57f1..59e0bf6 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -5294,8 +5294,10 @@ class DSLParser:
new_docstring += line
self.function.docstring = new_docstring
- def format_docstring(self):
+ def format_docstring(self) -> str:
f = self.function
+ assert f is not None
+ assert f.full_name is not None
new_or_init = f.kind.new_or_init
if new_or_init and not f.docstring:
@@ -5338,7 +5340,7 @@ class DSLParser:
right_bracket_count = 0
- def fix_right_bracket_count(desired):
+ def fix_right_bracket_count(desired: int) -> str:
nonlocal right_bracket_count
s = ''
while right_bracket_count < desired:
@@ -5372,7 +5374,7 @@ class DSLParser:
last_p = parameters[-1]
line_length = len(''.join(text))
indent = " " * line_length
- def add_parameter(text):
+ def add_parameter(text: str) -> None:
nonlocal line_length
nonlocal first_parameter
if first_parameter:
@@ -5488,9 +5490,9 @@ class DSLParser:
add(p.name)
add('\n')
add(textwrap.indent(rstrip_lines(p.docstring.rstrip()), " "))
- parameters = output()
- if parameters:
- parameters += '\n'
+ parameters_output = output()
+ if parameters_output:
+ parameters_output += '\n'
##
## docstring body
@@ -5538,7 +5540,7 @@ class DSLParser:
add(docstring)
docstring = output()
- docstring = linear_format(docstring, parameters=parameters)
+ docstring = linear_format(docstring, parameters=parameters_output)
docstring = docstring.rstrip()
return docstring