qapi/schema: adjust type narrowing for mypy's benefit
commit9bda6c7d1108c13be67e615b50f5d1b61fa3177e
authorJohn Snow <jsnow@redhat.com>
Fri, 15 Mar 2024 15:22:45 +0000 (15 16:22 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 24 Apr 2024 08:03:54 +0000 (24 10:03 +0200)
tree29ed09325e822958903ff1a54f87ffba3fb90835
parentd150be3d54e4df04948b7205f7ccdde5a84f0684
qapi/schema: adjust type narrowing for mypy's benefit

We already take care to perform some type narrowing for arg_type and
ret_type, but not in a way where mypy can utilize the result once we add
type hints, e.g.:

qapi/schema.py:833: error: Incompatible types in assignment (expression
has type "QAPISchemaType", variable has type
"Optional[QAPISchemaObjectType]") [assignment]

qapi/schema.py:893: error: Incompatible types in assignment (expression
has type "QAPISchemaType", variable has type
"Optional[QAPISchemaObjectType]") [assignment]

A simple change to use a temporary variable helps the medicine go down.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240315152301.3621858-10-armbru@redhat.com>
scripts/qapi/schema.py