John Snow <js...@redhat.com> writes: > On 2/16/21 11:08 AM, Markus Armbruster wrote: >> John Snow <js...@redhat.com> writes: >> >>> On 2/16/21 3:55 AM, Markus Armbruster wrote: >>>> John Snow <js...@redhat.com> writes: [...] >>>>> diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py >>>>> index 353e8020a27..ff16578f6de 100644 >>>>> --- a/scripts/qapi/schema.py >>>>> +++ b/scripts/qapi/schema.py >>>>> @@ -28,7 +28,7 @@ >>>>> class QAPISchemaEntity: >>>>> meta: Optional[str] = None >>>>> - def __init__(self, name, info, doc, ifcond=None, >>>>> features=None): >>>>> + def __init__(self, name: str, info, doc, ifcond=None, features=None): >>>>> assert name is None or isinstance(name, str) >>>>> for f in features or []: >>>>> assert isinstance(f, QAPISchemaFeature) >>>> >>>> How is this hunk related to typing introspect.py >>>> >>> >>> I forget! >>> >>> qapi/introspect.py:262: error: Returning Any from function declared to >>> return "str" >>> Found 1 error in 1 file (checked 14 source files) >>> >>> Oh, for this reason: >>> >>> if isinstance(typ, QAPISchemaBuiltinType): >>> return typ.name >>> >>> _use_type has a return type that is dependent upon the type of >>> "typ.name", which required typing the QAPISchemaEntity initializer. >>> >>> >>> (Do you want this in its own preceding patch?) >> >> That would work. >> Keeping it in this patch with a suitable hint in the commit message >> would also work. Up to you. If you want me to tweak in my tree, tell >> me how. >> > > We can try: > > "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()."
Sold!