aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2021-06-04 11:55:28 -0400
committerJohn Snow <jsnow@redhat.com>2021-06-18 16:10:06 -0400
commit1f6399393bc672c2b89c3c3b862ff96baecc1bef (patch)
tree0f75c626ebfb5d72f94af3dfc40f9f0c26836948 /python
parentf85d3252ef889b102eb42756450f45c973d3cb43 (diff)
downloadqemu-1f6399393bc672c2b89c3c3b862ff96baecc1bef.zip
qemu-1f6399393bc672c2b89c3c3b862ff96baecc1bef.tar.gz
qemu-1f6399393bc672c2b89c3c3b862ff96baecc1bef.tar.bz2
python/qmp: Correct type of QMPReturnValue
It's only a Dict[str, Any] most of the time. It's not actually guaranteed to be anything in particular. Fix this type to be more accurate to the reality we live in. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-8-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'python')
-rw-r--r--python/qemu/qmp/__init__.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py
index 822c793..a6e1a7b 100644
--- a/python/qemu/qmp/__init__.py
+++ b/python/qemu/qmp/__init__.py
@@ -35,14 +35,19 @@ from typing import (
)
-# QMPMessage is a QMP Message of any kind.
-# e.g. {'yee': 'haw'}
+#: QMPMessage is an entire QMP message of any kind.
+QMPMessage = Dict[str, Any]
+
+#: QMPReturnValue is the 'return' value of a command.
+QMPReturnValue = object
+
+# QMPMessage can be outgoing commands or incoming events/returns.
+# QMPReturnValue is usually a dict/json object, but due to QAPI's
+# 'returns-whitelist', it can actually be anything.
#
-# QMPReturnValue is the inner value of return values only.
-# {'return': {}} is the QMPMessage,
+# {'return': {}} is a QMPMessage,
# {} is the QMPReturnValue.
-QMPMessage = Dict[str, Any]
-QMPReturnValue = Dict[str, Any]
+
InternetAddrT = Tuple[str, int]
UnixAddrT = str
@@ -297,8 +302,8 @@ class QEMUMonitorProtocol:
return resp
def cmd(self, name: str,
- args: Optional[Dict[str, Any]] = None,
- cmd_id: Optional[Any] = None) -> QMPMessage:
+ args: Optional[Dict[str, object]] = None,
+ cmd_id: Optional[object] = None) -> QMPMessage:
"""
Build a QMP command and send it to the QMP Monitor.
@@ -313,7 +318,7 @@ class QEMUMonitorProtocol:
qmp_cmd['id'] = cmd_id
return self.cmd_obj(qmp_cmd)
- def command(self, cmd: str, **kwds: Any) -> QMPReturnValue:
+ def command(self, cmd: str, **kwds: object) -> QMPReturnValue:
"""
Build and send a QMP command to the monitor, report errors if any
"""