Pylint: minor code simplifications

Simplify the code in minor ways. Each of this changes fixes a warning
from Pylint 2.4 that doesn't appear with Pylint 1.7.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2020-03-24 18:36:56 +01:00
parent 5d1dfd4108
commit 399b82f986
3 changed files with 6 additions and 9 deletions

View file

@ -402,8 +402,7 @@ def parse_dependencies(inp_str):
:param inp_str: Input string with macros delimited by ':'.
:return: list of dependencies
"""
dependencies = [dep for dep in map(validate_dependency,
inp_str.split(':'))]
dependencies = list(map(validate_dependency, inp_str.split(':')))
return dependencies

View file

@ -262,7 +262,7 @@ class MbedTlsTest(BaseHostTest):
data_bytes += bytearray(dependencies)
data_bytes += bytearray([function_id, len(parameters)])
for typ, param in parameters:
if typ == 'int' or typ == 'exp':
if typ in ('int', 'exp'):
i = int(param, 0)
data_bytes += b'I' if typ == 'int' else b'E'
self.align_32bit(data_bytes)

View file

@ -1127,9 +1127,8 @@ Diffie-Hellman selftest
dhm_selftest:
"""
stream = StringIOWrapper('test_suite_ut.function', data)
tests = [(name, test_function, dependencies, args)
for name, test_function, dependencies, args in
parse_test_data(stream)]
# List of (name, function_name, dependencies, args)
tests = list(parse_test_data(stream))
test1, test2, test3, test4 = tests
self.assertEqual(test1[0], 'Diffie-Hellman full exchange #1')
self.assertEqual(test1[1], 'dhm_do_dhm')
@ -1170,9 +1169,8 @@ dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622"
"""
stream = StringIOWrapper('test_suite_ut.function', data)
tests = [(name, function_name, dependencies, args)
for name, function_name, dependencies, args in
parse_test_data(stream)]
# List of (name, function_name, dependencies, args)
tests = list(parse_test_data(stream))
test1, test2 = tests
self.assertEqual(test1[0], 'Diffie-Hellman full exchange #1')
self.assertEqual(test1[1], 'dhm_do_dhm')