[Python-checkins] gh-104050: Argument Clinic: Annotate the IndentStack class (#106934)
erlend-aasland
webhook-mailer at python.org
Thu Jul 20 19:19:15 EDT 2023
https://github.com/python/cpython/commit/d81b4f8ff84311fa737e62f2883442ec06d7d5d8
commit: d81b4f8ff84311fa737e62f2883442ec06d7d5d8
branch: main
author: Erlend E. Aasland <erlend at python.org>
committer: erlend-aasland <erlend.aasland at protonmail.com>
date: 2023-07-20T23:19:11Z
summary:
gh-104050: Argument Clinic: Annotate the IndentStack class (#106934)
files:
M Tools/clinic/clinic.py
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py
index 003ecf784d711..a204c1dd0dc2d 100755
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -4284,7 +4284,7 @@ def _ensure(self):
if not self.indents:
fail('IndentStack expected indents, but none are defined.')
- def measure(self, line):
+ def measure(self, line: str) -> int:
"""
Returns the length of the line's margin.
"""
@@ -4298,7 +4298,7 @@ def measure(self, line):
return self.indents[-1]
return len(line) - len(stripped)
- def infer(self, line):
+ def infer(self, line: str) -> int:
"""
Infer what is now the current margin based on this line.
Returns:
@@ -4331,19 +4331,19 @@ def infer(self, line):
return outdent_count
@property
- def depth(self):
+ def depth(self) -> int:
"""
Returns how many margins are currently defined.
"""
return len(self.indents)
- def indent(self, line):
+ def indent(self, line: str) -> str:
"""
Indents a line by the currently defined margin.
"""
return self.margin + line
- def dedent(self, line):
+ def dedent(self, line: str) -> str:
"""
Dedents a line by the currently defined margin.
(The inverse of 'indent'.)
More information about the Python-checkins
mailing list