diff options
author | Markus Armbruster <armbru@redhat.com> | 2021-09-08 06:54:26 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-09-08 15:30:10 +0200 |
commit | e2ff14a5740c2fe3714a56221792b6d74bc64c08 (patch) | |
tree | 8e384de5ac3128a1fbc99f5504bb195fcbf62532 | |
parent | 916fca17c7445c17d4be37610c80c1f68784ef28 (diff) | |
download | qemu-e2ff14a5740c2fe3714a56221792b6d74bc64c08.zip qemu-e2ff14a5740c2fe3714a56221792b6d74bc64c08.tar.gz qemu-e2ff14a5740c2fe3714a56221792b6d74bc64c08.tar.bz2 |
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 <armbru@redhat.com>
Message-Id: <20210908045428.2689093-4-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r-- | scripts/qapi/common.py | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 1d62c27..4892735 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -132,9 +132,6 @@ class Indentation: def __init__(self, initial: int = 0) -> None: self._level = initial - def __int__(self) -> int: - return self._level - def __repr__(self) -> str: return "{}({:d})".format(type(self).__name__, self._level) @@ -148,9 +145,7 @@ class Indentation: def decrease(self, amount: int = 4) -> None: """Decrease the indentation level by ``amount``, default 4.""" - if self._level < amount: - raise ArithmeticError( - f"Can't remove {amount:d} spaces from {self!r}") + assert amount <= self._level self._level -= amount |