From 10755a9536eaf134f86df1d32a47ee8b07c2f1b9 Mon Sep 17 00:00:00 2001 From: John Snow Date: Fri, 15 Mar 2024 16:22:46 +0100 Subject: 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 Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster Message-ID: <20240315152301.3621858-11-armbru@redhat.com> --- scripts/qapi/schema.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') 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) -- cgit v1.1