Skip to content

Commit fca1834

Browse files
Merge pull request #2631 from practicalswift/pep8-fixes-20160520
[gardening] Fix various PEP-8 violations.
2 parents 15be410 + ac15a59 commit fca1834

File tree

6 files changed

+65
-66
lines changed

6 files changed

+65
-66
lines changed

Diff for: .pep8

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[flake8]
2-
filename = *.py,80+-check,Benchmark_Driver,Benchmark_DTrace.in,Benchmark_GuardMalloc.in,Benchmark_RuntimeLeaksRunner.in,build-script,gyb,line-directive,mock-distcc,ns-html2rst,recursive-lipo,rth,split-generated-tests,submit-benchmark-results,update-checkout,viewcfg,backtrace-check
2+
filename = *.py,80+-check,Benchmark_Driver,Benchmark_DTrace.in,Benchmark_GuardMalloc.in,Benchmark_RuntimeLeaksRunner.in,build-script,check-incremental,gyb,line-directive,mock-distcc,ns-html2rst,recursive-lipo,rth,split-generated-tests,submit-benchmark-results,update-checkout,viewcfg,backtrace-check

Diff for: utils/check-incremental

+51-52
Original file line numberDiff line numberDiff line change
@@ -19,74 +19,73 @@
1919
#
2020
# ----------------------------------------------------------------------------
2121

22-
import subprocess
2322
import os
23+
import subprocess
2424
import sys
25-
import time
2625

2726

2827
def main():
29-
verbose = False
30-
num_iterations = 4
31-
32-
write_obj_file = False
33-
next_arg_is_output = False
34-
compare_time = True
35-
output_file = None
36-
37-
for arg in sys.argv:
38-
if next_arg_is_output:
39-
output_file = arg
40-
next_arg_is_output = False
41-
elif arg == '-c':
42-
write_obj_file = True
43-
elif arg == '-disable-incremental-llvm-codegen':
44-
compare_time = False
45-
elif arg == '-o':
46-
next_arg_is_output = True
47-
48-
if not write_obj_file or output_file is None:
49-
return
50-
51-
new_args = sys.argv[1:]
52-
subprocess.check_call(new_args)
28+
verbose = False
29+
num_iterations = 4
30+
31+
write_obj_file = False
32+
next_arg_is_output = False
33+
compare_time = True
34+
output_file = None
35+
36+
for arg in sys.argv:
37+
if next_arg_is_output:
38+
output_file = arg
39+
next_arg_is_output = False
40+
elif arg == '-c':
41+
write_obj_file = True
42+
elif arg == '-disable-incremental-llvm-codegen':
43+
compare_time = False
44+
elif arg == '-o':
45+
next_arg_is_output = True
46+
47+
if not write_obj_file or output_file is None:
48+
return
49+
50+
new_args = sys.argv[1:]
51+
subprocess.check_call(new_args)
5352

54-
if verbose:
55-
print "Reference compilation of " + output_file + ":"
53+
if verbose:
54+
print "Reference compilation of " + output_file + ":"
5655

57-
reference_md5 = subprocess.check_output(["md5", "-q", output_file])
58-
reference_time = os.path.getmtime(output_file)
56+
reference_md5 = subprocess.check_output(["md5", "-q", output_file])
57+
reference_time = os.path.getmtime(output_file)
5958

60-
if verbose:
61-
print " time = {}".format(reference_time)
62-
print " md5 = " + reference_md5
59+
if verbose:
60+
print " time = {}".format(reference_time)
61+
print " md5 = " + reference_md5
6362

64-
subprocess.check_call(["cp", output_file, output_file + ".ref.o"])
63+
subprocess.check_call(["cp", output_file, output_file + ".ref.o"])
6564

66-
for iteration in range(0, num_iterations):
65+
for iteration in range(0, num_iterations):
6766

68-
if verbose:
69-
print "Iteration {}:".format(iteration)
67+
if verbose:
68+
print "Iteration {}:".format(iteration)
7069

71-
subprocess.check_call(new_args)
70+
subprocess.check_call(new_args)
7271

73-
second_md5 = subprocess.check_output(["md5", "-q", output_file])
74-
second_time = os.path.getmtime(output_file)
72+
second_md5 = subprocess.check_output(["md5", "-q", output_file])
73+
second_time = os.path.getmtime(output_file)
7574

76-
if verbose:
77-
print " time = {}".format(second_time)
78-
print " md5 = " + second_md5
75+
if verbose:
76+
print " time = {}".format(second_time)
77+
print " md5 = " + second_md5
7978

