On Mon, Jan 15, 2024 at 9:03 AM Markus Armbruster <armbru@redhat.com> wrote:
>
> John Snow <jsnow@redhat.com> writes:
>
> > These methods should always return a str, it's only the default abstract
> > implementation that doesn't. They can be marked "abstract", which
> > requires subclasses to override the method with the proper return type.
> >
> > Signed-off-by: John Snow <jsnow@redhat.com>
> > ---
> > scripts/qapi/schema.py | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
> > index e45d9545eda..8e25dd35562 100644
> > --- a/scripts/qapi/schema.py
> > +++ b/scripts/qapi/schema.py
> > @@ -16,6 +16,7 @@
> >
> > # TODO catching name collisions in generated code would be nice
> >
> > +from abc import ABC, abstractmethod
> > from collections import OrderedDict
> > import os
> > import re
> > @@ -253,10 +254,11 @@ def visit(self, visitor):
> > visitor.visit_include(self._sub_module.name, self.info)
> >
> >
> > -class QAPISchemaType(QAPISchemaDefinition):
> > +class QAPISchemaType(QAPISchemaDefinition, ABC):
> > # Return the C type for common use.
> > # For the types we commonly box, this is a pointer type.
> > - def c_type(self):
> > + @abstractmethod
> > + def c_type(self) -> str:
>
> You additionally add the type hint. Suggest to either mention it in the
> commit message, or add it only together with the other type hints in
> PATCH 17.
Okie-dokey. (moved type hints to the big patch)
>
> > pass
> >
> > # Return the C type to be used in a parameter list.
> > @@ -267,7 +269,8 @@ def c_param_type(self):
> > def c_unboxed_type(self):
> > return self.c_type()
> >
> > - def json_type(self):
> > + @abstractmethod
> > + def json_type(self) -> str:
>
> Likewise.
>
> > pass
> >
> > def alternate_qtype(self):
>