aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2024-03-15 16:22:46 +0100
committerMarkus Armbruster <armbru@redhat.com>2024-04-24 10:03:54 +0200
commit10755a9536eaf134f86df1d32a47ee8b07c2f1b9 (patch)
treebe0e695e4bc715c96fb408f9acb69f52576e88c3 /scripts
parent9bda6c7d1108c13be67e615b50f5d1b61fa3177e (diff)
downloadqemu-10755a9536eaf134f86df1d32a47ee8b07c2f1b9.zip
qemu-10755a9536eaf134f86df1d32a47ee8b07c2f1b9.tar.gz
qemu-10755a9536eaf134f86df1d32a47ee8b07c2f1b9.tar.bz2
qapi/schema: add type narrowing to lookup_type()
This function is a bit hard to type as-is; mypy needs some assertions to assist with the type narrowing. 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-11-armbru@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi/schema.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index e448023..1034825 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -989,7 +989,9 @@ class QAPISchema:
return ent
def lookup_type(self, name):
- return self.lookup_entity(name, QAPISchemaType)
+ typ = self.lookup_entity(name, QAPISchemaType)
+ assert typ is None or isinstance(typ, QAPISchemaType)
+ return typ
def resolve_type(self, name, info, what):
typ = self.lookup_type(name)