The function only receives the dictionary form of enum expressions
now, so we can make it shorter.

Suggested-by: Markus Armbruster <arm...@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com>
Reviewed-by: Markus Armbruster <arm...@redhat.com>
---
 scripts/qapi/common.py | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 569e397147..510b177e6a 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -1656,14 +1656,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']
-            else:
-                name = v
-            enum.append(QAPISchemaMember(name))
-        return enum
+        return [QAPISchemaMember(v['name']) for v in values]
 
     def _make_implicit_enum_type(self, name, info, ifcond, values):
         # See also QAPISchemaObjectTypeMember._pretty_owner()
@@ -1763,8 +1756,8 @@ class QAPISchema(object):
         else:
             variants = [self._make_simple_variant(key, value, info)
                         for (key, value) in data.items()]
-            typ = self._make_implicit_enum_type(name, info, ifcond,
-                                                [v.name for v in variants])
+            enum = [{'name': v.name} for v in variants]
+            typ = self._make_implicit_enum_type(name, info, ifcond, enum)
             tag_member = QAPISchemaObjectTypeMember('type', typ, False)
             members = [tag_member]
         self._def_entity(
-- 
2.20.0


Reply via email to