[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 23/72] python/qmp: Correct type of QMPReturnValue
From: |
John Snow |
Subject: |
[PATCH v2 23/72] python/qmp: Correct type of QMPReturnValue |
Date: |
Tue, 3 Nov 2020 19:35:13 -0500 |
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>
---
python/qemu/qmp/__init__.py | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py
index 9606248a3d2e..7355a558796f 100644
--- a/python/qemu/qmp/__init__.py
+++ b/python/qemu/qmp/__init__.py
@@ -35,14 +35,19 @@
)
-# QMPMessage is a QMP Message of any kind.
-# e.g. {'yee': 'haw'}
-#
-# QMPReturnValue is the inner value of return values only.
-# {'return': {}} is the QMPMessage,
-# {} is the QMPReturnValue.
+#: QMPMessage is an entire QMP message of any kind.
QMPMessage = Dict[str, Any]
-QMPReturnValue = 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.
+#
+# {'return': {}} is a QMPMessage,
+# {} is the QMPReturnValue.
+
InternetAddrT = Tuple[str, str]
UnixAddrT = str
@@ -271,8 +276,8 @@ def cmd_obj(self, qmp_cmd: QMPMessage) -> QMPMessage:
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.
@@ -287,7 +292,7 @@ def cmd(self, name: str,
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
"""
--
2.26.2
- [PATCH v2 11/72] scripts/qom-fuse: ensure QOMFuse.read always returns bytes, (continued)
- [PATCH v2 11/72] scripts/qom-fuse: ensure QOMFuse.read always returns bytes, John Snow, 2020/11/03
- [PATCH v2 16/72] python: add optional fuse dependency, John Snow, 2020/11/03
- [PATCH v2 10/72] scripts/qom-fuse: use QOMCommand.qom_list(), John Snow, 2020/11/03
- [PATCH v2 13/72] scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.py, John Snow, 2020/11/03
- [PATCH v2 15/72] python: add fuse command to 'qom' tools, John Snow, 2020/11/03
- [PATCH v2 18/72] scripts/qemu-ga-client: apply (most) flake8 rules, John Snow, 2020/11/03
- [PATCH v2 20/72] scripts/qemu-ga-client: replace deprecated optparse with argparse, John Snow, 2020/11/03
- [PATCH v2 19/72] scripts/qemu-ga-client: Fix exception handling, John Snow, 2020/11/03
- [PATCH v2 26/72] python/qemu-ga-client: add entry point, John Snow, 2020/11/03
- [PATCH v2 29/72] scripts/qmp-shell: Apply flake8 rules, John Snow, 2020/11/03
- [PATCH v2 23/72] python/qmp: Correct type of QMPReturnValue,
John Snow <=
- [PATCH v2 28/72] scripts/qmp-shell: apply isort rules, John Snow, 2020/11/03
- [PATCH v2 21/72] scripts/qemu-ga-client: add module docstring, John Snow, 2020/11/03
- [PATCH v2 27/72] scripts/qemu-ga-client: Add forwarder stub, John Snow, 2020/11/03
- [PATCH v2 25/72] scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.py, John Snow, 2020/11/03
- [PATCH v2 17/72] scripts/qemu-ga-client: apply isort rules, John Snow, 2020/11/03
- [PATCH v2 14/72] scripts/qom-fuse: add redirection shim to python/qemu/qmp/qom-fuse.py, John Snow, 2020/11/03
- [PATCH v2 22/72] scripts/qemu-ga-client: apply (most) pylint rules, John Snow, 2020/11/03
- [PATCH v2 31/72] scripts/qmp-shell: fix exception handling, John Snow, 2020/11/03
- [PATCH v2 32/72] scripts/qmp-shell: fix connect method signature, John Snow, 2020/11/03
- [PATCH v2 30/72] scripts/qmp-shell: fix show_banner signature, John Snow, 2020/11/03