mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 02:01:16 +00: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:
parent
fbd6f4e90c
commit
fbb84eca72
@ -22,8 +22,7 @@ install:
|
|||||||
- pip install nose
|
- pip install nose
|
||||||
- pip install nose2
|
- pip install nose2
|
||||||
- pip install flake8
|
- pip install flake8
|
||||||
- pip install isort==4.3.21
|
- pip install pylint==2.6.0
|
||||||
- pip install pylint==1.9.2
|
|
||||||
- git clone -v https://github.com/ARM-software/devlib.git /tmp/devlib && cd /tmp/devlib && python setup.py install
|
- git clone -v https://github.com/ARM-software/devlib.git /tmp/devlib && cd /tmp/devlib && python setup.py install
|
||||||
- cd $TRAVIS_BUILD_DIR && python setup.py install
|
- cd $TRAVIS_BUILD_DIR && python setup.py install
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ ignore=external
|
|||||||
# https://bitbucket.org/logilab/pylint/issue/232/wrong-hanging-indentation-false-positive
|
# https://bitbucket.org/logilab/pylint/issue/232/wrong-hanging-indentation-false-positive
|
||||||
# TODO: disabling no-value-for-parameter and logging-format-interpolation, as they appear to be broken
|
# TODO: disabling no-value-for-parameter and logging-format-interpolation, as they appear to be broken
|
||||||
# in version 1.4.1 and return a lot of false postives; should be re-enabled once fixed.
|
# in version 1.4.1 and return a lot of false postives; should be re-enabled once fixed.
|
||||||
disable=C0301,C0103,C0111,W0142,R0903,R0904,R0922,W0511,W0141,I0011,R0921,W1401,C0330,no-value-for-parameter,logging-format-interpolation,no-else-return,inconsistent-return-statements,keyword-arg-before-vararg,consider-using-enumerate,no-member
|
disable=C0301,C0103,C0111,W0142,R0903,R0904,R0922,W0511,W0141,I0011,R0921,W1401,C0330,no-value-for-parameter,logging-format-interpolation,no-else-return,inconsistent-return-statements,keyword-arg-before-vararg,consider-using-enumerate,no-member,super-with-arguments,useless-object-inheritance,raise-missing-from,no-else-raise,no-else-break,no-else-continue
|
||||||
|
|
||||||
[FORMAT]
|
[FORMAT]
|
||||||
max-module-lines=4000
|
max-module-lines=4000
|
||||||
|
@ -78,7 +78,7 @@ class ProcessCommand(Command):
|
|||||||
if not args.recursive:
|
if not args.recursive:
|
||||||
output_list = [RunOutput(process_directory)]
|
output_list = [RunOutput(process_directory)]
|
||||||
else:
|
else:
|
||||||
output_list = [output for output in discover_wa_outputs(process_directory)]
|
output_list = list(discover_wa_outputs(process_directory))
|
||||||
|
|
||||||
pc = ProcessContext()
|
pc = ProcessContext()
|
||||||
for run_output in output_list:
|
for run_output in output_list:
|
||||||
|
@ -252,8 +252,7 @@ class ConfigurationPoint(object):
|
|||||||
a warning to the user however will continue execution.
|
a warning to the user however will continue execution.
|
||||||
"""
|
"""
|
||||||
self.name = identifier(name)
|
self.name = identifier(name)
|
||||||
if kind in KIND_MAP:
|
kind = KIND_MAP.get(kind, kind)
|
||||||
kind = KIND_MAP[kind]
|
|
||||||
if kind is not None and not callable(kind):
|
if kind is not None and not callable(kind):
|
||||||
raise ValueError('Kind must be callable.')
|
raise ValueError('Kind must be callable.')
|
||||||
self.kind = kind
|
self.kind = kind
|
||||||
|
@ -297,7 +297,7 @@ def merge_augmentations(raw):
|
|||||||
raise ConfigError(msg.format(value, n, exc))
|
raise ConfigError(msg.format(value, n, exc))
|
||||||
|
|
||||||
# Make sure none of the specified aliases conflict with each other
|
# Make sure none of the specified aliases conflict with each other
|
||||||
to_check = [e for e in entries]
|
to_check = list(entries)
|
||||||
while len(to_check) > 1:
|
while len(to_check) > 1:
|
||||||
check_entry = to_check.pop()
|
check_entry = to_check.pop()
|
||||||
for e in to_check:
|
for e in to_check:
|
||||||
|
@ -33,6 +33,7 @@ class JobSpecSource(object):
|
|||||||
def id(self):
|
def id(self):
|
||||||
return self.config['id']
|
return self.config['id']
|
||||||
|
|
||||||
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ class Executor(object):
|
|||||||
for status in reversed(Status.levels):
|
for status in reversed(Status.levels):
|
||||||
if status in counter:
|
if status in counter:
|
||||||
parts.append('{} {}'.format(counter[status], status))
|
parts.append('{} {}'.format(counter[status], status))
|
||||||
self.logger.info(status_summary + ', '.join(parts))
|
self.logger.info('{}{}'.format(status_summary, ', '.join(parts)))
|
||||||
|
|
||||||
self.logger.info('Results can be found in {}'.format(output.basepath))
|
self.logger.info('Results can be found in {}'.format(output.basepath))
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ def init_user_directory(overwrite_existing=False): # pylint: disable=R0914
|
|||||||
# If running with sudo on POSIX, change the ownership to the real user.
|
# If running with sudo on POSIX, change the ownership to the real user.
|
||||||
real_user = os.getenv('SUDO_USER')
|
real_user = os.getenv('SUDO_USER')
|
||||||
if real_user:
|
if real_user:
|
||||||
|
# pylint: disable=import-outside-toplevel
|
||||||
import pwd # done here as module won't import on win32
|
import pwd # done here as module won't import on win32
|
||||||
user_entry = pwd.getpwnam(real_user)
|
user_entry = pwd.getpwnam(real_user)
|
||||||
uid, gid = user_entry.pw_uid, user_entry.pw_gid
|
uid, gid = user_entry.pw_uid, user_entry.pw_gid
|
||||||
|
@ -157,6 +157,7 @@ class Alias(object):
|
|||||||
raise ConfigError(msg.format(param, self.name, ext.name))
|
raise ConfigError(msg.format(param, self.name, ext.name))
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=bad-mcs-classmethod-argument
|
||||||
class PluginMeta(type):
|
class PluginMeta(type):
|
||||||
"""
|
"""
|
||||||
This basically adds some magic to plugins to make implementing new plugins,
|
This basically adds some magic to plugins to make implementing new plugins,
|
||||||
@ -367,7 +368,7 @@ class Plugin(with_metaclass(PluginMeta, object)):
|
|||||||
self._modules.append(module)
|
self._modules.append(module)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return str(self.name)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
params = []
|
params = []
|
||||||
|
@ -35,6 +35,7 @@ class __LoaderWrapper(object):
|
|||||||
def reset(self):
|
def reset(self):
|
||||||
# These imports cannot be done at top level, because of
|
# These imports cannot be done at top level, because of
|
||||||
# sys.modules manipulation below
|
# sys.modules manipulation below
|
||||||
|
# pylint: disable=import-outside-toplevel
|
||||||
from wa.framework.plugin import PluginLoader
|
from wa.framework.plugin import PluginLoader
|
||||||
from wa.framework.configuration.core import settings
|
from wa.framework.configuration.core import settings
|
||||||
self._loader = PluginLoader(settings.plugin_packages,
|
self._loader = PluginLoader(settings.plugin_packages,
|
||||||
|
@ -281,7 +281,7 @@ def apk_version_matches(path, version):
|
|||||||
version = list_or_string(version)
|
version = list_or_string(version)
|
||||||
info = get_cacheable_apk_info(path)
|
info = get_cacheable_apk_info(path)
|
||||||
for v in version:
|
for v in version:
|
||||||
if info.version_name == v or info.version_code == v:
|
if v in (info.version_name, info.version_code):
|
||||||
return True
|
return True
|
||||||
if loose_version_matching(v, info.version_name):
|
if loose_version_matching(v, info.version_name):
|
||||||
return True
|
return True
|
||||||
|
@ -732,7 +732,7 @@ class IdleStateValue(object):
|
|||||||
'''Checks passed state and converts to its ID'''
|
'''Checks passed state and converts to its ID'''
|
||||||
value = caseless_string(value)
|
value = caseless_string(value)
|
||||||
for s_id, s_name, s_desc in self.values:
|
for s_id, s_name, s_desc in self.values:
|
||||||
if value == s_id or value == s_name or value == s_desc:
|
if value in (s_id, s_name, s_desc):
|
||||||
return s_id
|
return s_id
|
||||||
msg = 'Invalid IdleState: "{}"; Must be in {}'
|
msg = 'Invalid IdleState: "{}"; Must be in {}'
|
||||||
raise ValueError(msg.format(value, self.values))
|
raise ValueError(msg.format(value, self.values))
|
||||||
|
@ -151,7 +151,7 @@ class PowerStateProcessor(object):
|
|||||||
|
|
||||||
def __init__(self, cpus, wait_for_marker=True, no_idle=None):
|
def __init__(self, cpus, wait_for_marker=True, no_idle=None):
|
||||||
if no_idle is 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.power_state = SystemPowerState(len(cpus), no_idle=no_idle)
|
||||||
self.requested_states = {} # cpu_id -> requeseted state
|
self.requested_states = {} # cpu_id -> requeseted state
|
||||||
self.wait_for_marker = wait_for_marker
|
self.wait_for_marker = wait_for_marker
|
||||||
@ -405,7 +405,7 @@ class ParallelStats(object):
|
|||||||
|
|
||||||
for i, clust in enumerate(clusters):
|
for i, clust in enumerate(clusters):
|
||||||
self.clusters[str(i)] = set(clust)
|
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.first_timestamp = None
|
||||||
self.last_timestamp = None
|
self.last_timestamp = None
|
||||||
|
@ -78,8 +78,8 @@ def init(verbosity=logging.INFO, color=True, indent_with=4,
|
|||||||
_console_handler.setFormatter(formatter(regular_fmt))
|
_console_handler.setFormatter(formatter(regular_fmt))
|
||||||
root_logger.addHandler(_console_handler)
|
root_logger.addHandler(_console_handler)
|
||||||
|
|
||||||
buffer_capacity = os.getenv('WA_LOG_BUFFER_CAPACITY',
|
buffer_capacity = int(os.getenv('WA_LOG_BUFFER_CAPACITY',
|
||||||
DEFAULT_INIT_BUFFER_CAPACITY)
|
str(DEFAULT_INIT_BUFFER_CAPACITY)))
|
||||||
_init_handler = InitHandler(buffer_capacity)
|
_init_handler = InitHandler(buffer_capacity)
|
||||||
_init_handler.setLevel(logging.DEBUG)
|
_init_handler.setLevel(logging.DEBUG)
|
||||||
root_logger.addHandler(_init_handler)
|
root_logger.addHandler(_init_handler)
|
||||||
|
@ -335,7 +335,7 @@ def load_struct_from_yaml(filepath=None, text=None):
|
|||||||
of basic Python types (strings, ints, lists, dicts, etc.)."""
|
of basic Python types (strings, ints, lists, dicts, etc.)."""
|
||||||
|
|
||||||
# Import here to avoid circular imports
|
# 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
|
from wa.utils.serializer import yaml
|
||||||
|
|
||||||
if not (filepath or text) or (filepath and text):
|
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()
|
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)
|
return load_struct_from_python(filepath)
|
||||||
elif extn == '.yaml':
|
elif extn == '.yaml':
|
||||||
return load_struct_from_yaml(filepath)
|
return load_struct_from_yaml(filepath)
|
||||||
@ -718,7 +718,7 @@ def lock_file(path, timeout=30):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Import here to avoid circular imports
|
# 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
|
from wa.framework.exception import ResourceError
|
||||||
|
|
||||||
locked = False
|
locked = False
|
||||||
|
@ -188,7 +188,7 @@ class ReventRecording(object):
|
|||||||
self._parse_header_and_devices(self.fh)
|
self._parse_header_and_devices(self.fh)
|
||||||
self._events_start = self.fh.tell()
|
self._events_start = self.fh.tell()
|
||||||
if not self.stream:
|
if not self.stream:
|
||||||
self._events = [e for e in self._iter_events()]
|
self._events = list(self._iter_events())
|
||||||
finally:
|
finally:
|
||||||
if self._close_when_done:
|
if self._close_when_done:
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -45,7 +45,7 @@ def get_terminal_size():
|
|||||||
|
|
||||||
|
|
||||||
def _get_terminal_size_windows():
|
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:
|
try:
|
||||||
from ctypes import windll, create_string_buffer
|
from ctypes import windll, create_string_buffer
|
||||||
# stdin handle is -10
|
# stdin handle is -10
|
||||||
@ -77,6 +77,7 @@ def _get_terminal_size_tput():
|
|||||||
|
|
||||||
|
|
||||||
def _get_terminal_size_linux():
|
def _get_terminal_size_linux():
|
||||||
|
# pylint: disable=import-outside-toplevel
|
||||||
def ioctl_GWINSZ(fd):
|
def ioctl_GWINSZ(fd):
|
||||||
try:
|
try:
|
||||||
import fcntl
|
import fcntl
|
||||||
|
@ -226,7 +226,7 @@ def module_name_set(l): # noqa: E741
|
|||||||
modules = set()
|
modules = set()
|
||||||
for m in l:
|
for m in l:
|
||||||
if m and isinstance(m, dict):
|
if m and isinstance(m, dict):
|
||||||
modules.update({k for k in m.keys()})
|
modules.update(m.keys())
|
||||||
else:
|
else:
|
||||||
modules.add(m)
|
modules.add(m)
|
||||||
return modules
|
return modules
|
||||||
@ -374,9 +374,8 @@ class prioritylist(object):
|
|||||||
else:
|
else:
|
||||||
raise ValueError('Invalid index {}'.format(index))
|
raise ValueError('Invalid index {}'.format(index))
|
||||||
current_global_offset = 0
|
current_global_offset = 0
|
||||||
priority_counts = {priority: count for (priority, count) in
|
priority_counts = dict(zip(self.priorities, [len(self.elements[p])
|
||||||
zip(self.priorities, [len(self.elements[p])
|
for p in self.priorities]))
|
||||||
for p in self.priorities])}
|
|
||||||
for priority in self.priorities:
|
for priority in self.priorities:
|
||||||
if not index_range:
|
if not index_range:
|
||||||
break
|
break
|
||||||
@ -462,7 +461,7 @@ class toggle_set(set):
|
|||||||
"""
|
"""
|
||||||
returns a list of enabled items.
|
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):
|
def conflicts_with(self, other):
|
||||||
"""
|
"""
|
||||||
@ -581,7 +580,7 @@ class level(object):
|
|||||||
return repr(self)
|
return repr(self)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return str(self.name)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '{}({})'.format(self.name, self.value)
|
return '{}({})'.format(self.name, self.value)
|
||||||
@ -806,7 +805,7 @@ class ParameterDict(dict):
|
|||||||
|
|
||||||
def update(self, *args, **kwargs):
|
def update(self, *args, **kwargs):
|
||||||
for d in list(args) + [kwargs]:
|
for d in list(args) + [kwargs]:
|
||||||
for k, v in d:
|
for k, v in d.items():
|
||||||
self[k] = v
|
self[k] = v
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,4 +91,4 @@ class Chrome(ApkUiautoWorkload):
|
|||||||
owner = self.target.execute("{} stat -c '%u' {}".format(self.target.busybox, offline_pages), as_root=True).strip()
|
owner = self.target.execute("{} stat -c '%u' {}".format(self.target.busybox, offline_pages), as_root=True).strip()
|
||||||
self.target.execute('{} tar -xvf {} -C {}'.format(self.target.busybox, archives_src, archives_dst), as_root=True)
|
self.target.execute('{} tar -xvf {} -C {}'.format(self.target.busybox, archives_src, archives_dst), as_root=True)
|
||||||
self.target.execute('{} cp {} {}'.format(self.target.busybox, metadata_src, metadata_dst), as_root=True)
|
self.target.execute('{} cp {} {}'.format(self.target.busybox, metadata_src, metadata_dst), as_root=True)
|
||||||
self.target.execute('{} chown -R {}:{} {}'.format(self.target.busybox, owner, owner, offline_pages), as_root=True)
|
self.target.execute('{0} chown -R {1}:{1} {2}'.format(self.target.busybox, owner, offline_pages), as_root=True)
|
||||||
|
@ -257,7 +257,7 @@ class GBScoreCalculator(object):
|
|||||||
'memory': 0.1926489,
|
'memory': 0.1926489,
|
||||||
'stream': 0.1054738,
|
'stream': 0.1054738,
|
||||||
}
|
}
|
||||||
# pylint: disable=C0326
|
|
||||||
workloads = [
|
workloads = [
|
||||||
# ID Name Power Mac ST Power Mac MT
|
# ID Name Power Mac ST Power Mac MT
|
||||||
GBWorkload(101, 'Blowfish', 43971, 40979), # NOQA
|
GBWorkload(101, 'Blowfish', 43971, 40979), # NOQA
|
||||||
|
@ -109,4 +109,4 @@ class Gmail(ApkUiautoWorkload):
|
|||||||
owner = self.target.execute("{} stat -c '%u' {}".format(self.target.busybox, database_dst), as_root=True).strip()
|
owner = self.target.execute("{} stat -c '%u' {}".format(self.target.busybox, database_dst), as_root=True).strip()
|
||||||
self.target.execute('{} rm {}'.format(self.target.busybox, existing_mailstores), as_root=True)
|
self.target.execute('{} rm {}'.format(self.target.busybox, existing_mailstores), as_root=True)
|
||||||
self.target.execute('{} tar -xvf {} -C {}'.format(self.target.busybox, database_src, database_dst), as_root=True)
|
self.target.execute('{} tar -xvf {} -C {}'.format(self.target.busybox, database_src, database_dst), as_root=True)
|
||||||
self.target.execute('{} chown -R {}:{} {}'.format(self.target.busybox, owner, owner, database_dst), as_root=True)
|
self.target.execute('{0} chown -R {1}:{1} {2}'.format(self.target.busybox, owner, database_dst), as_root=True)
|
||||||
|
@ -85,4 +85,4 @@ class GoogleMaps(ApkUiautoWorkload):
|
|||||||
owner = self.target.execute("{} stat -c '%u' {}".format(self.target.busybox, package_data_dir), as_root=True).strip()
|
owner = self.target.execute("{} stat -c '%u' {}".format(self.target.busybox, package_data_dir), as_root=True).strip()
|
||||||
self.target.execute('{} tar -xvf {} -C {}'.format(self.target.busybox, databases_src, databases_dst), as_root=True)
|
self.target.execute('{} tar -xvf {} -C {}'.format(self.target.busybox, databases_src, databases_dst), as_root=True)
|
||||||
self.target.execute('{} tar -xvf {} -C {}'.format(self.target.busybox, files_src, files_dst), as_root=True)
|
self.target.execute('{} tar -xvf {} -C {}'.format(self.target.busybox, files_src, files_dst), as_root=True)
|
||||||
self.target.execute('{} chown -R {}:{} {}'.format(self.target.busybox, owner, owner, package_data_dir), as_root=True)
|
self.target.execute('{0} chown -R {1}:{1} {2}'.format(self.target.busybox, owner, package_data_dir), as_root=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user