Skip to content

qapi: static typing conversion, pt5a

John Snow qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest15 patches 3 repliesIn review
  2. v221 patches 15 repliesSuperseded
  3. v122 patches 44 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15qapi/parser: Don't try to handle file errorsscripts/qapi/parser.py scripts/qapi/schema.py scripts/qapi/source.py +1 more+18 -170 replies
2/15qapi: Add test for nonexistent schema filetests/qapi-schema/meson.build tests/qapi-schema/missing-schema.err tests/qapi-schema/missing-schema.out+7 -10 replies
3/15qapi/source: Remove line number from QAPISourceInfo initializerscripts/qapi/parser.py scripts/qapi/source.py+4 -80 replies
4/15qapi/parser: factor parsing routine into methodscripts/qapi/parser.py+28 -120 replies
5/15qapi/parser: Assert lexer value is a stringscripts/qapi/parser.py+1 -00 replies
6/15qapi/parser: enforce all top-level expressions must be dict in _parse()scripts/qapi/parser.py tests/qapi-schema/non-objects.err tests/qapi-schema/quoted-structural-chars.err+10 -80 replies
7/15qapi/parser: assert object keys are stringsscripts/qapi/parser.py+2 -00 replies
8/15qapi/parser: Use @staticmethod where appropriatescripts/qapi/parser.py+4 -20 replies
9/15qapi: add must_match helperscripts/qapi/common.py scripts/qapi/main.py scripts/qapi/parser.py+16 -110 replies
10/15qapi/parser: Fix token membership tests when token can be Nonescripts/qapi/parser.py tests/qapi-schema/meson.build tests/qapi-schema/missing-array-rsqb.err +5 more+9 -20 replies
11/15qapi/parser: Rework _check_pragma_list_of_str as a TypeGuardscripts/qapi/parser.py+16 -140 replies
12/15qapi/parser: add type hint annotationsscripts/qapi/parser.py+38 -200 replies
13/15qapi/parser: Remove superfluous list comprehensionscripts/qapi/parser.py+1 -10 replies
14/15qapi/parser: allow 'ch' variable namescripts/qapi/pylintrc+1 -02 replies
15/15qapi/parser: add docstringsscripts/qapi/parser.py+69 -00 replies

Reviews trailers per patch

None of the 15 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMarkus Armbruster
SeriesR-b
1/15
2/15
3/15
4/15
5/15
6/15
7/15
8/15
9/15
10/15
11/15
12/15
13/15
14/15
15/15

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/15] qapi: static typing conversion, pt5a

This is part five (a), and focuses on QAPISchemaParser in parser.py. It does not touch QAPIDoc yet, which will be covered next.

gitlab: https://gitlab.com/jsnow/qemu/-/commits/python-qapi-cleanup-pt5a

Requirements:
- Python 3.6+
- mypy >= 0.770
- pylint >= 2.6.0 (2.7.0+ when using Python 3.9+)

Every commit should pass with:
- isort -c qapi/
- flake8 qapi/
- pylint --rcfile=qapi/pylintrc qapi/
- mypy --config-file=qapi/mypy.ini qapi/

V3:

001: Commit message changed
004: Commit message changed
005/15:[0002] [FC] 'qapi/parser: Assert lexer value is a string'
- Remove comment
015/15:[0019] [FC] 'qapi/parser: add docstrings'
- Futz with docstrings based on review from armbru

V2:

001/21:[0024] [FC] 'qapi/parser: Don't try to handle file errors' 002/21:[down] 'qapi: Add test for nonexistent schema file'
003/21:[0008] [FC] 'qapi/source: Remove line number from QAPISourceInfo initializer' 004/21:[0003] [FC] 'qapi/parser: factor parsing routine into method' 005/21:[0002] [FC] 'qapi/parser: Assert lexer value is a string' 006/21:[down] 'qapi/parser: enforce all top-level expressions must be dict in _parse()' 007/21:[----] [--] 'qapi/parser: assert object keys are strings' 008/21:[----] [--] 'qapi/parser: Use @staticmethod where appropriate' 009/21:[down] 'qapi: add must_match helper'
010/21:[down] 'qapi/parser: Fix token membership tests when token can be None' 011/21:[0012] [FC] 'qapi/parser: Rework _check_pragma_list_of_str as a TypeGuard' 012/21:[0019] [FC] 'qapi/parser: add type hint annotations'
013/21:[down] 'qapi/parser: Remove superfluous list comprehension' 014/21:[----] [--] 'qapi/parser: allow 'ch' variable name'
015/21:[0080] [FC] 'qapi/parser: add docstrings'

