aboutsummaryrefslogtreecommitdiff
path: root/scripts/qmp/qmp-shell
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2021-06-07 16:06:31 -0400
committerJohn Snow <jsnow@redhat.com>2021-06-18 16:10:07 -0400
commitdb12abc20859e93e802f668a2f744222c96ada63 (patch)
tree54179356eec7910f134e6833886aca45d54079c7 /scripts/qmp/qmp-shell
parent6faf2384ec78d5a1e0b5dfe430e80cf2278e45c4 (diff)
downloadqemu-db12abc20859e93e802f668a2f744222c96ada63.zip
qemu-db12abc20859e93e802f668a2f744222c96ada63.tar.gz
qemu-db12abc20859e93e802f668a2f744222c96ada63.tar.bz2
scripts/qmp-shell: refactor QMPCompleter
list is a generic type, but we expect to use strings directly. We could subclass list[str], but pylint does not presently understand that invocation. Change this class to envelop a list instead of *being* a list, for simpler mypy typing. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-25-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'scripts/qmp/qmp-shell')
-rwxr-xr-xscripts/qmp/qmp-shell14
1 files changed, 11 insertions, 3 deletions
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index 847d348..7369403 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -78,9 +78,17 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
from qemu import qmp
-class QMPCompleter(list):
- def complete(self, text, state):
- for cmd in self:
+class QMPCompleter:
+ # NB: Python 3.9+ will probably allow us to subclass list[str] directly,
+ # but pylint as of today does not know that List[str] is simply 'list'.
+ def __init__(self) -> None:
+ self._matches: List[str] = []
+
+ def append(self, value: str) -> None:
+ return self._matches.append(value)
+
+ def complete(self, text: str, state: int) -> Optional[str]:
+ for cmd in self._matches:
if cmd.startswith(text):
if state == 0:
return cmd