qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/21] qapi: static typing conversion, pt5a
@ 2021-05-11 22:05 John Snow
  2021-05-11 22:05 ` [PATCH v2 01/21] qapi/parser: Don't try to handle file errors John Snow
                   ` (20 more replies)
  0 siblings, 21 replies; 37+ messages in thread
From: John Snow @ 2021-05-11 22:05 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael Roth, John Snow, Eduardo Habkost, Markus Armbruster, Cleber Rosa

This is part five, 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/`

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 (21):
  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
  CHECKPOINT
  qapi: [WIP] Rip QAPIDoc out of parser.py
  qapi: [WIP] Add type ignores for qapidoc.py
  qapi: [WIP] Import QAPIDoc from qapidoc Signed-off-by: John Snow
    <jsnow@redhat.com>
  qapi: [WIP] Add QAPIDocError
  qapi: [WIP] Enable linters on parser.py

 scripts/qapi/common.py                        |   8 +-
 scripts/qapi/expr.py                          |   2 +-
 scripts/qapi/main.py                          |   6 +-
 scripts/qapi/mypy.ini                         |   2 +-
 scripts/qapi/parser.py                        | 570 ++++++------------
 scripts/qapi/pylintrc                         |   3 +-
 scripts/qapi/qapidoc.py                       | 360 +++++++++++
 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 -
 21 files changed, 575 insertions(+), 421 deletions(-)
 create mode 100644 scripts/qapi/qapidoc.py
 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




^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2021-05-19 18:23 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 22:05 [PATCH v2 00/21] qapi: static typing conversion, pt5a John Snow
2021-05-11 22:05 ` [PATCH v2 01/21] qapi/parser: Don't try to handle file errors John Snow
2021-05-18  9:28   ` Markus Armbruster
2021-05-18 13:14     ` John Snow
2021-05-19  7:01       ` Markus Armbruster
2021-05-19 17:17         ` John Snow
2021-05-19 17:51         ` John Snow
2021-05-18 19:01     ` John Snow
2021-05-19  6:51       ` Markus Armbruster
2021-05-11 22:05 ` [PATCH v2 02/21] qapi: Add test for nonexistent schema file John Snow
2021-05-11 22:05 ` [PATCH v2 03/21] qapi/source: Remove line number from QAPISourceInfo initializer John Snow
2021-05-11 22:05 ` [PATCH v2 04/21] qapi/parser: factor parsing routine into method John Snow
2021-05-18  9:57   ` Markus Armbruster
2021-05-18 15:11     ` John Snow
2021-05-11 22:05 ` [PATCH v2 05/21] qapi/parser: Assert lexer value is a string John Snow
2021-05-18 10:02   ` Markus Armbruster
2021-05-18 15:19     ` John Snow
2021-05-11 22:05 ` [PATCH v2 06/21] qapi/parser: enforce all top-level expressions must be dict in _parse() John Snow
2021-05-11 22:05 ` [PATCH v2 07/21] qapi/parser: assert object keys are strings John Snow
2021-05-11 22:05 ` [PATCH v2 08/21] qapi/parser: Use @staticmethod where appropriate John Snow
2021-05-11 22:05 ` [PATCH v2 09/21] qapi: add must_match helper John Snow
2021-05-11 22:05 ` [PATCH v2 10/21] qapi/parser: Fix token membership tests when token can be None John Snow
2021-05-11 22:05 ` [PATCH v2 11/21] qapi/parser: Rework _check_pragma_list_of_str as a TypeGuard John Snow
2021-05-11 22:05 ` [PATCH v2 12/21] qapi/parser: add type hint annotations John Snow
2021-05-18 12:01   ` Markus Armbruster
2021-05-18 13:25     ` John Snow
2021-05-11 22:05 ` [PATCH v2 13/21] qapi/parser: Remove superfluous list comprehension John Snow
2021-05-11 22:05 ` [PATCH v2 14/21] qapi/parser: allow 'ch' variable name John Snow
2021-05-11 22:05 ` [PATCH v2 15/21] qapi/parser: add docstrings John Snow
2021-05-19  6:41   ` Markus Armbruster
2021-05-19 18:21     ` John Snow
2021-05-11 22:05 ` [PATCH v2 16/21] CHECKPOINT John Snow
2021-05-11 22:05 ` [PATCH v2 17/21] qapi: [WIP] Rip QAPIDoc out of parser.py John Snow
2021-05-11 22:05 ` [PATCH v2 18/21] qapi: [WIP] Add type ignores for qapidoc.py John Snow
2021-05-11 22:05 ` [PATCH v2 19/21] qapi: [WIP] Import QAPIDoc from qapidoc Signed-off-by: John Snow <jsnow@redhat.com> John Snow
2021-05-11 22:06 ` [PATCH v2 20/21] qapi: [WIP] Add QAPIDocError John Snow
2021-05-11 22:06 ` [PATCH v2 21/21] qapi: [WIP] Enable linters on parser.py John Snow

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).