[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 08/19] qapi/schema: add type narrowing to lookup_type()
|
From: |
John Snow |
|
Subject: |
[PATCH v2 08/19] qapi/schema: add type narrowing to lookup_type() |
|
Date: |
Fri, 12 Jan 2024 17:29:34 -0500 |
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>
---
scripts/qapi/schema.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 775766c0135..66a78f28fd4 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -997,7 +997,9 @@ def lookup_entity(self, name, typ=None):
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)
--
2.43.0
- Re: [PATCH v2 01/19] qapi: sort pylint suppressions, (continued)
[PATCH v2 02/19] qapi/schema: add pylint suppressions, John Snow, 2024/01/12
[PATCH v2 04/19] qapi/schema: declare type for QAPISchemaObjectTypeMember.type, John Snow, 2024/01/12
[PATCH v2 05/19] qapi/schema: declare type for QAPISchemaArrayType.element_type, John Snow, 2024/01/12
[PATCH v2 08/19] qapi/schema: add type narrowing to lookup_type(),
John Snow <=
[PATCH v2 13/19] qapi/schema: split "checked" field into "checking" and "checked", John Snow, 2024/01/12
[PATCH v2 11/19] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type, John Snow, 2024/01/12
[PATCH v2 14/19] qapi/schema: fix typing for QAPISchemaVariants.tag_member, John Snow, 2024/01/12
[PATCH v2 15/19] qapi/schema: assert inner type of QAPISchemaVariants in check_clash(), John Snow, 2024/01/12
[PATCH v2 12/19] qapi/schema: assert info is present when necessary, John Snow, 2024/01/12