From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PULL 3/5] qapi: Bury some unused code in class Indentation
Date: Mon, 13 Sep 2021 11:50:36 +0200 [thread overview]
Message-ID: <20210913095038.3040776-4-armbru@redhat.com> (raw)
In-Reply-To: <20210913095038.3040776-1-armbru@redhat.com>
.__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>
---
scripts/qapi/common.py | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 1d62c27fb7..489273574a 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 @@ def increase(self, amount: int = 4) -> None:
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
--
2.31.1
next prev parent reply other threads:[~2021-09-13 9:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 9:50 [PULL 0/5] QAPI patches patches for 2021-09-13 Markus Armbruster
2021-09-13 9:50 ` [PULL 1/5] qapi: Fix a botched type annotation Markus Armbruster
2021-09-13 9:50 ` [PULL 2/5] qapi: Drop Indentation.__bool__() Markus Armbruster
2021-09-13 9:50 ` Markus Armbruster [this message]
2021-09-13 9:50 ` [PULL 4/5] tests/qapi-schema: Cover 'not' condition with empty argument Markus Armbruster
2021-09-13 9:50 ` [PULL 5/5] qapi: Fix bogus error for 'if': { 'not': '' } Markus Armbruster
2021-09-13 12:32 ` [PULL 0/5] QAPI patches patches for 2021-09-13 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210913095038.3040776-4-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.