From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Cc: Michael Roth <michael.roth@amd.com>, John Snow <jsnow@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Cleber Rosa <crosa@redhat.com>
Subject: [PATCH v6 00/19] qapi: static typing conversion, pt2
Date: Mon, 15 Feb 2021 21:17:50 -0500 [thread overview]
Message-ID: <20210216021809.134886-1-jsnow@redhat.com> (raw)
Hi, this series adds static type hints to the QAPI module.
This is part two, and covers introspect.py.
Part 2: https://gitlab.com/jsnow/qemu/-/tree/python-qapi-cleanup-pt2
Everything: https://gitlab.com/jsnow/qemu/-/tree/python-qapi-cleanup-pt6
- Requires Python 3.6+
- Requires mypy 0.770 or newer (for type analysis only)
- Requires pylint 2.6.0 or newer (for lint checking only)
(Note: pylint does not like Python 3.9 very much yet. Known problem.)
Type hints are added in patches that add *only* type hints and change no
other behavior. Any necessary changes to behavior to accommodate typing
are split out into their own tiny patches.
Every commit should pass with (from ./scripts):
- flake8 qapi/
- pylint --rcfile=qapi/pylintrc qapi/
- mypy --config-file=qapi/mypy.ini qapi/
- isort -c qapi/
V6:
001/19:[down] 'qapi: Replace List[str] with Sequence[str] for ifcond'
009/19:[0021] [FC] 'qapi/introspect.py: Introduce preliminary tree typing'
010/19:[0013] [FC] 'qapi/introspect.py: create a typed 'Annotated' data strutcure'
013/19:[down] 'qapi/introspect.py: remove _gen_variants helper'
014/19:[0053] [FC] 'qapi/introspect.py: add type hint annotations'
015/19:[down] 'qapi/introspect.py: Add docstrings to _gen_tree and _tree_to_qlit'
017/19:[down] 'qapi/introspect.py: Type _gen_tree variants as Sequence[str]'
018/19:[down] 'qapi/introspect.py: set _gen_tree's default ifcond argument to ()'
019/19:[down] 'qapi/introspect.py: add SchemaMetaType enum'
01: New; consistently type ifcond as Seq[str] in already-typed files.
09: Adjust comment concerning _stub to be more clear (?)
Rename _stub to _Stub, etc.
TreeValue becomes JSONValue.
10: _NodeT becomes _ValueT to match the _Value name.
Change visit_alternate_type whitespace around some more.
13: New, pre-requisite for using SchemaInfo aliases.
(Was not appropriate to go into #14.)
14: Use Sequence[str] instead of List[str] for ifcond
Use SchemaInfo "dummy types" instead of _DObject
15: Adjust comment to mention dict_value limitation.
Add docstring for _gen_tree (from former "dummy types" patch).
Change name of commit to reflect now-multiple docstring additions.
OPTIONAL PATCHES:
17: Use Sequence[QAPISchemaFeature] instead of Optional[List[QAPISchemaFeature]]
18: Set a default argument for ifcond to the empty tuple ().
Stylistically matches the above patch.
19: Create a SchemaMetaType enum and use it instead of the string type.
(Contains an optional blurb that can be removed if desired.)
V5:
04: Rename 'suppress_first_indent' to 'dict_value'
(Docstring added in 014.)
06: Avoid changing the output structure of _make_tree
07: Chance the structure of _make_tree 8-)
08: Change commented TreeValue to include a TODO instead.
09: Change NodeT bound to _value instead of TreeValue
Change "Remove in 3.7" text to include "TODO: "
Remove forwarding suppress_first_indent/dict_value in recursive cases
Change spacing in visit_alternate_type()
11: Consequence of suppress_first_value/dict_value change
12: Commit message note added
Changed _DObject comment
13: Commit notes adjusted
_DObject stuff: Comment near SchemaInfo et al adjusted
14: Changed docstring to reflect dict_value change
15: Updated copyright year for 2021 :~)
V4:
- Rebased on "pt1.5" v4
- signatures updated to use Optional[QAPISourceInfo]
John Snow (19):
qapi: Replace List[str] with Sequence[str] for ifcond
qapi/introspect.py: assert schema is not None
qapi/introspect.py: use _make_tree for features nodes
qapi/introspect.py: add _gen_features helper
qapi/introspect.py: guard against ifcond/comment misuse
qapi/introspect.py: Unify return type of _make_tree()
qapi/introspect.py: replace 'extra' dict with 'comment' argument
qapi/introspect.py: Always define all 'extra' dict keys
qapi/introspect.py: Introduce preliminary tree typing
qapi/introspect.py: create a typed 'Annotated' data strutcure
qapi/introspect.py: improve _tree_to_qlit error message
qapi/introspect.py: improve readability of _tree_to_qlit
qapi/introspect.py: remove _gen_variants helper
qapi/introspect.py: add type hint annotations
qapi/introspect.py: Add docstrings to _gen_tree and _tree_to_qlit
qapi/introspect.py: Update copyright and authors list
qapi/introspect.py: Type _gen_tree variants as Sequence[str]
qapi/introspect.py: set _gen_tree's default ifcond argument to ()
qapi/introspect.py: add SchemaMetaType enum
scripts/qapi/commands.py | 3 +-
scripts/qapi/events.py | 4 +-
scripts/qapi/gen.py | 12 +-
scripts/qapi/introspect.py | 350 +++++++++++++++++++++++++++----------
scripts/qapi/mypy.ini | 5 -
scripts/qapi/schema.py | 2 +-
scripts/qapi/types.py | 12 +-
scripts/qapi/visit.py | 10 +-
8 files changed, 275 insertions(+), 123 deletions(-)
--
2.29.2
next reply other threads:[~2021-02-16 2:29 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-16 2:17 John Snow [this message]
2021-02-16 2:17 ` [PATCH v6 01/19] qapi: Replace List[str] with Sequence[str] for ifcond John Snow
2021-02-16 8:43 ` Markus Armbruster
2021-02-16 15:19 ` John Snow
2021-02-16 15:58 ` Markus Armbruster
2021-02-16 2:17 ` [PATCH v6 02/19] qapi/introspect.py: assert schema is not None John Snow
2021-02-16 2:17 ` [PATCH v6 03/19] qapi/introspect.py: use _make_tree for features nodes John Snow
2021-02-16 2:17 ` [PATCH v6 04/19] qapi/introspect.py: add _gen_features helper John Snow
2021-02-16 2:17 ` [PATCH v6 05/19] qapi/introspect.py: guard against ifcond/comment misuse John Snow
2021-02-17 12:01 ` Markus Armbruster
2021-02-16 2:17 ` [PATCH v6 06/19] qapi/introspect.py: Unify return type of _make_tree() John Snow
2021-02-16 2:17 ` [PATCH v6 07/19] qapi/introspect.py: replace 'extra' dict with 'comment' argument John Snow
2021-02-16 2:17 ` [PATCH v6 08/19] qapi/introspect.py: Always define all 'extra' dict keys John Snow
2021-02-16 2:17 ` [PATCH v6 09/19] qapi/introspect.py: Introduce preliminary tree typing John Snow
2021-02-16 2:18 ` [PATCH v6 10/19] qapi/introspect.py: create a typed 'Annotated' data strutcure John Snow
2021-02-16 2:18 ` [PATCH v6 11/19] qapi/introspect.py: improve _tree_to_qlit error message John Snow
2021-02-16 2:18 ` [PATCH v6 12/19] qapi/introspect.py: improve readability of _tree_to_qlit John Snow
2021-02-16 2:18 ` [PATCH v6 13/19] qapi/introspect.py: remove _gen_variants helper John Snow
2021-02-16 2:18 ` [PATCH v6 14/19] qapi/introspect.py: add type hint annotations John Snow
2021-02-16 8:55 ` Markus Armbruster
2021-02-16 8:58 ` Markus Armbruster
2021-02-16 15:33 ` John Snow
2021-02-16 16:08 ` Markus Armbruster
2021-02-16 16:19 ` John Snow
2021-02-17 9:21 ` Markus Armbruster
2021-02-18 18:56 ` Markus Armbruster
2021-02-18 19:01 ` Markus Armbruster
2021-02-16 2:18 ` [PATCH v6 15/19] qapi/introspect.py: Add docstrings to _gen_tree and _tree_to_qlit John Snow
2021-02-17 9:39 ` Markus Armbruster
2021-02-17 16:07 ` John Snow
2021-02-17 16:35 ` Markus Armbruster
2021-02-17 16:55 ` John Snow
2021-02-18 7:53 ` Markus Armbruster
2021-02-16 2:18 ` [PATCH v6 16/19] qapi/introspect.py: Update copyright and authors list John Snow
2021-02-16 2:18 ` [PATCH v6 17/19] qapi/introspect.py: Type _gen_tree variants as Sequence[str] John Snow
2021-02-16 9:10 ` Markus Armbruster
2021-02-16 15:13 ` John Snow
2021-02-16 2:18 ` [PATCH v6 18/19] qapi/introspect.py: set _gen_tree's default ifcond argument to () John Snow
2021-02-16 2:18 ` [PATCH v6 19/19] qapi/introspect.py: add SchemaMetaType enum John Snow
2021-02-16 9:24 ` Markus Armbruster
2021-02-16 15:08 ` John Snow
2021-02-16 16:09 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210216021809.134886-1-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=michael.roth@amd.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).