Markus Armbruster <arm...@redhat.com> writes: > John Snow <js...@redhat.com> writes: > >> 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".) >> >> Signed-off-by: John Snow <js...@redhat.com> >> --- >> scripts/qapi/introspect.py | 124 +++++++++++++++++++++++++++---------- >> scripts/qapi/mypy.ini | 5 -- >> scripts/qapi/schema.py | 2 +- >> 3 files changed, 92 insertions(+), 39 deletions(-) >> >> diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py >> index b0fcc4443c1..45284af1330 100644 >> --- a/scripts/qapi/introspect.py >> +++ b/scripts/qapi/introspect.py [...] >> @@ -216,10 +237,13 @@ def _use_type(self, typ): >> return self._name(typ.name) >> >> @staticmethod >> - def _gen_features(features): >> + def _gen_features(features: List[QAPISchemaFeature] >> + ) -> List[Annotated[str]]: >> return [Annotated(f.name, f.ifcond) for f in features] >> >> - def _gen_tree(self, name, mtype, obj, ifcond, features): >> + def _gen_tree(self, name: str, mtype: str, obj: Dict[str, object], > > Schould this be obj: SchemaInfo?
No, because @obj is incomplete; _gen_tree() completes it. > >> + ifcond: Sequence[str], >> + features: Optional[List[QAPISchemaFeature]]) -> None: >> comment: Optional[str] = None >> if mtype not in ('command', 'event', 'builtin', 'array'): >> if not self._unmask: [...]