qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	ehabkost@redhat.com, qemu-block@nongnu.org, philmd@redhat.com,
	Max Reitz <mreitz@redhat.com>, John Snow <jsnow@redhat.com>
Subject: [PATCH RFC WIP 1/6] iotests: type hint wip
Date: Wed, 13 May 2020 17:41:25 -0400	[thread overview]
Message-ID: <20200513214130.15375-2-jsnow@redhat.com> (raw)
In-Reply-To: <20200513214130.15375-1-jsnow@redhat.com>

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/qemu-iotests/iotests.py | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 6c0e781af7..27c477c8a7 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -90,7 +90,7 @@
 luks_default_key_secret_opt = 'key-secret=keysec0'
 
 
-def qemu_img(*args):
+def qemu_img(*args) -> int:
     '''Run qemu-img and return the exit code'''
     devnull = open('/dev/null', 'r+')
     exitcode = subprocess.call(qemu_img_args + list(args),
@@ -113,24 +113,24 @@ def ordered_qmp(qmsg, conv_keys=True):
         return od
     return qmsg
 
-def qemu_img_create(*args):
-    args = list(args)
+def qemu_img_create(*args: str) -> int:
+    qargs = list(args)
 
     # default luks support
-    if '-f' in args and args[args.index('-f') + 1] == 'luks':
-        if '-o' in args:
-            i = args.index('-o')
-            if 'key-secret' not in args[i + 1]:
-                args[i + 1].append(luks_default_key_secret_opt)
-                args.insert(i + 2, '--object')
-                args.insert(i + 3, luks_default_secret_object)
+    if '-f' in qargs and qargs[qargs.index('-f') + 1] == 'luks':
+        if '-o' in qargs:
+            i = qargs.index('-o')
+            if 'key-secret' not in qargs[i + 1]:
+                qargs[i + 1].append(luks_default_key_secret_opt)
+                qargs.insert(i + 2, '--object')
+                qargs.insert(i + 3, luks_default_secret_object)
         else:
-            args = ['-o', luks_default_key_secret_opt,
-                    '--object', luks_default_secret_object] + args
+            qargs = ['-o', luks_default_key_secret_opt,
+                     '--object', luks_default_secret_object] + qargs
 
-    args.insert(0, 'create')
+    qargs.insert(0, 'create')
 
-    return qemu_img(*args)
+    return qemu_img(*qargs)
 
 def qemu_img_verbose(*args):
     '''Run qemu-img without suppressing its output and return the exit code'''
-- 
2.21.1



  reply	other threads:[~2020-05-13 21:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 21:41 [PATCH RFC WIP 0/6] iotests: delinting work-in-progress John Snow
2020-05-13 21:41 ` John Snow [this message]
2020-05-13 21:41 ` [PATCH RFC WIP 2/6] Makefile: add delint WIP John Snow
2020-05-13 21:41 ` [PATCH RFC WIP 3/6] nbd-fault-injector: delint John Snow
2020-05-13 21:41 ` [PATCH RFC WIP 4/6] qed.py: delint John Snow
2020-05-13 21:41 ` [PATCH RFC WIP 5/6] qcow2.py: delint John Snow
2020-05-13 21:41 ` [PATCH RFC WIP 6/6] WIP: delint test files John Snow
2020-05-14  3:15 ` [PATCH RFC WIP 0/6] iotests: delinting work-in-progress no-reply

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=20200513214130.15375-2-jsnow@redhat.com \
    --to=jsnow@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@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).