[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/19] qapi/schema: name QAPISchemaInclude entities
|
From: |
John Snow |
|
Subject: |
[PATCH 03/19] qapi/schema: name QAPISchemaInclude entities |
|
Date: |
Wed, 15 Nov 2023 20:43:34 -0500 |
It simplifies typing to mandate that entities will always have a name;
to achieve this we can occasionally assign an internal name. This
alleviates errors such as:
qapi/schema.py:287: error: Argument 1 to "__init__" of
"QAPISchemaEntity" has incompatible type "None"; expected "str"
[arg-type]
Trying to fix it the other way by allowing entities to only have
optional names opens up a nightmare portal of whackamole to try and
audit that every other pathway doesn't actually pass a None name when we
expect it to; this is the simpler direction of consitifying the typing.
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 153e703e0ef..0fb44452dd5 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -220,7 +220,9 @@ def visit(self, visitor):
class QAPISchemaInclude(QAPISchemaEntity):
def __init__(self, sub_module, info):
- super().__init__(None, info, None)
+ # Includes are internal entity objects; and may occur multiple times
+ name = f"q_include_{info.fname}:{info.line}"
+ super().__init__(name, info, None)
self._sub_module = sub_module
def visit(self, visitor):
--
2.41.0
[PATCH 03/19] qapi/schema: name QAPISchemaInclude entities,
John Snow <=
[PATCH 12/19] qapi/schema: split "checked" field into "checking" and "checked", John Snow, 2023/11/15
[PATCH 01/19] qapi/schema: fix QAPISchemaEntity.__repr__(), John Snow, 2023/11/15
[PATCH 06/19] qapi/schema: adjust type narrowing for mypy's benefit, John Snow, 2023/11/15