From 00376d1345475fb3613a0d58584f161cd870ea90 Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:09 -0400 Subject: python/qom: Do not use 'err' name at module scope Pylint updated to 2.9.0 upstream, adding new warnings for things that re-use the 'err' variable. Luckily, this only breaks the python-check-tox job, which is allowed to fail as a warning. Signed-off-by: John Snow Reviewed-by: Wainer dos Santos Moschetta Reviewed-by: Willian Rampazzo Message-id: 20210629214323.1329806-2-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/qmp/qom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python/qemu') diff --git a/python/qemu/qmp/qom.py b/python/qemu/qmp/qom.py index 7ec7843..8ff28a8 100644 --- a/python/qemu/qmp/qom.py +++ b/python/qemu/qmp/qom.py @@ -38,8 +38,8 @@ from .qom_common import QOMCommand try: from .qom_fuse import QOMFuse -except ModuleNotFoundError as err: - if err.name != 'fuse': +except ModuleNotFoundError as _err: + if _err.name != 'fuse': raise else: assert issubclass(QOMFuse, QOMCommand) -- cgit v1.1 From 7f179082638efe920748b5243423bdcaed3d42ef Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:10 -0400 Subject: python: expose typing information via PEP 561 https://www.python.org/dev/peps/pep-0561/#specification Create 'py.typed' files in each subpackage that indicate to mypy that this is a typed module, so that users of any of these packages can use mypy to check their code as well. Note: Theoretically it's possible to ditch MANIFEST.in in favor of using package_data in setup.cfg, but I genuinely could not figure out how to get it to include things from the *source root* into the *package root*; only how to include things from each subpackage. I tried! Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-3-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/py.typed | 0 python/qemu/qmp/py.typed | 0 python/qemu/utils/py.typed | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 python/qemu/machine/py.typed create mode 100644 python/qemu/qmp/py.typed create mode 100644 python/qemu/utils/py.typed (limited to 'python/qemu') diff --git a/python/qemu/machine/py.typed b/python/qemu/machine/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/python/qemu/qmp/py.typed b/python/qemu/qmp/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/python/qemu/utils/py.typed b/python/qemu/utils/py.typed new file mode 100644 index 0000000..e69de29 -- cgit v1.1 From 82e6517d9d0a1ce9fdc09919af26775a5127a5ec Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:11 -0400 Subject: python: Remove global pylint suppressions These suppressions only apply to a small handful of places. Instead of disabling them globally, disable them just in the cases where we need. The design of the machine class grew quite organically with tons of constructor and class instance variables -- there's little chance of meaningfully refactoring it in the near term, so just suppress the warnings for that class. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-4-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/machine.py | 3 +++ python/qemu/machine/qtest.py | 2 ++ 2 files changed, 5 insertions(+) (limited to 'python/qemu') diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index b624355..e3345df 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -84,6 +84,7 @@ class QEMUMachine: ... # vm is guaranteed to be shut down here """ + # pylint: disable=too-many-instance-attributes, too-many-public-methods def __init__(self, binary: str, @@ -111,6 +112,8 @@ class QEMUMachine: @param console_log: (optional) path to console log file @note: Qemu process is not started until launch() is used. ''' + # pylint: disable=too-many-arguments + # Direct user configuration self._binary = binary diff --git a/python/qemu/machine/qtest.py b/python/qemu/machine/qtest.py index 9370068..d6d9c6a 100644 --- a/python/qemu/machine/qtest.py +++ b/python/qemu/machine/qtest.py @@ -116,6 +116,8 @@ class QEMUQtestMachine(QEMUMachine): base_temp_dir: str = "/var/tmp", socket_scm_helper: Optional[str] = None, sock_dir: Optional[str] = None): + # pylint: disable=too-many-arguments + if name is None: name = "qemu-%d" % os.getpid() if sock_dir is None: -- cgit v1.1 From 5c02c865866fdd2d17e8f5507deb4aa1f74bf59f Mon Sep 17 00:00:00 2001 From: John Snow Date: Tue, 29 Jun 2021 17:43:23 -0400 Subject: python: Fix broken ReST docstrings This patch *doesn't* update all of the docstring standards across the QEMU package directory to make our docstring usage consistent. It *doesn't* fix the formatting to make it look pretty or reasonable in generated output. It *does* fix a few small instances where Sphinx would emit a build warning because of malformed ReST -- If we built our Python docs with Sphinx. Signed-off-by: John Snow Reviewed-by: Willian Rampazzo Reviewed-by: Wainer dos Santos Moschetta Message-id: 20210629214323.1329806-16-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/machine/__init__.py | 6 +++--- python/qemu/machine/machine.py | 3 ++- python/qemu/qmp/__init__.py | 1 + python/qemu/qmp/qom_common.py | 2 +- python/qemu/utils/accel.py | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) (limited to 'python/qemu') diff --git a/python/qemu/machine/__init__.py b/python/qemu/machine/__init__.py index 728f27a..9ccd58e 100644 --- a/python/qemu/machine/__init__.py +++ b/python/qemu/machine/__init__.py @@ -4,10 +4,10 @@ QEMU development and testing library. This library provides a few high-level classes for driving QEMU from a test suite, not intended for production use. -- QEMUMachine: Configure and Boot a QEMU VM - - QEMUQtestMachine: VM class, with a qtest socket. + | QEMUQtestProtocol: send/receive qtest messages. + | QEMUMachine: Configure and Boot a QEMU VM + | +-- QEMUQtestMachine: VM class, with a qtest socket. -- QEMUQtestProtocol: Connect to, send/receive qtest messages. """ # Copyright (C) 2020-2021 John Snow for Red Hat Inc. diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index e3345df..d47ab3d 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -545,7 +545,8 @@ class QEMUMachine: @param enabled: if False, qmp monitor options will be removed from the base arguments of the resulting QEMU command line. Default is True. - @note: call this function before launch(). + + .. note:: Call this function before launch(). """ self._qmp_set = enabled diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py index 376954c..269516a 100644 --- a/python/qemu/qmp/__init__.py +++ b/python/qemu/qmp/__init__.py @@ -279,6 +279,7 @@ class QEMUMonitorProtocol: None). The value passed will set the behavior of the underneath QMP socket as described in [1]. Default value is set to 15.0. + @return QMP greeting dict @raise OSError on socket connection errors @raise QMPConnectError if the greeting is not received diff --git a/python/qemu/qmp/qom_common.py b/python/qemu/qmp/qom_common.py index f82b167..a59ae1a 100644 --- a/python/qemu/qmp/qom_common.py +++ b/python/qemu/qmp/qom_common.py @@ -156,7 +156,7 @@ class QOMCommand: """ Run a fully-parsed subcommand, with error-handling for the CLI. - :return: The return code from `.run()`. + :return: The return code from `run()`. """ try: cmd = cls(args) diff --git a/python/qemu/utils/accel.py b/python/qemu/utils/accel.py index 297933d..386ff64 100644 --- a/python/qemu/utils/accel.py +++ b/python/qemu/utils/accel.py @@ -36,7 +36,7 @@ def list_accel(qemu_bin: str) -> List[str]: List accelerators enabled in the QEMU binary. @param qemu_bin (str): path to the QEMU binary. - @raise Exception: if failed to run `qemu -accel help` + @raise Exception: if failed to run ``qemu -accel help`` @return a list of accelerator names. """ if not qemu_bin: -- cgit v1.1