diff mbox series

[for-4.0,v7,17/27] qapi: simplify make_enum_members()

Message ID 20181208111606.8505-18-marcandre.lureau@redhat.com
State New
Headers show
Series Hi, | expand

Commit Message

Marc-André Lureau Dec. 8, 2018, 11:15 a.m. UTC
The function only receives the dictionary form of enum expressions
now, so we can make it shorter.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/qapi/common.py | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Comments

Markus Armbruster Dec. 11, 2018, 12:05 p.m. UTC | #1
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> The function only receives the dictionary form of enum expressions
> now, so we can make it shorter.
>
> Suggested-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  scripts/qapi/common.py | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index fd622313cb..44020779dd 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -1714,16 +1714,7 @@ class QAPISchema(object):
>                                              qtype_values, 'QTYPE'))
>  
>      def _make_enum_members(self, values):
> -        enum = []
> -        for v in values:
> -            if isinstance(v, dict):
> -                name = v['name']
> -                ifcond = v.get('if')
> -            else:
> -                name = v
> -                ifcond = None
> -            enum.append(QAPISchemaMember(name, ifcond))
> -        return enum
> +        return [QAPISchemaMember(v['name'], v.get('if')) for v in values]
>  
>      def _make_implicit_enum_type(self, name, info, ifcond, values):
>          # See also QAPISchemaObjectTypeMember._pretty_owner()

We may want to squash this one into PATCH 08 as mentioned in that
patch's review.

In case we don't:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Marc-André Lureau Dec. 11, 2018, 12:08 p.m. UTC | #2
Hi

On Tue, Dec 11, 2018 at 4:06 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
> > The function only receives the dictionary form of enum expressions
> > now, so we can make it shorter.
> >
> > Suggested-by: Markus Armbruster <armbru@redhat.com>
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  scripts/qapi/common.py | 11 +----------
> >  1 file changed, 1 insertion(+), 10 deletions(-)
> >
> > diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> > index fd622313cb..44020779dd 100644
> > --- a/scripts/qapi/common.py
> > +++ b/scripts/qapi/common.py
> > @@ -1714,16 +1714,7 @@ class QAPISchema(object):
> >                                              qtype_values, 'QTYPE'))
> >
> >      def _make_enum_members(self, values):
> > -        enum = []
> > -        for v in values:
> > -            if isinstance(v, dict):
> > -                name = v['name']
> > -                ifcond = v.get('if')
> > -            else:
> > -                name = v
> > -                ifcond = None
> > -            enum.append(QAPISchemaMember(name, ifcond))
> > -        return enum
> > +        return [QAPISchemaMember(v['name'], v.get('if')) for v in values]
> >
> >      def _make_implicit_enum_type(self, name, info, ifcond, values):
> >          # See also QAPISchemaObjectTypeMember._pretty_owner()
>
> We may want to squash this one into PATCH 08 as mentioned in that
> patch's review.
>
> In case we don't:
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
>

Feel free to squash on commit, thanks
diff mbox series

Patch

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index fd622313cb..44020779dd 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -1714,16 +1714,7 @@  class QAPISchema(object):
                                             qtype_values, 'QTYPE'))
 
     def _make_enum_members(self, values):
-        enum = []
-        for v in values:
-            if isinstance(v, dict):
-                name = v['name']
-                ifcond = v.get('if')
-            else:
-                name = v
-                ifcond = None
-            enum.append(QAPISchemaMember(name, ifcond))
-        return enum
+        return [QAPISchemaMember(v['name'], v.get('if')) for v in values]
 
     def _make_implicit_enum_type(self, name, info, ifcond, values):
         # See also QAPISchemaObjectTypeMember._pretty_owner()