[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC WIP 1/6] iotests: type hint wip
From: |
John Snow |
Subject: |
[PATCH RFC WIP 1/6] iotests: type hint wip |
Date: |
Wed, 13 May 2020 17:41:25 -0400 |
Signed-off-by: John Snow <address@hidden>
---
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
- [PATCH RFC WIP 0/6] iotests: delinting work-in-progress, John Snow, 2020/05/13
- [PATCH RFC WIP 2/6] Makefile: add delint WIP, John Snow, 2020/05/13
- [PATCH RFC WIP 1/6] iotests: type hint wip,
John Snow <=
- [PATCH RFC WIP 6/6] WIP: delint test files, John Snow, 2020/05/13
- [PATCH RFC WIP 4/6] qed.py: delint, John Snow, 2020/05/13
- [PATCH RFC WIP 3/6] nbd-fault-injector: delint, John Snow, 2020/05/13
- [PATCH RFC WIP 5/6] qcow2.py: delint, John Snow, 2020/05/13
- Re: [PATCH RFC WIP 0/6] iotests: delinting work-in-progress, no-reply, 2020/05/13