[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 11/19] qapi/schema: fix QAPISchemaArrayType.check's call to r
|
From: |
John Snow |
|
Subject: |
Re: [PATCH 11/19] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type |
|
Date: |
Wed, 22 Nov 2023 10:58:02 -0500 |
On Wed, Nov 22, 2023 at 7:59 AM Markus Armbruster <armbru@redhat.com> wrote:
>
> John Snow <jsnow@redhat.com> writes:
>
> > There's more conditionals in here than we can reasonably pack into a
> > terse little statement, so break it apart into something more explicit.
> >
> > (When would a built-in array ever cause a QAPISemError? I don't know,
> > maybe never - but the type system wasn't happy all the same.)
> >
> > Signed-off-by: John Snow <jsnow@redhat.com>
> > ---
> > scripts/qapi/schema.py | 11 +++++++++--
> > 1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> > index 462acb2bb61..164d86c4064 100644
> > --- a/scripts/qapi/schema.py
> > +++ b/scripts/qapi/schema.py
> > @@ -384,9 +384,16 @@ def need_has_if_optional(self):
> >
> > def check(self, schema):
> > super().check(schema)
> > +
> > + if self.info:
> > + assert self.info.defn_meta # guaranteed to be set by expr.py
> > + what = self.info.defn_meta
> > + else:
> > + what = 'built-in array'
> > +
> > self._element_type = schema.resolve_type(
> > - self._element_type_name, self.info,
> > - self.info and self.info.defn_meta)
> > + self._element_type_name, self.info, what
> > + )
> > assert not isinstance(self.element_type, QAPISchemaArrayType)
> >
> > def set_module(self, schema):
>
> What problem are you solving here?
>
1. "self.info and self.info.defn_meta" is the wrong type ifn't self.info
2. self.info.defn_meta is *also* not guaranteed by static types
ultimately: we need to assert self.info and self.info.defn_meta both;
but it's possible (?) that we don't have self.info in the case that
we're a built-in array, so I handle that.
- Re: [PATCH 05/19] qapi/schema: make c_type() and json_type() abstract methods, (continued)
- Re: [PATCH 05/19] qapi/schema: make c_type() and json_type() abstract methods, Markus Armbruster, 2023/11/21
- Re: [PATCH 05/19] qapi/schema: make c_type() and json_type() abstract methods, Daniel P . Berrangé, 2023/11/21
- Re: [PATCH 05/19] qapi/schema: make c_type() and json_type() abstract methods, John Snow, 2023/11/21
- Re: [PATCH 05/19] qapi/schema: make c_type() and json_type() abstract methods, Daniel P . Berrangé, 2023/11/21
- Re: [PATCH 05/19] qapi/schema: make c_type() and json_type() abstract methods, Markus Armbruster, 2023/11/22
- Re: [PATCH 05/19] qapi/schema: make c_type() and json_type() abstract methods, Daniel P . Berrangé, 2023/11/22
[PATCH 09/19] qapi/schema: assert info is present when necessary, John Snow, 2023/11/15
[PATCH 11/19] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type, John Snow, 2023/11/15
[PATCH 14/19] qapi/schema: assert QAPISchemaVariants are QAPISchemaObjectType, John Snow, 2023/11/15
[PATCH 13/19] qapi/schema: fix typing for QAPISchemaVariants.tag_member, John Snow, 2023/11/15
[PATCH 17/19] qapi/schema: turn on mypy strictness, John Snow, 2023/11/15
[PATCH 19/19] qapi/schema: refactor entity lookup helpers, John Snow, 2023/11/15
[PATCH 18/19] qapi/schema: remove unnecessary asserts, John Snow, 2023/11/15