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.
"""
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:
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'.)