qapi/introspect.py: add type hint annotations
commit82b52f6b84585f1ea2a6ceb9fc0f264e3b13ed48
authorJohn Snow <jsnow@redhat.com>
Tue, 16 Feb 2021 02:18:04 +0000 (15 21:18 -0500)
committerMarkus Armbruster <armbru@redhat.com>
Thu, 18 Feb 2021 18:45:20 +0000 (18 19:45 +0100)
tree04f8ac136cb5df583b5f37b035e4aa77b0418e7c
parentcf5db2142b674ebab8e0799fd07e3884cfb00fc5
qapi/introspect.py: add type hint annotations

NB: The type aliases (SchemaInfo et al) declare intent for some of the
"dictly-typed" objects we pass around in introspect.py. They do not
enforce the shape of those objects, and cannot, until Python 3.7 or
later. (And even then, it may not be "worth it".)

Annotations are also added to the QAPISchemaEntity __init__ method in
schema.py to allow mypy to statically prove the type of typ.name,
needed to prove the return type of
QAPISchemaGenIntrospectVisitor._use_type().

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210216021809.134886-15-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Note on QAPISchemaEntity.__init__() squashed into commit message,
Comment wrapped to conform to PEP 8]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/introspect.py
scripts/qapi/mypy.ini
scripts/qapi/schema.py