01:
- Futzed with the commit message a lot.
- Added new try/except to QAPISchema() instead of main().
- Adjusted "let caller handle this error" comment
- Adjusted test-qapi not to crash.
02:
- New, add test for nonexistant root schema file.
03:
- Commit message changes.
- Rebase changes, removed _column RFC patch that preceded it.
04:
- Commit message changes.
- Minor rebase changes (from changed comment in 01)
05:
- Remove assert message, replace w/ comment
06:
- Replaces 'qapi/parser: assert get_expr returns object in outer loop'
09:
- Renamed match_nofail() to must_match()
10:
- Use tuple() for token membership tests
- Add test cases to prevent regressions
11:
- _check => _check_list_str
- info.pragma => pragma
12:
- Remove 'Expression' type entirely for now
- Highlight self.tok as actively taking None type with Union[str, None]
- Minor rebase confetti.
13:
- Renamed commit message.
15:
- Reworked.
- Note that 'pos' is indeed interface as it is used by the error handlers.

John Snow (15):
qapi/parser: Don't try to handle file errors
qapi: Add test for nonexistent schema file qapi/source: Remove line number from QAPISourceInfo initializer qapi/parser: factor parsing routine into method qapi/parser: Assert lexer value is a string qapi/parser: enforce all top-level expressions must be dict in

    _parse()

qapi/parser: assert object keys are strings qapi/parser: Use @staticmethod where appropriate
qapi: add must_match helper
qapi/parser: Fix token membership tests when token can be None qapi/parser: Rework _check_pragma_list_of_str as a TypeGuard qapi/parser: add type hint annotations
qapi/parser: Remove superfluous list comprehension qapi/parser: allow 'ch' variable name
qapi/parser: add docstrings

 scripts/qapi/common.py                        |   8 +-
 scripts/qapi/main.py                          |   6 +-
 scripts/qapi/parser.py                        | 230 +++++++++++++-----
 scripts/qapi/pylintrc                         |   1 +
 scripts/qapi/schema.py                        |  11 +-
 scripts/qapi/source.py                        |  13 +-
 tests/qapi-schema/meson.build                 |   9 +-
 tests/qapi-schema/missing-array-rsqb.err      |   1 +
 tests/qapi-schema/missing-array-rsqb.json     |   1 +
 tests/qapi-schema/missing-array-rsqb.out      |   0
 .../missing-object-member-element.err         |   1 +
 .../missing-object-member-element.json        |   1 +
 .../missing-object-member-element.out         |   0
 tests/qapi-schema/missing-schema.err          |   1 +
 tests/qapi-schema/missing-schema.out          |   0
 tests/qapi-schema/non-objects.err             |   2 +-
 tests/qapi-schema/quoted-structural-chars.err |   2 +-
 tests/qapi-schema/test-qapi.py                |   3 -
 18 files changed, 209 insertions(+), 81 deletions(-)
 create mode 100644 tests/qapi-schema/missing-array-rsqb.err
 create mode 100644 tests/qapi-schema/missing-array-rsqb.json
 create mode 100644 tests/qapi-schema/missing-array-rsqb.out
 create mode 100644 tests/qapi-schema/missing-object-member-element.err
 create mode 100644 tests/qapi-schema/missing-object-member-element.json
 create mode 100644 tests/qapi-schema/missing-object-member-element.out
 create mode 100644 tests/qapi-schema/missing-schema.err
 create mode 100644 tests/qapi-schema/missing-schema.out
Signature · 1 line
2.30.2