1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-02 03:12:34 +01:00

Pylint Fixes

Update our version of pylint to use the latest version and update the
codebase to comply with the majority of the updates.

For now disable the additional checks for `super-with-arguments`,
`useless-object-inheritance`, `raise-missing-from`, `no-else-raise`,
`no-else-break`, `no-else-continue` to be consistent with the existing
codebase.
This commit is contained in:
Marc Bonnici
2020-10-19 18:07:21 +01:00
committed by setrofim
parent fbd6f4e90c
commit fbb84eca72
22 changed files with 33 additions and 31 deletions

View File

@@ -151,7 +151,7 @@ class PowerStateProcessor(object):
def __init__(self, cpus, wait_for_marker=True, no_idle=None):
if no_idle is None:
no_idle = False if cpus[0].cpuidle and cpus[0].cpuidle.states else True
no_idle = not (cpus[0].cpuidle and cpus[0].cpuidle.states)
self.power_state = SystemPowerState(len(cpus), no_idle=no_idle)
self.requested_states = {} # cpu_id -> requeseted state
self.wait_for_marker = wait_for_marker
@@ -405,7 +405,7 @@ class ParallelStats(object):
for i, clust in enumerate(clusters):
self.clusters[str(i)] = set(clust)
self.clusters['all'] = set([cpu.id for cpu in cpus])
self.clusters['all'] = {cpu.id for cpu in cpus}
self.first_timestamp = None
self.last_timestamp = None

View File

@@ -78,8 +78,8 @@ def init(verbosity=logging.INFO, color=True, indent_with=4,
_console_handler.setFormatter(formatter(regular_fmt))
root_logger.addHandler(_console_handler)
buffer_capacity = os.getenv('WA_LOG_BUFFER_CAPACITY',
DEFAULT_INIT_BUFFER_CAPACITY)
buffer_capacity = int(os.getenv('WA_LOG_BUFFER_CAPACITY',
str(DEFAULT_INIT_BUFFER_CAPACITY)))
_init_handler = InitHandler(buffer_capacity)
_init_handler.setLevel(logging.DEBUG)
root_logger.addHandler(_init_handler)

View File

@@ -335,7 +335,7 @@ def load_struct_from_yaml(filepath=None, text=None):
of basic Python types (strings, ints, lists, dicts, etc.)."""
# Import here to avoid circular imports
# pylint: disable=wrong-import-position,cyclic-import
# pylint: disable=wrong-import-position,cyclic-import, import-outside-toplevel
from wa.utils.serializer import yaml
if not (filepath or text) or (filepath and text):
@@ -361,7 +361,7 @@ def load_struct_from_file(filepath):
"""
extn = os.path.splitext(filepath)[1].lower()
if (extn == '.py') or (extn == '.pyc') or (extn == '.pyo'):
if extn in ('.py', '.pyc', '.pyo'):
return load_struct_from_python(filepath)
elif extn == '.yaml':
return load_struct_from_yaml(filepath)
@@ -718,7 +718,7 @@ def lock_file(path, timeout=30):
"""
# Import here to avoid circular imports
# pylint: disable=wrong-import-position,cyclic-import
# pylint: disable=wrong-import-position,cyclic-import, import-outside-toplevel
from wa.framework.exception import ResourceError
locked = False

View File

@@ -188,7 +188,7 @@ class ReventRecording(object):
self._parse_header_and_devices(self.fh)
self._events_start = self.fh.tell()
if not self.stream:
self._events = [e for e in self._iter_events()]
self._events = list(self._iter_events())
finally:
if self._close_when_done:
self.close()

View File

@@ -45,7 +45,7 @@ def get_terminal_size():
def _get_terminal_size_windows():
# pylint: disable=unused-variable,redefined-outer-name,too-many-locals
# pylint: disable=unused-variable,redefined-outer-name,too-many-locals, import-outside-toplevel
try:
from ctypes import windll, create_string_buffer
# stdin handle is -10
@@ -77,6 +77,7 @@ def _get_terminal_size_tput():
def _get_terminal_size_linux():
# pylint: disable=import-outside-toplevel
def ioctl_GWINSZ(fd):
try:
import fcntl

View File

@@ -226,7 +226,7 @@ def module_name_set(l): # noqa: E741
modules = set()
for m in l:
if m and isinstance(m, dict):
modules.update({k for k in m.keys()})
modules.update(m.keys())
else:
modules.add(m)
return modules
@@ -374,9 +374,8 @@ class prioritylist(object):
else:
raise ValueError('Invalid index {}'.format(index))
current_global_offset = 0
priority_counts = {priority: count for (priority, count) in
zip(self.priorities, [len(self.elements[p])
for p in self.priorities])}
priority_counts = dict(zip(self.priorities, [len(self.elements[p])
for p in self.priorities]))
for priority in self.priorities:
if not index_range:
break
@@ -462,7 +461,7 @@ class toggle_set(set):
"""
returns a list of enabled items.
"""
return set([item for item in self if not item.startswith('~')])
return {item for item in self if not item.startswith('~')}
def conflicts_with(self, other):
"""
@@ -581,7 +580,7 @@ class level(object):
return repr(self)
def __str__(self):
return self.name
return str(self.name)
def __repr__(self):
return '{}({})'.format(self.name, self.value)
@@ -806,7 +805,7 @@ class ParameterDict(dict):
def update(self, *args, **kwargs):
for d in list(args) + [kwargs]:
for k, v in d:
for k, v in d.items():
self[k] = v