[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/5] qapi: Bury some unused code in class Indentation
From: |
Markus Armbruster |
Subject: |
[PATCH 3/5] qapi: Bury some unused code in class Indentation |
Date: |
Wed, 8 Sep 2021 06:54:26 +0200 |
.__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>
---
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
- [PATCH 0/5] qapi: Another round of minor fixes and cleanups, Markus Armbruster, 2021/09/08
- [PATCH 4/5] tests/qapi-schema: Cover 'not' condition with empty argument, Markus Armbruster, 2021/09/08
- [PATCH 3/5] qapi: Bury some unused code in class Indentation,
Markus Armbruster <=
- [PATCH 5/5] qapi: Fix bogus error for 'if': { 'not': '' }, Markus Armbruster, 2021/09/08
- [PATCH 1/5] qapi: Fix a botched type annotation, Markus Armbruster, 2021/09/08
- [PATCH 2/5] qapi: Drop Indentation.__bool__(), Markus Armbruster, 2021/09/08
- Re: [PATCH 0/5] qapi: Another round of minor fixes and cleanups, Marc-André Lureau, 2021/09/08
- Re: [PATCH 0/5] qapi: Another round of minor fixes and cleanups, Markus Armbruster, 2021/09/13