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
--
2.30.2