80-
# This is the most important check: is the output file exactly the same.
81-
if reference_md5 != second_md5:
82-
sys.exit("non-determinism when generating: " + output_file)
79+
# This is the most important check: is the output file exactly the
80+
# same.
81+
if reference_md5 != second_md5:
82+
sys.exit("non-determinism when generating: " + output_file)
8383

84-
# This is the bonus check: does the compiler not re-write the output file.
85-
# (For compilations < 1sec this check may succeed even if the file was
86-
# overwritten).
87-
if compare_time and reference_time != second_time:
88-
sys.exit("file re-written: " + output_file)
84+
# This is the bonus check: does the compiler not re-write the output
85+
# file. (For compilations < 1sec this check may succeed even if the
86+
# file was overwritten).
87+
if compare_time and reference_time != second_time:
88+
sys.exit("file re-written: " + output_file)
8989

9090

9191
main()
92-

Diff for: utils/gyb_stdlib_support.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ def defaultIndicesForTraversal(traversal): # noqa (N802)
4949
assert False, 'unknown traversal'
5050

5151

52-
def documentationNameForTraversal(traversal):
53-
if traversal == 'Forward':
54-
return 'collection'
52+
def documentationNameForTraversal(traversal): # noqa (N802)
53+
if traversal == 'Forward':
54+
return 'collection'
5555
if traversal == 'Bidirectional':
56-
return 'bidirectional collection'
56+
return 'bidirectional collection'
5757
if traversal == 'RandomAccess':
58-
return 'random-access collection'
58+
return 'random-access collection'
5959
assert False, 'unknown traversal'

Diff for: utils/swift_build_support/swift_build_support/cache_util.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ def reify(func):
4747
4848
Note: Support method that takes no arguments.
4949
"""
50-
class wrapper(object):
50+
class Wrapper(object):
5151
def __get__(self, obj, objtype=None):
5252
if obj is None:
5353
return self
5454
result = func(obj)
5555
setattr(obj, func.__name__, result)
5656
return result
5757

58-
return update_wrapper(wrapper(), func)
58+
return update_wrapper(Wrapper(), func)

Diff for: utils/swift_build_support/tests/test_cmake.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import unittest
1313
from argparse import Namespace
1414

15-
from swift_build_support.cmake import CMakeOptions, CMake
15+
from swift_build_support.cmake import CMake, CMakeOptions
1616
from swift_build_support.toolchain import host_toolchain
1717

1818

Diff for: utils/swift_build_support/tests/test_workspace.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,29 +63,29 @@ def create_basic_args(self, generator, variant, assertions):
6363
swift_assertions=assertions,
6464
swift_stdlib_assertions=assertions)
6565

66-
def test_Ninja_ReleaseAssert(self):
66+
def test_Ninja_ReleaseAssert(self): # noqa (N802 function name should be lowercase)
6767
# build-script -R
6868
args = self.create_basic_args(
6969
"Ninja", variant="Release", assertions=True)
7070
self.assertEqual(compute_build_subdir(args),
7171
"Ninja-ReleaseAssert")
7272

73-
def test_Ninja_Release(self):
73+
def test_Ninja_Release(self): # noqa (N802 function name should be lowercase)
7474
# build-script -R --no-assertions
7575
args = self.create_basic_args(
7676
"Ninja", variant="Release", assertions=False)
7777
self.assertEqual(compute_build_subdir(args),
7878
"Ninja-Release")
7979

80-
def test_Ninja_Release_stdlib_ReleaseAssert(self):
80+
def test_Ninja_Release_stdlib_ReleaseAssert(self): # noqa (N802 function name should be lowercase)
8181
# build-script -R --no-assertions --swift-stdlib-assertions
8282
args = self.create_basic_args(
8383
"Ninja", variant="Release", assertions=False)
8484
args.swift_stdlib_assertions = True
8585
self.assertEqual(compute_build_subdir(args),
8686
"Ninja-Release+stdlib-ReleaseAssert")
8787

88-
def test_Ninja_mixed(self):
88+
def test_Ninja_mixed(self): # noqa (N802 function name should be lowercase)
8989
# build-script -R --no-assertions
9090
# --llvm-build-variant=RelWithDebInfo
9191
# --swift-analyze-code-coverage="merged"
@@ -99,7 +99,7 @@ def test_Ninja_mixed(self):
9999
"Ninja+cmark-Release+llvm-RelWithDebInfo"
100100
"+swift-ReleaseCoverage+stdlib-ReleaseAssert")
101101

102-
def test_Unix_Makefiles_ReleaseAssert(self):
102+
def test_Unix_Makefiles_ReleaseAssert(self): # noqa (N802 function name should be lowercase)
103103
# build-script -R -m
104104
args = self.create_basic_args(
105105
"Unix Makefiles", variant="Release", assertions=True)

0 commit comments

Comments
 (0)