]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qapi/schema: add type narrowing to lookup_type()
authorJohn Snow <jsnow@redhat.com>
Fri, 15 Mar 2024 15:22:46 +0000 (16:22 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 24 Apr 2024 08:03:54 +0000 (10:03 +0200)
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>

scripts/qapi/schema.py

index e44802369dd892091fb9235133dba05adec81cec..103482541519510a2705744f636fa4c9435194d6 100644 (file)
@@ -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)