mbox series

[00/14] qapi: static typing conversion, pt3

Message ID 20200922211802.4083666-1-jsnow@redhat.com
Headers show
Series qapi: static typing conversion, pt3 | expand

Message

John Snow Sept. 22, 2020, 9:17 p.m. UTC
based-on: <20200922211313.4082880-1-jsnow@redhat.com>
          [PATCH 00/16] qapi: static typing conversion, pt2

Hi, this series adds static type hints to the QAPI module.
This is part three!

Part 3: https://gitlab.com/jsnow/qemu/-/tree/python-qapi-cleanup-pt3
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)

This part of the series focuses on just doc.py ... which, err, Peter
Maydell is getting rid of soon. Oh well. This is posted for reference;
and simply as context and pre-requisite for later patches.

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:
 - flake8 qapi/
 - pylint --rcfile=qapi/pylintrc qapi/
 - mypy --config-file=qapi/mypy.ini qapi/

John Snow (14):
  qapi/doc.py: stash long temporary locals in named locals
  qapi/doc.py: avoid unnecessary keyword arguments
  qapi/doc.py: Add assertion on section.member
  qapi/doc.py: assert correct types in member_func callbacks
  qapi/doc.py: Assert no suffix given for enum members
  qapi/doc.py: Add type hint annotations
  qapi/doc.py: enable mypy checks
  qapi/doc.py: Add generic texi_member callback
  qapi/doc.py: Remove one-letter variables
  qapi/gen.py: Add __bool__ dunder method to QAPIGen
  qapi/doc.py: Don't use private attributes of QAPIGen property
  qapi/doc.py: Assert tag member is Enum type
  qapi/doc.py: Assert type of object variant
  qapi/doc.py: enable pylint checks

 scripts/qapi/doc.py   | 189 ++++++++++++++++++++++++++++--------------
 scripts/qapi/gen.py   |   3 +
 scripts/qapi/mypy.ini |   5 --
 scripts/qapi/pylintrc |   3 +-
 4 files changed, 133 insertions(+), 67 deletions(-)

-- 
2.26.2

Comments

Eduardo Habkost Sept. 23, 2020, 8:46 p.m. UTC | #1
On Tue, Sep 22, 2020 at 05:17:51PM -0400, John Snow wrote:
> Similarly to other cases, we lack the power at the moment to express
> that a specific member is constrained to a certain containing type. Add
> an assertion before we use properties specific to that type.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Eduardo Habkost Sept. 23, 2020, 8:47 p.m. UTC | #2
On Tue, Sep 22, 2020 at 05:17:53PM -0400, John Snow wrote:
> We don't do anything with this argument. If something shows up here,
> something wrong has happened.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Eduardo Habkost Sept. 23, 2020, 8:47 p.m. UTC | #3
On Tue, Sep 22, 2020 at 05:17:54PM -0400, John Snow wrote:
> Annotations do not change runtime behavior.
> This commit *only* adds annotations.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Eduardo Habkost Sept. 23, 2020, 9:09 p.m. UTC | #4
On Tue, Sep 22, 2020 at 05:18:02PM -0400, John Snow wrote:
> Signed-off-by: John Snow <jsnow@redhat.com>

Tested-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
John Snow Sept. 30, 2020, 4:44 a.m. UTC | #5
On 9/22/20 5:17 PM, John Snow wrote:
> based-on: <20200922211313.4082880-1-jsnow@redhat.com>

>            [PATCH 00/16] qapi: static typing conversion, pt2

> 

> Hi, this series adds static type hints to the QAPI module.

> This is part three!

> 

> Part 3: https://gitlab.com/jsnow/qemu/-/tree/python-qapi-cleanup-pt3

> Everything: https://gitlab.com/jsnow/qemu/-/tree/python-qapi-cleanup-pt6

> 


This entire series is now deprecated, because of Peter Maydell's work 
removing doc.py!

There will not be a replacement. The series now goes from part 1, 2, ... 
4, 5, 6.

--js