From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org
Subject: [PATCH 1/3] iotests.py: Fix type check errors in wait_migration()
Date: Tue, 27 Oct 2020 17:38:04 +0100 [thread overview]
Message-ID: <20201027163806.290960-2-kwolf@redhat.com> (raw)
In-Reply-To: <20201027163806.290960-1-kwolf@redhat.com>
Commit 1847a4a8c20 clarified that event_wait() can return None (though
only with timeout=0) and commit f12a282ff47 annotated it as returning
Optional[QMPMessage].
Type checks in wait_migration() fail because of the unexpected optional
return type:
iotests.py:750: error: Value of type variable "Msg" of "log" cannot be "Optional[Dict[str, Any]]"
iotests.py:751: error: Value of type "Optional[Dict[str, Any]]" is not indexable
iotests.py:754: error: Value of type "Optional[Dict[str, Any]]" is not indexable
Fortunately, the non-zero default timeout is used in the event_wait()
call, so we can make mypy happy by just asserting this.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
tests/qemu-iotests/iotests.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 63d2ace93c..28388a0fbc 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -747,6 +747,10 @@ class VM(qtest.QEMUQtestMachine):
def wait_migration(self, expect_runstate: Optional[str]) -> bool:
while True:
event = self.event_wait('MIGRATION')
+ # We use the default timeout, and with a timeout, event_wait()
+ # never returns None
+ assert event
+
log(event, filters=[filter_qmp_event])
if event['data']['status'] in ('completed', 'failed'):
break
--
2.28.0
next prev parent reply other threads:[~2020-10-27 16:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-27 16:38 [PATCH 0/3] iotests: Fix pylint/mypy warnings on F33 Kevin Wolf
2020-10-27 16:38 ` Kevin Wolf [this message]
2020-10-27 17:31 ` [PATCH 1/3] iotests.py: Fix type check errors in wait_migration() John Snow
2020-10-27 16:38 ` [PATCH 2/3] iotests: Disable unsubscriptable-object in pylint Kevin Wolf
2020-10-27 16:48 ` John Snow
2020-10-27 16:38 ` [PATCH 3/3] iotests: Use Python 3 style super() Kevin Wolf
2020-10-27 16:48 ` John Snow
2020-10-28 9:31 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201027163806.290960-2-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=jsnow@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).