[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 05/19] qapi/schema: declare type for QAPISchemaArrayType.e
|
From: |
Markus Armbruster |
|
Subject: |
Re: [PATCH v2 05/19] qapi/schema: declare type for QAPISchemaArrayType.element_type |
|
Date: |
Mon, 15 Jan 2024 14:59:25 +0100 |
|
User-agent: |
Gnus/5.13 (Gnus v5.13) |
John Snow <jsnow@redhat.com> writes:
> This field should always be present and defined after check() is
> called. Declare the property but allow its initialization to be delayed
> until check() so that it can be typed without the use of `Optional`.
>
> This helps simplify typing by avoiding the need to interrogate the value
> for None at multiple callsites; the overwhelming majority of uses assume
> a fully-initialized object.
If you like my version of the previous patch's commit message, we could
reuse it here.
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
> scripts/qapi/schema.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> index 48a51dcd188..e45d9545eda 100644
> --- a/scripts/qapi/schema.py
> +++ b/scripts/qapi/schema.py
> @@ -389,7 +389,7 @@ def __init__(self, name, info, element_type):
> super().__init__(name, info, None)
> assert isinstance(element_type, str)
> self._element_type_name = element_type
> - self.element_type = None
> + self.element_type: QAPISchemaType
>
> def need_has_if_optional(self):
> # When FOO is an array, we still need has_FOO to distinguish
- Re: [PATCH v2 06/19] qapi/schema: make c_type() and json_type() abstract methods, (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
- Re: [PATCH v2 05/19] qapi/schema: declare type for QAPISchemaArrayType.element_type,
Markus Armbruster <=
- [PATCH v2 08/19] qapi/schema: add type narrowing to lookup_type(), John Snow, 2024/01/12
- [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