Branch: refs/heads/staging Home: https://github.com/qemu/qemu Commit: 2184bca7b17559107032ba4fd8fc6f65345276ed https://github.com/qemu/qemu/commit/2184bca7b17559107032ba4fd8fc6f65345276ed Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021)
Changed paths: M scripts/qapi/commands.py M scripts/qapi/events.py M scripts/qapi/gen.py M scripts/qapi/types.py M scripts/qapi/visit.py Log Message: ----------- qapi: Replace List[str] with Sequence[str] for ifcond It does happen to be a list (as of now), but we can describe it in more general terms with no loss in accuracy to allow tuples and other constructs. In the future, we can write "ifcond: Sequence[str] = ()" as a default parameter, which we could not do safely with a Mutable type like a List. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-2-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 6b67bcac0f595143f5a5fce4e518b74577bae192 https://github.com/qemu/qemu/commit/6b67bcac0f595143f5a5fce4e518b74577bae192 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: assert schema is not None The introspect visitor is stateful, but expects that it will have a schema to refer to. Add assertions that state this. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-3-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: d70f5130f6779042f43d315a9bf2dd182e4708c7 https://github.com/qemu/qemu/commit/d70f5130f6779042f43d315a9bf2dd182e4708c7 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: use _make_tree for features nodes At present, we open-code this in _make_tree itself; but if the structure of the tree changes, this is brittle. Use an explicit recursive call to _make_tree when appropriate to help keep the interior node typing consistent. A consequence of doing this is that the 'ifcond' key of the features dict will be omitted when ifcond is false-ish, just like it is omitted in top-level calls to _make_tree. This also increases consistency in our handling of this property. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-4-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 84bece7dd4ce7ca5a36bc996452ebc882f59ae54 https://github.com/qemu/qemu/commit/84bece7dd4ce7ca5a36bc996452ebc882f59ae54 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: add _gen_features helper _make_tree might receive a dict (a SchemaInfo object) or some other type (usually, a string) for its obj parameter. Adding features information should arguably be performed by the caller at such a time when we know the type of the object and don't have to re-interrogate it. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-5-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 055569603d150a18e4d976bb58092206f5024814 https://github.com/qemu/qemu/commit/055569603d150a18e4d976bb58092206f5024814 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: guard against ifcond/comment misuse _tree_to_qlit is called recursively on dict values (isolated from their keys); at such a point in generating output it is too late to apply an ifcond. Similarly, comments do not necessarily have a "tidy" place they can be printed in such a circumstance. Forbid this usage by renaming "suppress_first_indent" to "dict_value" to emphasize that indents are suppressed only for the benefit of dict values; then add an assertion assuring we do not pass ifcond/comments in this case. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-6-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> [Comment wrapped to conform to PEP 8] Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 84cf09915fdaba38a5d5f21baff38e94dd98607f https://github.com/qemu/qemu/commit/84cf09915fdaba38a5d5f21baff38e94dd98607f Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: Unify return type of _make_tree() Returning two different types conditionally can be complicated to type. Return one type for consistency. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-7-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 5f50cede4afe71c91b028d6433adb7b8db9a73b8 https://github.com/qemu/qemu/commit/5f50cede4afe71c91b028d6433adb7b8db9a73b8 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: replace 'extra' dict with 'comment' argument This is only used to pass in a dictionary with a comment already set, so skip the runaround and just accept the (optional) comment. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-8-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: d4c5b429fd18d30f2e23aef6e944fe40f2319024 https://github.com/qemu/qemu/commit/d4c5b429fd18d30f2e23aef6e944fe40f2319024 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: Always define all 'extra' dict keys This mimics how a typed object works, where 'if' and 'comment' are always set, regardless of if they have a value set or not. It is safe to do this because of the way that _tree_to_qlit processes these values (using dict.get with a default of None), resulting in no change of output from _tree_to_qlit. There are no other users of this data. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-9-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 9db27346133b5b83699af49d290662d346683259 https://github.com/qemu/qemu/commit/9db27346133b5b83699af49d290662d346683259 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: Introduce preliminary tree typing The types will be used in forthcoming patches to add typing. These types describe the layout and structure of the objects passed to _tree_to_qlit, but lack the power to describe annotations until the next commit. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-10-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 4f7f97a7b3d3321f02f854829f37637d6e144a57 https://github.com/qemu/qemu/commit/4f7f97a7b3d3321f02f854829f37637d6e144a57 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: create a typed 'Annotated' data strutcure Presently, we use a tuple to attach a dict containing annotations (comments and compile-time conditionals) to a tree node. This is undesirable because dicts are difficult to strongly type; promoting it to a real class allows us to name the values and types of the annotations we are expecting. In terms of typing, the Annotated<T> type serves as a generic container where the annotated node's type is preserved, allowing for greater specificity than we'd be able to provide without a generic. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-11-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 2a6c161bbf92a6259cb4b1687a0154492e78b8f5 https://github.com/qemu/qemu/commit/2a6c161bbf92a6259cb4b1687a0154492e78b8f5 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: improve _tree_to_qlit error message Trivial; make the error message just a pinch more explicit in case we trip this by accident in the future. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-12-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: c0e8d9f3c199357d89f362c54e1edced82c3c084 https://github.com/qemu/qemu/commit/c0e8d9f3c199357d89f362c54e1edced82c3c084 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: improve readability of _tree_to_qlit Subjective, but I find getting rid of the comprehensions helps. Also, divide the sections into scalar and non-scalar sections, and remove old-style string formatting. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-13-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: cf5db2142b674ebab8e0799fd07e3884cfb00fc5 https://github.com/qemu/qemu/commit/cf5db2142b674ebab8e0799fd07e3884cfb00fc5 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: remove _gen_variants helper It is easier to give a name to all of the dictly-typed objects we pass around in introspect.py by removing this helper, as it does not return an object that has any knowable type by itself. Inline it into its only caller instead. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-14-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 82b52f6b84585f1ea2a6ceb9fc0f264e3b13ed48 https://github.com/qemu/qemu/commit/82b52f6b84585f1ea2a6ceb9fc0f264e3b13ed48 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py M scripts/qapi/mypy.ini M scripts/qapi/schema.py Log Message: ----------- qapi/introspect.py: add type hint annotations NB: The type aliases (SchemaInfo et al) declare intent for some of the "dictly-typed" objects we pass around in introspect.py. They do not enforce the shape of those objects, and cannot, until Python 3.7 or later. (And even then, it may not be "worth it".) Annotations are also added to the QAPISchemaEntity __init__ method in schema.py to allow mypy to statically prove the type of typ.name, needed to prove the return type of QAPISchemaGenIntrospectVisitor._use_type(). Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-15-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> [Note on QAPISchemaEntity.__init__() squashed into commit message, Comment wrapped to conform to PEP 8] Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: 5444dedfc723d43fd29e8017e38089aac359c3d1 https://github.com/qemu/qemu/commit/5444dedfc723d43fd29e8017e38089aac359c3d1 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: Add docstrings to _gen_tree and _tree_to_qlit Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-16-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> [Doc string improvements squashed in] Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: cf26906c4a1c803e907036a2b45f80dea3a89bbb https://github.com/qemu/qemu/commit/cf26906c4a1c803e907036a2b45f80dea3a89bbb Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: Update copyright and authors list To reflect the work that went into strictly typing introspect.py, punish myself by claiming credit. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-17-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: cea53c31b7b29fcd239b49d738111676700924ea https://github.com/qemu/qemu/commit/cea53c31b7b29fcd239b49d738111676700924ea Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: Type _gen_tree variants as Sequence[str] Optional[List] is clunky; an empty sequence can more elegantly convey "no variants". By downgrading "List" to "Sequence", we can also accept tuples; this is useful for the empty tuple specifically, which we may use as a default parameter because it is immutable. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-18-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> [Doc string touched up] Reviewed-by: Markus Armbruster <arm...@redhat.com> Commit: 9b77d946990e7497469bb98171b90b4f3ab186a9 https://github.com/qemu/qemu/commit/9b77d946990e7497469bb98171b90b4f3ab186a9 Author: John Snow <js...@redhat.com> Date: 2021-02-18 (Thu, 18 Feb 2021) Changed paths: M scripts/qapi/introspect.py Log Message: ----------- qapi/introspect.py: set _gen_tree's default ifcond argument to () We don't need to create an empty, mutable list to pass to _gen_tree; since it is now typed as a Sequence, we can use the empty tuple as a default and omit the argument. Signed-off-by: John Snow <js...@redhat.com> Message-Id: <20210216021809.134886-19-js...@redhat.com> Reviewed-by: Markus Armbruster <arm...@redhat.com> Signed-off-by: Markus Armbruster <arm...@redhat.com> Commit: e90ef02389dc8b57eaea22b290244609d720a8bf https://github.com/qemu/qemu/commit/e90ef02389dc8b57eaea22b290244609d720a8bf Author: Peter Maydell <peter.mayd...@linaro.org> Date: 2021-02-19 (Fri, 19 Feb 2021) Changed paths: M scripts/qapi/commands.py M scripts/qapi/events.py M scripts/qapi/gen.py M scripts/qapi/introspect.py M scripts/qapi/mypy.ini M scripts/qapi/schema.py M scripts/qapi/types.py M scripts/qapi/visit.py Log Message: ----------- Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-02-18' into staging QAPI patches patches for 2021-02-18 # gpg: Signature made Thu 18 Feb 2021 18:51:35 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "arm...@redhat.com" # gpg: Good signature from "Markus Armbruster <arm...@redhat.com>" [full] # gpg: aka "Markus Armbruster <arm...@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2021-02-18: qapi/introspect.py: set _gen_tree's default ifcond argument to () qapi/introspect.py: Type _gen_tree variants as Sequence[str] qapi/introspect.py: Update copyright and authors list qapi/introspect.py: Add docstrings to _gen_tree and _tree_to_qlit qapi/introspect.py: add type hint annotations qapi/introspect.py: remove _gen_variants helper qapi/introspect.py: improve readability of _tree_to_qlit qapi/introspect.py: improve _tree_to_qlit error message qapi/introspect.py: create a typed 'Annotated' data strutcure qapi/introspect.py: Introduce preliminary tree typing qapi/introspect.py: Always define all 'extra' dict keys qapi/introspect.py: replace 'extra' dict with 'comment' argument qapi/introspect.py: Unify return type of _make_tree() qapi/introspect.py: guard against ifcond/comment misuse qapi/introspect.py: add _gen_features helper qapi/introspect.py: use _make_tree for features nodes qapi/introspect.py: assert schema is not None qapi: Replace List[str] with Sequence[str] for ifcond Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> Compare: https://github.com/qemu/qemu/compare/ce42fe17ad2d...e90ef02389dc