From 4cd0408f6e8c47aa9d4bae4af7e48f82fc074849 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Fri, 17 Jul 2020 09:23:34 -0700 Subject: [PATCH 1/2] Fix a bunch of python lint errors --- benchmark/scripts/compare_perf_tests.py | 4 ++-- benchmark/scripts/perf_test_driver/perf_test_driver.py | 4 ++-- test/Inputs/not.py | 2 +- unittests/Reflection/RemoteMirrorInterop/test.py | 6 +++--- utils/bug_reducer/bug_reducer/list_reducer.py | 4 ++-- utils/bug_reducer/bug_reducer/opt_bug_reducer.py | 4 ++-- utils/bug_reducer/bug_reducer/swift_tools.py | 4 ++-- utils/line-directive | 4 ++-- utils/protocol_graph.py | 4 ++-- utils/update_checkout/update_checkout/update_checkout.py | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/benchmark/scripts/compare_perf_tests.py b/benchmark/scripts/compare_perf_tests.py index ef461dbde2aa6..57ad939720820 100755 --- a/benchmark/scripts/compare_perf_tests.py +++ b/benchmark/scripts/compare_perf_tests.py @@ -551,9 +551,9 @@ def compare(name): comparisons = list(map(compare, comparable_tests)) - def partition(l, p): + def partition(items, p): return functools.reduce( - lambda x, y: x[not p(y)].append(y) or x, l, ([], []) + lambda x, y: x[not p(y)].append(y) or x, items, ([], []) ) decreased, not_decreased = partition( diff --git a/benchmark/scripts/perf_test_driver/perf_test_driver.py b/benchmark/scripts/perf_test_driver/perf_test_driver.py index 599d28eafb7d6..c662345333682 100644 --- a/benchmark/scripts/perf_test_driver/perf_test_driver.py +++ b/benchmark/scripts/perf_test_driver/perf_test_driver.py @@ -130,8 +130,8 @@ def run_for_opt_level(self, binary, opt_level, test_filter): print("testing driver at path: %s" % binary) names = [] output = subprocess.check_output([binary, "--list"], universal_newlines=True) - for l in output.split("\n")[1:]: - m = BENCHMARK_OUTPUT_RE.match(l) + for line in output.split("\n")[1:]: + m = BENCHMARK_OUTPUT_RE.match(line) if m is None: continue names.append(m.group(1)) diff --git a/test/Inputs/not.py b/test/Inputs/not.py index 6e1c8b8270968..4e8163b257e68 100644 --- a/test/Inputs/not.py +++ b/test/Inputs/not.py @@ -10,5 +10,5 @@ isPosix = (sys.platform != "win32") subprocess.check_call(shlex.split(sys.argv[1], posix=isPosix)) sys.exit(1) -except subprocess.CalledProcessError as e: +except subprocess.CalledProcessError: sys.exit(0) diff --git a/unittests/Reflection/RemoteMirrorInterop/test.py b/unittests/Reflection/RemoteMirrorInterop/test.py index a18ca81c6ef63..9fa771ab95a28 100755 --- a/unittests/Reflection/RemoteMirrorInterop/test.py +++ b/unittests/Reflection/RemoteMirrorInterop/test.py @@ -56,9 +56,9 @@ def libPath(path): for i in range(len(swiftcs) + 1): for localMirrorlibs in itertools.combinations(mirrorlibs, i): for i, arg in enumerate(absoluteArgs): - print 'Testing', arg, 'with mirror libs:' - for l in localMirrorlibs: - print '\t', l + print('Testing', arg, 'with mirror libs:') + for lib in localMirrorlibs: + print('\t', lib) callArgs = ['/tmp/test'] dylibPath = os.path.join('/tmp', 'libtest' + str(i) + '.dylib') callArgs.append(dylibPath) diff --git a/utils/bug_reducer/bug_reducer/list_reducer.py b/utils/bug_reducer/bug_reducer/list_reducer.py index d1f9f72abd0f9..0d15dfa66ec08 100644 --- a/utils/bug_reducer/bug_reducer/list_reducer.py +++ b/utils/bug_reducer/bug_reducer/list_reducer.py @@ -12,8 +12,8 @@ class ListReducer(object): """Reduce lists of objects. Inspired by llvm bugpoint""" - def __init__(self, l): - self.target_list = l + def __init__(self, lst): + self.target_list = lst # Maximal number of allowed splitting iterations, # before the elements are randomly shuffled. self.max_iters_without_progress = 3 diff --git a/utils/bug_reducer/bug_reducer/opt_bug_reducer.py b/utils/bug_reducer/bug_reducer/opt_bug_reducer.py index ca8ffd82b8166..b184063f8ae23 100644 --- a/utils/bug_reducer/bug_reducer/opt_bug_reducer.py +++ b/utils/bug_reducer/bug_reducer/opt_bug_reducer.py @@ -16,8 +16,8 @@ class ReduceMiscompilingPasses(list_reducer.ListReducer): - def __init__(self, l, invoker): - list_reducer.ListReducer.__init__(self, l) + def __init__(self, lst, invoker): + list_reducer.ListReducer.__init__(self, lst) self.invoker = invoker def run_test(self, prefix, suffix): diff --git a/utils/bug_reducer/bug_reducer/swift_tools.py b/utils/bug_reducer/bug_reducer/swift_tools.py index c6ac2fc73cf4b..a657c0635b89d 100644 --- a/utils/bug_reducer/bug_reducer/swift_tools.py +++ b/utils/bug_reducer/bug_reducer/swift_tools.py @@ -236,7 +236,7 @@ def get_symbols(self, input_file): cmdline = self.base_args(emit_sib=False) cmdline.append(input_file) output = subprocess.check_output(cmdline) - for l in output.split("\n")[:-1]: - t = tuple(l.split(" ")) + for line in output.split("\n")[:-1]: + t = tuple(line.split(" ")) assert(len(t) == 2) yield t diff --git a/utils/line-directive b/utils/line-directive index 4d22240a48595..56b688e28b6af 100755 --- a/utils/line-directive +++ b/utils/line-directive @@ -714,8 +714,8 @@ def run(): break output = input - def decode_match(p, l): - m = p.match(l) + def decode_match(p, line): + m = p.match(line) if m is None: return () file, line_num = map_line_to_source_file( diff --git a/utils/protocol_graph.py b/utils/protocol_graph.py index 3dc0304ea5dcb..41a6975149f33 100644 --- a/utils/protocol_graph.py +++ b/utils/protocol_graph.py @@ -186,8 +186,8 @@ def parse_protocol(m): else '' label = node if len(requirements + generics) == 0 else ( - '\n\n
' + - '\n%s%s%s
\n%s\n
\n' % ( + ('\n\n
' + + '\n%s%s%s
\n%s\n
\n') % ( node, '\n'.join('%s' % r for r in requirements), divider, diff --git a/utils/update_checkout/update_checkout/update_checkout.py b/utils/update_checkout/update_checkout/update_checkout.py index a13b626443ffe..78e447b299ec6 100755 --- a/utils/update_checkout/update_checkout/update_checkout.py +++ b/utils/update_checkout/update_checkout/update_checkout.py @@ -37,9 +37,9 @@ def run_parallel(fn, pool_args, n_processes=0): parallel implementation. """ - def init(l): + def init(lck): global lock - lock = l + lock = lck if n_processes == 0: n_processes = cpu_count() * 2 From 538c009b71ad2b85a3db38c4d10aaf9ae0c099cd Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Fri, 17 Jul 2020 11:26:20 -0700 Subject: [PATCH 2/2] adjust indentation --- utils/protocol_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/protocol_graph.py b/utils/protocol_graph.py index 41a6975149f33..f237f654b9013 100644 --- a/utils/protocol_graph.py +++ b/utils/protocol_graph.py @@ -187,7 +187,7 @@ def parse_protocol(m): label = node if len(requirements + generics) == 0 else ( ('\n\n
' + - '\n%s%s%s
\n%s\n
\n') % ( + '\n%s%s%s\n') % ( node, '\n'.join('%s' % r for r in requirements), divider,