[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistenc
From: |
Eric Blake |
Subject: |
Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap |
Date: |
Mon, 15 Feb 2021 14:26:58 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 |
On 2/15/21 1:00 PM, John Snow wrote:
> On 2/15/21 1:25 PM, Eric Blake wrote:
>> -BlockBitmapMapping = List[Dict[str, Union[str, List[Dict[str, str]]]]]
>> +BlockBitmapMapping = List[Dict[str,
>> + Union[str,
>> + List[Dict[str,
>> + Union[str, Dict[str,
>> bool]]]]]]]
>
> That looks *very* beefy.
>
> Is the Union because that union is valid for every key, or because every
> key has a potentially different value that is specific to that key?
>
> if it's the latter, I'd ditch the Union and just go with:
>
> Dict[str, object], or
> Dict[str, Any]
>
> object: will allow any type, but keeps strict checking enabled. If you
> try to use that value later on without a cast, mypy will warn you if you
> are using it in a manner not guaranteed by the "object" type. Can be
> useful if you are passing values to a function that already does RTTI to
> determine behavior.
We're in luck; both 297 and 300 still pass with this applied on top of
my previous attempt:
diff --git i/tests/qemu-iotests/300 w/tests/qemu-iotests/300
index 7501bd1018e2..adb927629747 100755
--- i/tests/qemu-iotests/300
+++ w/tests/qemu-iotests/300
@@ -22,7 +22,7 @@
import os
import random
import re
-from typing import Dict, List, Optional, Union
+from typing import Dict, List, Optional
import iotests
@@ -30,10 +30,7 @@ import iotests
# pylint: disable=wrong-import-order
import qemu
-BlockBitmapMapping = List[Dict[str,
- Union[str,
- List[Dict[str,
- Union[str, Dict[str,
bool]]]]]]]
+BlockBitmapMapping = List[Dict[str, object]]
mig_sock = os.path.join(iotests.sock_dir, 'mig_sock')
>
> Any: Also allows any type, but enables gradual typing. If you later
> "assume" the type of this value, mypy will say nothing. Can be useful
> when you've just got a job to do and the right tool would have been a
> recursive type or a TypedDict (unavailable in Python 3.6.)
I'm not too worried about needing to further enhance the type-checking
on an individual iotest.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
- [PULL 0/5] bitmaps patches through 2021-02-12, Eric Blake, 2021/02/12
- [PULL 1/5] migration: dirty-bitmap: Use struct for alias map inner members, Eric Blake, 2021/02/12
- [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Eric Blake, 2021/02/12
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Kevin Wolf, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Eric Blake, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Kevin Wolf, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, Eric Blake, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, John Snow, 2021/02/15
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap,
Eric Blake <=
- Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap, John Snow, 2021/02/15
[PULL 4/5] block: return status from bdrv_append and friends, Eric Blake, 2021/02/12
[PULL 5/5] block: use return status of bdrv_append(), Eric Blake, 2021/02/12
[PULL 2/5] migration: dirty-bitmap: Allow control of bitmap persistence, Eric Blake, 2021/02/12
Re: [PULL 0/5] bitmaps patches through 2021-02-12, Peter Maydell, 2021/02/14