Skip to content

Commit e2ff14a

Browse files
author
Markus Armbruster
committed
qapi: Bury some unused code in class Indentation
.__int__() has never been used. Drop it. .decrease() raises ArithmeticError when asked to decrease indentation level below zero. Nothing catches it. It's a programming error. Dumb down to assert. Signed-off-by: Markus Armbruster <[email protected]> Message-Id: <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]>
1 parent 916fca1 commit e2ff14a

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

scripts/qapi/common.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ class Indentation:
132132
def __init__(self, initial: int = 0) -> None:
133133
self._level = initial
134134

135-
def __int__(self) -> int:
136-
return self._level
137-
138135
def __repr__(self) -> str:
139136
return "{}({:d})".format(type(self).__name__, self._level)
140137

@@ -148,9 +145,7 @@ def increase(self, amount: int = 4) -> None:
148145

149146
def decrease(self, amount: int = 4) -> None:
150147
"""Decrease the indentation level by ``amount``, default 4."""
151-
if self._level < amount:
152-
raise ArithmeticError(
153-
f"Can't remove {amount:d} spaces from {self!r}")
148+
assert amount <= self._level
154149
self._level -= amount
155150

156151

0 commit comments

Comments
 (0)