Hi, this series adds static types to the QAPI module.
This is part three, and it focuses on expr.py.
Environment:
- Python >= 3.6, <= 3.8 *
- mypy >= 0.770
- pylint >= 2.6.0
- flake8
- isort
Every commit should pass with (from ./scripts/):
- flake8 qapi/
- pylint --rcfile=qapi/pylintrc qapi/
- mypy --config-file=qapi/mypy.ini qapi/
- pushd qapi && isort -c . && popd
V5:
001/17:[----] [--] 'qapi/expr: Comment cleanup'
002/19: -DROPPED- 'flake8: Enforce shorter line length for comments and docstrings'
002/17:[----] [--] 'qapi/expr.py: Remove 'info' argument from nested check_if_str'
003/17:[----] [--] 'qapi/expr.py: Check for dict instead of OrderedDict'
004/17:[0006] [FC] 'qapi/expr.py: constrain incoming expression types'
005/17:[----] [--] 'qapi/expr.py: Add assertion for union type 'check_dict''
006/17:[----] [--] 'qapi/expr.py: move string check upwards in check_type'
007/17:[down] 'qapi/expr.py: Check type of union and alternate 'data' member'
008/19: -MERGED- ^ 'qapi: add tests for invalid 'data' field type'
009/19: -MERGED- ^ 'qapi/expr.py: Check type of 'data' member'
008/17:[0004] [FC] 'qapi/expr.py: Add casts in a few select cases'
009/17:[----] [--] 'qapi/expr.py: Modify check_keys to accept any Collection'
010/17:[----] [-C] 'qapi/expr.py: add type hint annotations'
011/17:[0013] [FC] 'qapi/expr.py: Consolidate check_if_str calls in check_if'
012/17:[----] [--] 'qapi/expr.py: Remove single-letter variable'
013/17:[----] [--] 'qapi/expr.py: enable pylint checks'
014/17:[down] 'qapi/expr: Only explicitly prohibit 'Kind' nor 'List' for type names'
015/17:[0227] [FC] 'qapi/expr.py: Add docstrings'
016/17:[----] [-C] 'qapi/expr.py: Use tuples instead of lists for static data'
017/17:[down] 'qapi/expr: Update authorship and copyright information'
018/19: -DROPPED- 'qapi/expr.py: move related checks inside check_xxx functions'
019/19: -DROPPED- 'qapi/expr.py: Use an expression checker dispatch table'
- Dropped what was 02, 18, 19.
- Merged what was 08, 09 into what is now 07.
- 04: Expanded comment for _JSONObject type alias.
- 07: "New", combines the fix and the test patches from the previous series into
one patch.
- 08: Fixed spelling of "Checked" from "Asserted"
- 11: Reverted back to Python2 style string interpolation
- 14: New, fix the code to reflect the docs for Kind/List reservations.
- 15: Many, many docstring changes. (Too many to list!)
- 17: New, update copyright/authorship. (Could be folded into 15 if desired,
as that's what I'm claiming credit for.)
John Snow (17):
qapi/expr: Comment cleanup
qapi/expr.py: Remove 'info' argument from nested check_if_str
qapi/expr.py: Check for dict instead of OrderedDict
qapi/expr.py: constrain incoming expression types
qapi/expr.py: Add assertion for union type 'check_dict'
qapi/expr.py: move string check upwards in check_type
qapi/expr.py: Check type of union and alternate 'data' member
qapi/expr.py: Add casts in a few select cases
qapi/expr.py: Modify check_keys to accept any Collection
qapi/expr.py: add type hint annotations
qapi/expr.py: Consolidate check_if_str calls in check_if
qapi/expr.py: Remove single-letter variable
qapi/expr.py: enable pylint checks
qapi/expr: Only explicitly prohibit 'Kind' nor 'List' for type names
qapi/expr.py: Add docstrings
qapi/expr.py: Use tuples instead of lists for static data
qapi/expr: Update authorship and copyright information
scripts/qapi/expr.py | 444 +++++++++++++++---
scripts/qapi/mypy.ini | 5 -
scripts/qapi/pylintrc | 1 -
tests/qapi-schema/alternate-data-invalid.err | 2 +
tests/qapi-schema/alternate-data-invalid.json | 4 +
tests/qapi-schema/alternate-data-invalid.out | 0
tests/qapi-schema/meson.build | 2 +
tests/qapi-schema/union-invalid-data.err | 2 +
tests/qapi-schema/union-invalid-data.json | 6 +
tests/qapi-schema/union-invalid-data.out | 0
10 files changed, 385 insertions(+), 81 deletions(-)
create mode 100644 tests/qapi-schema/alternate-data-invalid.err
create mode 100644 tests/qapi-schema/alternate-data-invalid.json
create mode 100644 tests/qapi-schema/alternate-data-invalid.out
create mode 100644 tests/qapi-schema/union-invalid-data.err
create mode 100644 tests/qapi-schema/union-invalid-data.json
create mode 100644 tests/qapi-schema/union-invalid-data.out
--
2.30.2