diff mbox series

[v2,11/19] qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type

Message ID 20240112222945.3033854-12-jsnow@redhat.com (mailing list archive)
State New, archived
Headers show
Series qapi: statically type schema.py | expand

Commit Message

John Snow Jan. 12, 2024, 10:29 p.m. UTC
Adjust the expression at the callsite to eliminate weak type
introspection that believes this value can resolve to QAPISourceInfo; it
cannot.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/schema.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Markus Armbruster Jan. 16, 2024, 12:17 p.m. UTC | #1
John Snow <jsnow@redhat.com> writes:

> Adjust the expression at the callsite to eliminate weak type
> introspection that believes this value can resolve to QAPISourceInfo; it
> cannot.

What do you mean by "weak type introspection"?  mypy being underpowered?

> 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 35638c7708a..43af756ed47 100644
> --- a/scripts/qapi/schema.py
> +++ b/scripts/qapi/schema.py
> @@ -403,7 +403,7 @@ def check(self, schema):
>          super().check(schema)
>          self.element_type = schema.resolve_type(
>              self._element_type_name, self.info,
> -            self.info and self.info.defn_meta)
> +            self.info.defn_meta if self.info else None)
>          assert not isinstance(self.element_type, QAPISchemaArrayType)
>  
>      def set_module(self, schema):
John Snow Jan. 17, 2024, 4:48 p.m. UTC | #2
On Tue, Jan 16, 2024 at 7:17 AM Markus Armbruster <armbru@redhat.com> wrote:
>
> John Snow <jsnow@redhat.com> writes:
>
> > Adjust the expression at the callsite to eliminate weak type
> > introspection that believes this value can resolve to QAPISourceInfo; it
> > cannot.
>
> What do you mean by "weak type introspection"?  mypy being underpowered?

Yeah, s'what I meant.

>
> > 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 35638c7708a..43af756ed47 100644
> > --- a/scripts/qapi/schema.py
> > +++ b/scripts/qapi/schema.py
> > @@ -403,7 +403,7 @@ def check(self, schema):
> >          super().check(schema)
> >          self.element_type = schema.resolve_type(
> >              self._element_type_name, self.info,
> > -            self.info and self.info.defn_meta)
> > +            self.info.defn_meta if self.info else None)
> >          assert not isinstance(self.element_type, QAPISchemaArrayType)
> >
> >      def set_module(self, schema):
>
Markus Armbruster Jan. 17, 2024, 8 p.m. UTC | #3
John Snow <jsnow@redhat.com> writes:

> On Tue, Jan 16, 2024 at 7:17 AM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> John Snow <jsnow@redhat.com> writes:
>>
>> > Adjust the expression at the callsite to eliminate weak type
>> > introspection that believes this value can resolve to QAPISourceInfo; it
>> > cannot.
>>
>> What do you mean by "weak type introspection"?  mypy being underpowered?
>
> Yeah, s'what I meant.

Should be easy to clarify: mention mypy.
diff mbox series

Patch

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 35638c7708a..43af756ed47 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -403,7 +403,7 @@  def check(self, schema):
         super().check(schema)
         self.element_type = schema.resolve_type(
             self._element_type_name, self.info,
-            self.info and self.info.defn_meta)
+            self.info.defn_meta if self.info else None)
         assert not isinstance(self.element_type, QAPISchemaArrayType)
 
     def set_module(self, schema):