Skip to content

Commit 916fca1

Browse files
author
Markus Armbruster
committed
qapi: Drop Indentation.__bool__()
Intentation.__bool__() is not worth its keep: it has just one user, which can just as well check .__str__() instead. Signed-off-by: Markus Armbruster <[email protected]> Message-Id: <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]>
1 parent 7b275cd commit 916fca1

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

scripts/qapi/common.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ def __str__(self) -> str:
142142
"""Return the current indentation as a string of spaces."""
143143
return ' ' * self._level
144144

145-
def __bool__(self) -> bool:
146-
"""True when there is a non-zero indentation."""
147-
return bool(self._level)
148-
149145
def increase(self, amount: int = 4) -> None:
150146
"""Increase the indentation level by ``amount``, default 4."""
151147
self._level += amount
@@ -169,8 +165,9 @@ def cgen(code: str, **kwds: object) -> str:
169165
Obey `indent`, and strip `EATSPACE`.
170166
"""
171167
raw = code % kwds
172-
if indent:
173-
raw = re.sub(r'^(?!(#|$))', str(indent), raw, flags=re.MULTILINE)
168+
pfx = str(indent)
169+
if pfx:
170+
raw = re.sub(r'^(?!(#|$))', pfx, raw, flags=re.MULTILINE)
174171
return re.sub(re.escape(EATSPACE) + r' *', '', raw)
175172

176173

0 commit comments

Comments
 (0)