[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: |
John Snow |
Subject: |
Re: [PATCH v2 05/19] qapi/schema: declare type for QAPISchemaArrayType.element_type |
Date: |
Wed, 17 Jan 2024 11:06:57 -0500 |
On Mon, Jan 15, 2024 at 8:59 AM Markus Armbruster <armbru@redhat.com> wrote:
>
> 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.
Sure, I tweaked and re-used it.
--js
>
> > 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
>
- [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, 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
[PATCH v2 15/19] qapi/schema: assert inner type of QAPISchemaVariants in check_clash(), John Snow, 2024/01/12