qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 11/19] qapi/expr.py: Modify check_keys to accept any Colle


From: John Snow
Subject: Re: [PATCH v4 11/19] qapi/expr.py: Modify check_keys to accept any Collection
Date: Thu, 25 Mar 2021 19:37:21 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 3/25/21 10:45 AM, Markus Armbruster wrote:
John Snow <jsnow@redhat.com> writes:

This is a minor adjustment that allows the 'required' and 'optional'
keys fields to take a default value of an empty, immutable sequence (the
empty tuple).

This reveals a quirk of this function, which is that "a + b" is
list-specific behavior. We can accept a wider variety of types if we
avoid that behavior. Using Collection allows us to accept things like
lists, tuples, sets, and so on.

(Iterable would also have worked, but Iterable also includes things like
generator expressions which are consumed upon iteration, which would
require a rewrite to make sure that each input was only traversed once.)

Signed-off-by: John Snow <jsnow@redhat.com>

The commit message confused me briefly, until I realized v3 of this
patch came later in the series, where it modified check_keys() type
hints and added default values.

What about this:

   This is a minor adjustment that lets parameters @required and
   @optional take tuple arguments, in particular ().  Later patches will
   make use of that.


OK




reply via email to

[Prev in Thread] Current Thread [Next in Thread]