Skip to content

Commit b736e25

Browse files
author
Markus Armbruster
committed
qapi: Fix some pycodestyle-3 complaints
Fix the following issues: common.py:873:13: E129 visually indented line with same indent as next logical line common.py:1766:5: E741 ambiguous variable name 'l' common.py:1784:1: E305 expected 2 blank lines after class or function definition, found 1 common.py:1833:1: E305 expected 2 blank lines after class or function definition, found 1 common.py:1843:1: E305 expected 2 blank lines after class or function definition, found 1 visit.py:181:18: E127 continuation line over-indented for visual indent Signed-off-by: Markus Armbruster <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]> [Fixup squashed in:] Message-ID: <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]>
1 parent 214e4a5 commit b736e25

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

scripts/qapi/common.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,12 +884,12 @@ def check_keys(expr_elem, meta, required, optional=[]):
884884
if key not in required and key not in optional:
885885
raise QAPISemError(info, "Unknown key '%s' in %s '%s'"
886886
% (key, meta, name))
887-
if (key == 'gen' or key == 'success-response') and value is not False:
887+
if key in ['gen', 'success-response'] and value is not False:
888888
raise QAPISemError(info,
889889
"'%s' of %s '%s' should only use false value"
890890
% (key, meta, name))
891-
if (key == 'boxed' or key == 'allow-oob' or
892-
key == 'allow-preconfig') and value is not True:
891+
if (key in ['boxed', 'allow-oob', 'allow-preconfig']
892+
and value is not True):
893893
raise QAPISemError(info,
894894
"'%s' of %s '%s' should only use true value"
895895
% (key, meta, name))
@@ -1845,12 +1845,12 @@ def camel_to_upper(value):
18451845
return c_fun_str
18461846

18471847
new_name = ''
1848-
l = len(c_fun_str)
1849-
for i in range(l):
1848+
length = len(c_fun_str)
1849+
for i in range(length):
18501850
c = c_fun_str[i]
18511851
# When c is upper and no '_' appears before, do more checks
18521852
if c.isupper() and (i > 0) and c_fun_str[i - 1] != '_':
1853-
if i < l - 1 and c_fun_str[i + 1].islower():
1853+
if i < length - 1 and c_fun_str[i + 1].islower():
18541854
new_name += '_'
18551855
elif c_fun_str[i - 1].isdigit():
18561856
new_name += '_'
@@ -1863,6 +1863,7 @@ def c_enum_const(type_name, const_name, prefix=None):
18631863
type_name = prefix
18641864
return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper()
18651865

1866+
18661867
if hasattr(str, 'maketrans'):
18671868
c_name_trans = str.maketrans('.-', '__')
18681869
else:
@@ -1912,6 +1913,7 @@ def c_name(name, protect=True):
19121913
return 'q_' + name
19131914
return name
19141915

1916+
19151917
eatspace = '\033EATSPACE.'
19161918
pointer_suffix = ' *' + eatspace
19171919

@@ -1922,6 +1924,7 @@ def genindent(count):
19221924
ret += ' '
19231925
return ret
19241926

1927+
19251928
indent_level = 0
19261929

19271930

scripts/qapi/visit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def gen_visit_alternate(name, variants):
187187
}
188188
switch ((*obj)->type) {
189189
''',
190-
c_name=c_name(name))
190+
c_name=c_name(name))
191191

192192
for var in variants.variants:
193193
ret += mcgen('''

tests/qapi-schema/test-qapi.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def visit_object_type(self, name, info, ifcond, base, members, variants):
3434
if base:
3535
print(' base %s' % base.name)
3636
for m in members:
37-
print(' member %s: %s optional=%s' % \
38-
(m.name, m.type.name, m.optional))
37+
print(' member %s: %s optional=%s'
38+
% (m.name, m.type.name, m.optional))
3939
self._print_variants(variants)
4040
self._print_if(ifcond)
4141

@@ -46,10 +46,11 @@ def visit_alternate_type(self, name, info, ifcond, variants):
4646

4747
def visit_command(self, name, info, ifcond, arg_type, ret_type, gen,
4848
success_response, boxed, allow_oob, allow_preconfig):
49-
print('command %s %s -> %s' % \
50-
(name, arg_type and arg_type.name, ret_type and ret_type.name))
51-
print(' gen=%s success_response=%s boxed=%s oob=%s preconfig=%s' % \
52-
(gen, success_response, boxed, allow_oob, allow_preconfig))
49+
print('command %s %s -> %s'
50+
% (name, arg_type and arg_type.name,
51+
ret_type and ret_type.name))
52+
print(' gen=%s success_response=%s boxed=%s oob=%s preconfig=%s'
53+
% (gen, success_response, boxed, allow_oob, allow_preconfig))
5354
self._print_if(ifcond)
5455

5556
def visit_event(self, name, info, ifcond, arg_type, boxed):

0 commit comments

Comments
 (0)