mirror of
https://github.com/python/cpython.git
synced 2026-01-06 23:42:34 +00:00
gh-104050: Argument Clinic: Annotate the IndentStack class (#106934)
This commit is contained in:
parent
1218910860
commit
d81b4f8ff8
1 changed files with 5 additions and 5 deletions
|
|
@ -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'.)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue