[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] iotests: Fix up python style in 300
From: |
Markus Armbruster |
Subject: |
Re: [PATCH] iotests: Fix up python style in 300 |
Date: |
Mon, 01 Mar 2021 08:58:41 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> writes:
> 16.02.2021 02:21, John Snow wrote:
>> On 2/15/21 5:05 PM, Eric Blake wrote:
>>> Break some long lines, and relax our type hints to be more generic to
>>> any JSON, in order to more easily permit the additional JSON depth now
>>> possible in migration parameters. Detected by iotest 297.
>>>
>>> Fixes: ca4bfec41d56
>>> (qemu-iotests: 300: Add test case for modifying persistence of bitmap)
>>> Reported-by: Kevin Wolf <kwolf@redhat.com>
>>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> Reviewed-by: John Snow <jsnow@redhat.com>
>>
>>> ---
>>> tests/qemu-iotests/300 | 10 ++++++----
>>> 1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
>>> index 63036f6a6e13..adb927629747 100755
>>> --- a/tests/qemu-iotests/300
>>> +++ b/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,7 +30,7 @@ import iotests
>>> # pylint: disable=wrong-import-order
>>> import qemu
>>>
>>> -BlockBitmapMapping = List[Dict[str, Union[str, List[Dict[str, str]]]]]
>>> +BlockBitmapMapping = List[Dict[str, object]]
>>>
>> Assuming iotest 297 didn't yap about this, I think this has the
>> necessary power for this file and we don't have to work any harder.
>> If in the future you try to treat e.g. bmap['persistent'] as a
>> particular kind of value (string? bool? int?) mypy will likely
>> complain about that a little, saying it has no insight into the type
>> beyond "object".
>> If *that* becomes annoying, you can degrade this type to use 'Any'
>> instead of 'object' and even those checks will cease.
>
> Probably at some future moment we'll have generated python types for QAPI
> structures ? :)
Generating Python from the QAPI schema is possible. I'm not aware of
anyone planning to work on it near term.
- Re: [PATCH] iotests: Fix up python style in 300,
Markus Armbruster <=