From 46af48052b2b94e4ce46ccc8a1d37dd2c405a9d2 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 20 Jun 2020 09:46:45 +0000 Subject: [PATCH] Bug 1646421 - flake8 Fix a bunch of actual errors r=ahal Differential Revision: https://phabricator.services.mozilla.com/D80078 --- js/src/devtools/rootAnalysis/t/testlib.py | 2 +- js/src/tests/test262-export.py | 2 +- js/src/vm/jsopcode.py | 6 ++---- python/lldbutils/lldbutils/general.py | 2 +- python/mozbuild/mozbuild/configure/__init__.py | 2 ++ python/mozbuild/mozbuild/mach_commands.py | 2 +- python/mozbuild/mozbuild/test/configure/common.py | 2 +- .../mozbuild/test/configure/test_checks_configure.py | 2 +- python/mozbuild/mozbuild/test/test_util.py | 1 + taskcluster/docker/visual-metrics/run-visual-metrics.py | 1 + taskcluster/taskgraph/actions/cancel.py | 2 +- taskcluster/taskgraph/transforms/job/common.py | 3 +-- taskcluster/taskgraph/transforms/job/debian_package.py | 2 -- taskcluster/taskgraph/util/partners.py | 2 +- testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py | 2 +- testing/mozbase/mozlog/tests/test_formatters.py | 2 ++ testing/mozbase/mozrunner/mozrunner/base/device.py | 4 ++-- testing/talos/talos/whitelist.py | 2 +- tools/browsertime/mach_commands.py | 4 ++-- 19 files changed, 23 insertions(+), 22 deletions(-) diff --git a/js/src/devtools/rootAnalysis/t/testlib.py b/js/src/devtools/rootAnalysis/t/testlib.py index cd87917f6594..010f4012f13b 100644 --- a/js/src/devtools/rootAnalysis/t/testlib.py +++ b/js/src/devtools/rootAnalysis/t/testlib.py @@ -55,7 +55,7 @@ class Test(object): cmd = "{CXX} -c {source} -O3 -std=c++11 -fplugin={sixgill} -fplugin-arg-xgill-mangle=1 {options}".format( # NOQA: E501 source=self.infile(source), CXX=self.cfg.cxx, sixgill=self.cfg.sixgill_plugin, - options=options, env=env) + options=options) if self.cfg.verbose: print("Running %s" % cmd) subprocess.check_call(["sh", "-c", cmd]) diff --git a/js/src/tests/test262-export.py b/js/src/tests/test262-export.py index 60d10a2ee770..4c180ed7e147 100755 --- a/js/src/tests/test262-export.py +++ b/js/src/tests/test262-export.py @@ -230,7 +230,7 @@ def mergeMeta(reftest, frontmatter, includes): if info: # Open some space in an existing info text if "info" in frontmatter: - frontmatter["info"] += "\n\n \%" % info + frontmatter["info"] += "\n\n \%s" % info else: frontmatter["info"] = info diff --git a/js/src/vm/jsopcode.py b/js/src/vm/jsopcode.py index 9cc7ee59327b..b49f360ab20d 100644 --- a/js/src/vm/jsopcode.py +++ b/js/src/vm/jsopcode.py @@ -337,15 +337,13 @@ def get_opcodes(dir): '(stack_nuses)'.format( op=op, nuses=nuses, - stack_nuses=stack_nuses, - stack_uses=opcode.stack_uses)) + stack_nuses=stack_nuses)) if ndefs != -1 and stack_ndefs != -1 and ndefs != stack_ndefs: raise Exception('ndefs should match stack notation: {op}: ' '{ndefs} != {stack_ndefs} ' '(stack_ndefs)'.format( op=op, ndefs=ndefs, - stack_ndefs=stack_ndefs, - stack_defs=opcode.stack_defs)) + stack_ndefs=stack_ndefs)) return index, opcodes diff --git a/python/lldbutils/lldbutils/general.py b/python/lldbutils/lldbutils/general.py index ed858adbb4cd..9cbbb97a8fc3 100644 --- a/python/lldbutils/lldbutils/general.py +++ b/python/lldbutils/lldbutils/general.py @@ -38,7 +38,7 @@ class TArraySyntheticChildrenProvider: return None # Ideally we'd use the exception type, but it's unclear what that is # without knowing how to trigger the original exception. - except: # NOQA: E501 + except: # NOQA: E501, E722 pass return None diff --git a/python/mozbuild/mozbuild/configure/__init__.py b/python/mozbuild/mozbuild/configure/__init__.py index c7cd96cdf59b..9da26635dda4 100644 --- a/python/mozbuild/mozbuild/configure/__init__.py +++ b/python/mozbuild/mozbuild/configure/__init__.py @@ -360,6 +360,7 @@ class ConfigureSandbox(dict): else: assert isinstance(logger, logging.Logger) moz_logger = None + @contextmanager def queue_debug(): yield @@ -1154,6 +1155,7 @@ class ConfigureSandbox(dict): func.__defaults__, closure )) + @self.wraps(new_func) def wrapped(*args, **kwargs): if func in self._imports: diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index 4dce465fd079..70eb697d2b1a 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -1481,7 +1481,7 @@ class L10NCommands(MachCommandBase): 'Invoking `mach android archive-geckoview`') self.run_process( [mozpath.join(self.topsrcdir, 'mach'), 'android', - 'archive-geckoview'.format(locale)], + 'archive-geckoview'], append_env=append_env, pass_thru=True, ensure_exit_code=True, diff --git a/python/mozbuild/mozbuild/test/configure/common.py b/python/mozbuild/mozbuild/test/configure/common.py index b176c8c19728..e12ffd65b143 100644 --- a/python/mozbuild/mozbuild/test/configure/common.py +++ b/python/mozbuild/mozbuild/test/configure/common.py @@ -27,7 +27,7 @@ from buildconfig import ( def fake_short_path(path): if sys.platform.startswith('win'): - return '/'.join(p.split(' ', 1)[0] + '~1' if ' 'in p else p + return '/'.join(p.split(' ', 1)[0] + '~1' if ' ' in p else p for p in mozpath.split(path)) return path diff --git a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py index adfb6fc25687..bd90acc122b3 100644 --- a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py +++ b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py @@ -433,7 +433,7 @@ class TestChecksConfigure(unittest.TestCase): self.assertEqual(config, {}) self.assertEqual(out, textwrap.dedent('''\ checking for a... ''' # noqa # trailing whitespace... - ''' + ''' # noqa: E128 DEBUG: a: Trying known-a ERROR: Paths provided to find_program must be a list of strings, not %r ''' % mozpath.dirname(self.OTHER_A))) diff --git a/python/mozbuild/mozbuild/test/test_util.py b/python/mozbuild/mozbuild/test/test_util.py index 69d5601a1adc..6ce780e243bf 100644 --- a/python/mozbuild/mozbuild/test/test_util.py +++ b/python/mozbuild/mozbuild/test/test_util.py @@ -511,6 +511,7 @@ class TestStrictOrderingOnAppendListWithFlagsFactory(unittest.TestCase): class TestMemoize(unittest.TestCase): def test_memoize(self): self._count = 0 + @memoize def wrapped(a, b): self._count += 1 diff --git a/taskcluster/docker/visual-metrics/run-visual-metrics.py b/taskcluster/docker/visual-metrics/run-visual-metrics.py index 826b37140282..e66126a5139e 100644 --- a/taskcluster/docker/visual-metrics/run-visual-metrics.py +++ b/taskcluster/docker/visual-metrics/run-visual-metrics.py @@ -27,6 +27,7 @@ from voluptuous import ALLOW_EXTRA, Required, Schema #: The directory where artifacts from this job will be placed. OUTPUT_DIR = Path("/", "builds", "worker", "artifacts") + #: A job to process through visualmetrics.py @attr.s class Job: diff --git a/taskcluster/taskgraph/actions/cancel.py b/taskcluster/taskgraph/actions/cancel.py index 80bc55b3c79b..c9f6c58b07ca 100644 --- a/taskcluster/taskgraph/actions/cancel.py +++ b/taskcluster/taskgraph/actions/cancel.py @@ -36,6 +36,6 @@ def cancel_action(parameters, graph_config, input, task_group_id, task_id): # A 409 response indicates that this task is past its deadline. It # cannot be cancelled at this time, but it's also not running # anymore, so we can ignore this error. - logger.info('Task is past its deadline and cannot be cancelled.'.format(task_id)) + logger.info('Task {} is past its deadline and cannot be cancelled.'.format(task_id)) return raise diff --git a/taskcluster/taskgraph/transforms/job/common.py b/taskcluster/taskgraph/transforms/job/common.py index 90ce40689bc4..bf701446b138 100644 --- a/taskcluster/taskgraph/transforms/job/common.py +++ b/taskcluster/taskgraph/transforms/job/common.py @@ -198,8 +198,7 @@ def add_tooltool(config, job, taskdesc, internal=False): """ if job['worker']['implementation'] in ('docker-worker',): - level = config.params['level'] - add_cache(job, taskdesc, 'tooltool-cache'.format(level), + add_cache(job, taskdesc, 'tooltool-cache', '{workdir}/tooltool-cache'.format(**job['run'])) taskdesc['worker'].setdefault('env', {}).update({ diff --git a/taskcluster/taskgraph/transforms/job/debian_package.py b/taskcluster/taskgraph/transforms/job/debian_package.py index adf375fca1bc..c1e152de9832 100644 --- a/taskcluster/taskgraph/transforms/job/debian_package.py +++ b/taskcluster/taskgraph/transforms/job/debian_package.py @@ -183,8 +183,6 @@ def docker_worker_debian_package(config, job, taskdesc): .format( root_url=get_root_url(False), package=package, - snapshot=run['snapshot'], - dist=run['dist'], src_url=src_url, src_file=src_file, src_sha256=src_sha256, diff --git a/taskcluster/taskgraph/util/partners.py b/taskcluster/taskgraph/util/partners.py index 453891c2f4f4..4a3abd7aac71 100644 --- a/taskcluster/taskgraph/util/partners.py +++ b/taskcluster/taskgraph/util/partners.py @@ -384,7 +384,7 @@ def get_ftp_platform(platform): elif platform.startswith('linux64'): return 'linux-x86_64' else: - raise ValueError('Unimplemented platform %s'.format(platform)) + raise ValueError('Unimplemented platform {}'.format(platform)) # Ugh diff --git a/testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py b/testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py index ad24a490ca2d..30251f45552a 100644 --- a/testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py +++ b/testing/mozbase/mozlog/mozlog/pytest_mozlog/plugin.py @@ -109,7 +109,7 @@ class MozLog(object): # For skips, longrepr is a tuple of (file, lineno, reason) message = report.longrepr[-1] else: - raise ValueError("Unable to convert longrepr to message:\ntype %s\nfields:" % + raise ValueError("Unable to convert longrepr to message:\ntype %s\nfields: %s" % (longrepr.__class__, dir(longrepr))) if status != expected or expected != 'PASS': self.results[test] = (status, expected, message, stack) diff --git a/testing/mozbase/mozlog/tests/test_formatters.py b/testing/mozbase/mozlog/tests/test_formatters.py index 1d34c867fba2..3dd60d9dc911 100644 --- a/testing/mozbase/mozlog/tests/test_formatters.py +++ b/testing/mozbase/mozlog/tests/test_formatters.py @@ -319,6 +319,7 @@ def test_fail(name, opts, expected): print(result) assert result == expected + @pytest.mark.parametrize("name,opts,expected", FORMATS['PRECONDITION_FAILED'], ids=ids('PRECONDITION_FAILED')) def test_precondition_failed(name, opts, expected): @@ -341,6 +342,7 @@ def test_precondition_failed(name, opts, expected): print(result) assert result == expected + @pytest.mark.parametrize("name,opts,expected", FORMATS['KNOWN-INTERMITTENT'], ids=ids('KNOWN-INTERMITTENT')) def test_known_intermittent(name, opts, expected): diff --git a/testing/mozbase/mozrunner/mozrunner/base/device.py b/testing/mozbase/mozrunner/mozrunner/base/device.py index 38c1a68170b6..0c7d091f2855 100644 --- a/testing/mozbase/mozrunner/mozrunner/base/device.py +++ b/testing/mozbase/mozrunner/mozrunner/base/device.py @@ -100,7 +100,7 @@ class DeviceRunner(BaseRunner): self.app_ctx.device.pkill(self.app_ctx.remote_process, sig=sig) if self.wait(timeout) is None and sig is not None: - print("timed out waiting for '%s' process to exit, trying " + print("timed out waiting for '{}' process to exit, trying " "without signal {}".format( self.app_ctx.remote_process, sig)) @@ -108,7 +108,7 @@ class DeviceRunner(BaseRunner): # restart the process self.app_ctx.stop_application() if self.wait(timeout) is None: - print("timed out waiting for '%s' process to exit".format( + print("timed out waiting for '{}' process to exit".format( self.app_ctx.remote_process)) @property diff --git a/testing/talos/talos/whitelist.py b/testing/talos/talos/whitelist.py index 816462d8835b..e691113d9a99 100644 --- a/testing/talos/talos/whitelist.py +++ b/testing/talos/talos/whitelist.py @@ -117,7 +117,7 @@ class Whitelist: if filename not in errors: errors[filename] = [] - errors[filename].append("Duration %s > %S" + errors[filename].append("Duration %s > %s" % (row_value[file_duration_index]), DEFAULT_DURATION) return errors diff --git a/tools/browsertime/mach_commands.py b/tools/browsertime/mach_commands.py index 2cd423c2a136..5427fb0b656c 100644 --- a/tools/browsertime/mach_commands.py +++ b/tools/browsertime/mach_commands.py @@ -270,8 +270,8 @@ class MachBrowsertime(MachCommandBase): 'to {new_upstream_url}') if not re.search('/tarball/[a-f0-9]{40}$', new_upstream_url): - raise ValueError("New upstream URL does not end with /tarball/[a-f0-9]{40}: '{}'" - .format(new_upstream_url)) + raise ValueError("New upstream URL does not end with /tarball/[a-f0-9]{40}: '%s'" + % new_upstream_url) with open(package_json_path) as f: existing_body = json.loads(f.read(), object_pairs_hook=collections.OrderedDict)