]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
qapi/expr.py: Modify check_keys to accept any Collection
authorJohn Snow <jsnow@redhat.com>
Wed, 21 Apr 2021 18:20:24 +0000 (14:20 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 30 Apr 2021 10:59:54 +0000 (12:59 +0200)
This is a minor adjustment that lets parameters @required and
@optional take tuple arguments, in particular ().  Later patches will
make use of that.

(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. Collection implies the "can re-iterate" property.)

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210421182032.3521476-10-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/expr.py

index f3a4a8536e8e8e444c4b414573e641d70495068e..396c8126d6a9b7495dfed7bf5860ad00d04174ac 100644 (file)
@@ -102,7 +102,7 @@ def check_keys(value, info, source, required, optional):
             "%s misses key%s %s"
             % (source, 's' if len(missing) > 1 else '',
                pprint(missing)))
-    allowed = set(required + optional)
+    allowed = set(required) | set(optional)
     unknown = set(value) - allowed
     if unknown:
         raise QAPISemError(