From f75b20e4f16663af4c65657821c5727b1d1c2493 Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 10 Jan 2022 14:13:47 -0500 Subject: python/aqmp: use absolute import statement pylint's dependency astroid appears to have bugs in 2.9.1 and 2.9.2 (Dec 31 and Jan 3) that appear to erroneously expect the qemu namespace to have an __init__.py file. astroid 2.9.3 (Jan 9) avoids that problem, but appears to not understand a relative import within a namespace package. Update the relative import - it was worth changing anyway, because these packages will eventually be packaged and distributed separately. Signed-off-by: John Snow Reviewed-by: Beraldo Leal Message-id: 20220110191349.1841027-2-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/aqmp_tui.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'python/qemu') diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py index a2929f7..f1e926d 100644 --- a/python/qemu/aqmp/aqmp_tui.py +++ b/python/qemu/aqmp/aqmp_tui.py @@ -35,7 +35,8 @@ from pygments import token as Token import urwid import urwid_readline -from ..qmp import QEMUMonitorProtocol, QMPBadPortError +from qemu.qmp import QEMUMonitorProtocol, QMPBadPortError + from .error import ProtocolError from .message import DeserializationError, Message, UnexpectedTypeError from .protocol import ConnectError, Runstate -- cgit v1.1 From 42d73f2894ea1855df5a25d58e0d9eac6023dcc3 Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 10 Jan 2022 14:13:48 -0500 Subject: Python/aqmp: fix type definitions for mypy 0.920 0.920 (Released 2021-12-15) is not entirely happy with the way that I was defining _FutureT: qemu/aqmp/protocol.py:601: error: Item "object" of the upper bound "Optional[Future[Any]]" of type variable "_FutureT" has no attribute "done" Update it with something a little mechanically simpler that works better across a wider array of mypy versions. Signed-off-by: John Snow Message-id: 20220110191349.1841027-3-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/aqmp/protocol.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'python/qemu') diff --git a/python/qemu/aqmp/protocol.py b/python/qemu/aqmp/protocol.py index 5190b33..c4fbe35 100644 --- a/python/qemu/aqmp/protocol.py +++ b/python/qemu/aqmp/protocol.py @@ -43,8 +43,8 @@ from .util import ( T = TypeVar('T') +_U = TypeVar('_U') _TaskFN = Callable[[], Awaitable[None]] # aka ``async def func() -> None`` -_FutureT = TypeVar('_FutureT', bound=Optional['asyncio.Future[Any]']) class Runstate(Enum): @@ -591,7 +591,8 @@ class AsyncProtocol(Generic[T]): """ Fully reset this object to a clean state and return to `IDLE`. """ - def _paranoid_task_erase(task: _FutureT) -> Optional[_FutureT]: + def _paranoid_task_erase(task: Optional['asyncio.Future[_U]'] + ) -> Optional['asyncio.Future[_U]']: # Help to erase a task, ENSURING it is fully quiesced first. assert (task is None) or task.done() return None if (task and task.done()) else task -- cgit v1.1 From 366d33158cea72e80d80505f94c34cb505385c0a Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 10 Jan 2022 14:13:49 -0500 Subject: python: update type hints for mypy 0.930 Mypy 0.930, released Dec 22, changes the way argparse objects are considered. Crafting a definition that works under Python 3.6 and an older mypy alongside newer versions simultaneously is ... difficult, so... eh. Stub it out with an 'Any' definition to get the CI moving again. Oh well. Signed-off-by: John Snow Reviewed-by: Beraldo Leal Message-id: 20220110191349.1841027-4-jsnow@redhat.com Signed-off-by: John Snow --- python/qemu/qmp/qom_common.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'python/qemu') diff --git a/python/qemu/qmp/qom_common.py b/python/qemu/qmp/qom_common.py index a59ae1a..2e4c741 100644 --- a/python/qemu/qmp/qom_common.py +++ b/python/qemu/qmp/qom_common.py @@ -30,10 +30,6 @@ from typing import ( from . import QEMUMonitorProtocol, QMPError -# The following is needed only for a type alias. -Subparsers = argparse._SubParsersAction # pylint: disable=protected-access - - class ObjectPropertyInfo: """ Represents the return type from e.g. qom-list. @@ -89,7 +85,7 @@ class QOMCommand: self.qmp.connect() @classmethod - def register(cls, subparsers: Subparsers) -> None: + def register(cls, subparsers: Any) -> None: """ Register this command with the argument parser. -- cgit v1.1