qapi: delint using flake8

Petty style guide fixes and line length enforcement.  Not a big win, not
a big loss, but flake8 passes 100% on the qapi module, which gives us an
easy baseline to enforce hereafter.

A note on the flake8 exception: flake8 will warn on *any* bare except,
but pylint's is context-aware and will suppress the warning if you
re-raise the exception.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Message-Id: <20201009161558.107041-9-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
John Snow 2020-10-09 12:15:30 -04:00 committed by Markus Armbruster
parent 67fea57502
commit 42c0dd1222
4 changed files with 20 additions and 9 deletions

2
scripts/qapi/.flake8 Normal file
View File

@ -0,0 +1,2 @@
[flake8]
extend-ignore = E722 # Prefer pylint's bare-except checks to flake8's

View File

@ -65,7 +65,8 @@ def gen_call(name, arg_type, boxed, ret_type):
def gen_marshal_output(ret_type): def gen_marshal_output(ret_type):
return mcgen(''' return mcgen('''
static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret_out, Error **errp) static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in,
QObject **ret_out, Error **errp)
{ {
Visitor *v; Visitor *v;

View File

@ -536,7 +536,7 @@ class QAPISchemaVariants:
v.set_defined_in(name) v.set_defined_in(name)
def check(self, schema, seen): def check(self, schema, seen):
if not self.tag_member: # flat union if not self.tag_member: # flat union
self.tag_member = seen.get(c_name(self._tag_name)) self.tag_member = seen.get(c_name(self._tag_name))
base = "'base'" base = "'base'"
# Pointing to the base type when not implicit would be # Pointing to the base type when not implicit would be
@ -824,7 +824,7 @@ class QAPISchema:
self._entity_dict = {} self._entity_dict = {}
self._module_dict = OrderedDict() self._module_dict = OrderedDict()
self._schema_dir = os.path.dirname(fname) self._schema_dir = os.path.dirname(fname)
self._make_module(None) # built-ins self._make_module(None) # built-ins
self._make_module(fname) self._make_module(fname)
self._predefining = True self._predefining = True
self._def_predefineds() self._def_predefineds()
@ -968,7 +968,9 @@ class QAPISchema:
# But it's not tight: the disjunction need not imply it. We # But it's not tight: the disjunction need not imply it. We
# may end up compiling useless wrapper types. # may end up compiling useless wrapper types.
# TODO kill simple unions or implement the disjunction # TODO kill simple unions or implement the disjunction
assert (ifcond or []) == typ._ifcond # pylint: disable=protected-access
# pylint: disable=protected-access
assert (ifcond or []) == typ._ifcond
else: else:
self._def_entity(QAPISchemaObjectType( self._def_entity(QAPISchemaObjectType(
name, info, None, ifcond, None, None, members, None)) name, info, None, ifcond, None, None, members, None))

View File

@ -31,7 +31,9 @@ def gen_visit_decl(name, scalar=False):
if not scalar: if not scalar:
c_type += '*' c_type += '*'
return mcgen(''' return mcgen('''
bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Error **errp);
bool visit_type_%(c_name)s(Visitor *v, const char *name,
%(c_type)sobj, Error **errp);
''', ''',
c_name=c_name(name), c_type=c_type) c_name=c_name(name), c_type=c_type)
@ -125,7 +127,8 @@ bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
def gen_visit_list(name, element_type): def gen_visit_list(name, element_type):
return mcgen(''' return mcgen('''
bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp) bool visit_type_%(c_name)s(Visitor *v, const char *name,
%(c_name)s **obj, Error **errp)
{ {
bool ok = false; bool ok = false;
%(c_name)s *tail; %(c_name)s *tail;
@ -158,7 +161,8 @@ out_obj:
def gen_visit_enum(name): def gen_visit_enum(name):
return mcgen(''' return mcgen('''
bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error **errp) bool visit_type_%(c_name)s(Visitor *v, const char *name,
%(c_name)s *obj, Error **errp)
{ {
int value = *obj; int value = *obj;
bool ok = visit_type_enum(v, name, &value, &%(c_name)s_lookup, errp); bool ok = visit_type_enum(v, name, &value, &%(c_name)s_lookup, errp);
@ -172,7 +176,8 @@ bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error
def gen_visit_alternate(name, variants): def gen_visit_alternate(name, variants):
ret = mcgen(''' ret = mcgen('''
bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp) bool visit_type_%(c_name)s(Visitor *v, const char *name,
%(c_name)s **obj, Error **errp)
{ {
bool ok = false; bool ok = false;
@ -247,7 +252,8 @@ out_obj:
def gen_visit_object(name, base, members, variants): def gen_visit_object(name, base, members, variants):
return mcgen(''' return mcgen('''
bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error **errp) bool visit_type_%(c_name)s(Visitor *v, const char *name,
%(c_name)s **obj, Error **errp)
{ {
bool ok = false; bool ok = false;