diff --git a/.pep8 b/.pep8 index 5c9a43a5399d3..70cce09fa442b 100644 --- a/.pep8 +++ b/.pep8 @@ -1,3 +1,2 @@ [flake8] filename = *.py,Benchmark_Driver,Benchmark_DTrace.in,Benchmark_GuardMalloc.in,Benchmark_RuntimeLeaksRunner.in,build-script,gyb,line-directive,ns-html2rst,recursive-lipo,rth,submit-benchmark-results,update-checkout,viewcfg -max-line-length = 80 diff --git a/benchmark/scripts/Benchmark_DTrace.in b/benchmark/scripts/Benchmark_DTrace.in index 4cbd1702d26ae..8f78fee9b33e4 100644 --- a/benchmark/scripts/Benchmark_DTrace.in +++ b/benchmark/scripts/Benchmark_DTrace.in @@ -1,6 +1,6 @@ #!/usr/bin/env python -# ===--- Benchmark_DTrace.in ----------------------------------------------===// +# ===--- Benchmark_DTrace.in ---------------------------------------------===// # # This source file is part of the Swift.org open source project # @@ -10,7 +10,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// import argparse import os diff --git a/benchmark/scripts/Benchmark_Driver b/benchmark/scripts/Benchmark_Driver index bbf4ef72bccfe..aad5f533ace57 100755 --- a/benchmark/scripts/Benchmark_Driver +++ b/benchmark/scripts/Benchmark_Driver @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# ===--- Benchmark_Driver -------------------------------------------------===// +# ===--- Benchmark_Driver ------------------------------------------------===// # # This source file is part of the Swift.org open source project # @@ -11,7 +11,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// import argparse import datetime @@ -109,10 +109,10 @@ def instrument_test(driver_path, test, num_samples): avg_test_output[i] = int(round(avg_test_output[i] / float(len(test_outputs)))) avg_test_output[num_samples_index] = num_samples - avg_test_output[min_index] = min(test_outputs, - key=lambda x: int(x[min_index]))[min_index] - avg_test_output[max_index] = max(test_outputs, - key=lambda x: int(x[max_index]))[max_index] + avg_test_output[min_index] = min( + test_outputs, key=lambda x: int(x[min_index]))[min_index] + avg_test_output[max_index] = max( + test_outputs, key=lambda x: int(x[max_index]))[max_index] avg_test_output = map(str, avg_test_output) return avg_test_output diff --git a/benchmark/scripts/Benchmark_GuardMalloc.in b/benchmark/scripts/Benchmark_GuardMalloc.in index 2e6cb600745d7..1b03e132de9c5 100644 --- a/benchmark/scripts/Benchmark_GuardMalloc.in +++ b/benchmark/scripts/Benchmark_GuardMalloc.in @@ -1,6 +1,6 @@ #!/usr/bin/env python -# ===--- Benchmark_GuardMalloc.in -----------------------------------------===// +# ===--- Benchmark_GuardMalloc.in ----------------------------------------===// # # This source file is part of the Swift.org open source project # @@ -10,7 +10,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// import os import subprocess diff --git a/benchmark/scripts/Benchmark_RuntimeLeaksRunner.in b/benchmark/scripts/Benchmark_RuntimeLeaksRunner.in index 0acb0f8d13da5..15f4ac084cf83 100644 --- a/benchmark/scripts/Benchmark_RuntimeLeaksRunner.in +++ b/benchmark/scripts/Benchmark_RuntimeLeaksRunner.in @@ -1,6 +1,6 @@ #!/usr/bin/env python -# ===--- Benchmark_RuntimeLeaksRunner.in ----------------------------------===// +# ===--- Benchmark_RuntimeLeaksRunner.in ---------------------------------===// # # This source file is part of the Swift.org open source project # @@ -10,7 +10,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// import json import os @@ -26,8 +26,8 @@ import perf_test_driver # noqa (E402 module level import not at top of file) XFAIL_LIST = [ ] -# Global objective-c classes created by various frameworks. We do not care about -# these. +# Global objective-c classes created by various frameworks. We do not care +# about these. IGNORABLE_GLOBAL_OBJC_CLASSES = set([ '__NSPlaceholderDate', 'NSCache', diff --git a/benchmark/scripts/compare_perf_tests.py b/benchmark/scripts/compare_perf_tests.py index 6b740cda5106b..bc9940db560e9 100755 --- a/benchmark/scripts/compare_perf_tests.py +++ b/benchmark/scripts/compare_perf_tests.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# ===--- compare_perf_tests.py --------------------------------------------===// +# ===--- compare_perf_tests.py -------------------------------------------===// # # This source file is part of the Swift.org open source project # @@ -11,7 +11,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// # e.g. # repeat.sh 3 tot/bin/Benchmark_Driver run -o -O > tot.O.times @@ -136,7 +136,8 @@ def compare_scores(key, score1, worstsample1, score2, worstsample2, runs, num): if bestscore1 != 0 and bestscore2 != 0: print(("%+.1f%%" % - (((float(bestscore2) / bestscore1) - 1) * 100)).rjust(9), end="") + (((float(bestscore2) / bestscore1) - 1) * 100)).rjust(9), + end="") if ShowSpeedup: Num, Den = float(bestscore2), float(bestscore1) if IsTime: diff --git a/benchmark/scripts/generate_harness/generate_harness.py b/benchmark/scripts/generate_harness/generate_harness.py index e44056b466b6d..a4c7a0a52f7f1 100644 --- a/benchmark/scripts/generate_harness/generate_harness.py +++ b/benchmark/scripts/generate_harness/generate_harness.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# ===--- generate_harness.py ----------------------------------------------===// +# ===--- generate_harness.py ---------------------------------------------===// # # This source file is part of the Swift.org open source project # @@ -10,7 +10,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// # Generate CMakeLists.txt and utils/main.swift from templates. diff --git a/benchmark/scripts/perf_test_driver/perf_test_driver.py b/benchmark/scripts/perf_test_driver/perf_test_driver.py index 27f0701333461..5e9e3b115c0a2 100644 --- a/benchmark/scripts/perf_test_driver/perf_test_driver.py +++ b/benchmark/scripts/perf_test_driver/perf_test_driver.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# ===--- perf_test_driver.py ----------------------------------------------===// +# ===--- perf_test_driver.py ---------------------------------------------===// # # This source file is part of the Swift.org open source project # @@ -10,7 +10,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// import multiprocessing import os diff --git a/benchmark/utils/convertToJSON.py b/benchmark/utils/convertToJSON.py index 468df2717626b..e5f9053df3828 100644 --- a/benchmark/utils/convertToJSON.py +++ b/benchmark/utils/convertToJSON.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -# ===--- convertToJSON.py -------------------------------------------------===// +# ===--- convertToJSON.py ------------------------------------------------===// # # This source file is part of the Swift.org open source project # @@ -10,7 +10,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// # This script converts results from pre-commit benchmark tests to JSON. # Usage: PrecommitBench_O | convertToJSON.py diff --git a/docs/conf.py b/docs/conf.py index 47da3583a71d1..5769c1c66f54a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,8 @@ # # Swift documentation build configuration file. # -# This file is execfile()d with the current directory set to its containing dir. +# This file is execfile()d with the current directory set to its containing +# dir. # # Note that not all possible configuration values are present in this # autogenerated file. @@ -23,8 +24,8 @@ # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo'] # Add any paths that contain templates here, relative to this directory. @@ -66,7 +67,8 @@ # directories to ignore when looking for source files. exclude_patterns = ['_build'] -# The reST default role (used for this markup: `text`) to use for all documents. +# The reST default role (used for this markup: `text`) to use for all +# documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. @@ -190,7 +192,8 @@ } # Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). +# (source start file, target name, title, author, documentclass +# [howto/manual]). latex_documents = [ ('contents', 'Swift.tex', u'Swift Documentation', u'LLVM project', 'manual'), diff --git a/utils/GYBUnicodeDataUtils.py b/utils/GYBUnicodeDataUtils.py index 7f1c38b30b876..9fd14857dfe56 100644 --- a/utils/GYBUnicodeDataUtils.py +++ b/utils/GYBUnicodeDataUtils.py @@ -1,4 +1,4 @@ -# ===--- GYBUnicodeDataUtils.py -----------------------*- coding: utf-8 -*-===// +# ===--- GYBUnicodeDataUtils.py ----------------------*- coding: utf-8 -*-===// # # This source file is part of the Swift.org open source project # @@ -105,8 +105,8 @@ def __init__(self, grapheme_break_property_file_name): for cp in range(0, 0x110000): self.property_values[cp] = self.get_default_value() - for start_code_point, end_code_point, val in self.property_value_ranges: - for cp in range(start_code_point, end_code_point + 1): + for start_code_pt, end_code_pt, val in self.property_value_ranges: + for cp in range(start_code_pt, end_code_pt + 1): self.property_values[cp] = val def get_default_value(self): @@ -320,7 +320,8 @@ def get_value(self, cp): if cp <= 0xffff: data_block_index = self.bmp_lookup[ self.get_bmp_first_level_index(cp)] - return self.bmp_data[data_block_index][self.get_bmp_data_offset(cp)] + return self.bmp_data[data_block_index][ + self.get_bmp_data_offset(cp)] else: second_lookup_index = self.supp_lookup1[ self.get_supp_first_level_index(cp)] @@ -552,14 +553,14 @@ def _convert_line(line): pass else: code_point = int(token, 16) - # Tests from Unicode spec have isolated surrogates in them. Our - # segmentation algorithm works on UTF-8 sequences, so encoding a - # surrogate would produce an invalid code unit sequence. - # Instead of trying to emulate the maximal subpart algorithm for - # inserting U+FFFD in Python, we just replace every isolated - # surrogate with U+200B, which also has Grapheme_Cluster_Break - # equal to 'Control' and test separately that we handle - # ill-formed UTF-8 sequences. + # Tests from Unicode spec have isolated surrogates in them. + # Our segmentation algorithm works on UTF-8 sequences, so + # encoding a surrogate would produce an invalid code unit + # sequence. Instead of trying to emulate the maximal subpart + # algorithm for inserting U+FFFD in Python, we just replace + # every isolated surrogate with U+200B, which also has + # Grapheme_Cluster_Break equal to 'Control' and test + # separately that we handle ill-formed UTF-8 sequences. if code_point >= 0xd800 and code_point <= 0xdfff: code_point = 0x200b code_point = (b'\U%(cp)08x' % {b'cp': code_point}).decode( @@ -613,14 +614,14 @@ def _convert_line(line): pass else: code_point = int(token, 16) - # Tests from Unicode spec have isolated surrogates in them. Our + # Tests from Unicode spec have isolated surrogates in them. Our # segmentation algorithm works on UTF-16 sequences, so encoding # a surrogate would produce an invalid code unit sequence. - # Instead of trying to emulate the maximal subpart algorithm for - # inserting U+FFFD in Python, we just replace every isolated - # surrogate with U+200B, which also has Grapheme_Cluster_Break - # equal to 'Control' and test separately that we handle - # ill-formed UTF-8 sequences. + # Instead of trying to emulate the maximal subpart algorithm + # for inserting U+FFFD in Python, we just replace every + # isolated surrogate with U+200B, which also has + # Grapheme_Cluster_Break equal to 'Control' and test separately + # that we handle ill-formed UTF-8 sequences. if code_point >= 0xd800 and code_point <= 0xdfff: code_point = 0x200b test += [code_point] diff --git a/utils/SwiftIntTypes.py b/utils/SwiftIntTypes.py index 2641715c3d7b2..10c034f08bf69 100644 --- a/utils/SwiftIntTypes.py +++ b/utils/SwiftIntTypes.py @@ -1,4 +1,4 @@ -# ===--- SwiftIntTypes.py -----------------------------*- coding: utf-8 -*-===// +# ===--- SwiftIntTypes.py ----------------------------*- coding: utf-8 -*-===// # # This source file is part of the Swift.org open source project # diff --git a/utils/build-script b/utils/build-script index 6ca08689c7ac1..858ada5ab9ea8 100755 --- a/utils/build-script +++ b/utils/build-script @@ -284,7 +284,8 @@ To use it, specify the '--preset=' argument: [~/src/s]$ ./swift/utils/build-script --preset=ds ./swift/utils/build-script: using preset 'ds', which expands to - ./swift/utils/build-script --release --debug-swift --debug-swift-stdlib --test + ./swift/utils/build-script --release --debug-swift --debug-swift-stdlib \ + --test --build-subdir=ds -- ... diff --git a/utils/cmpcodesize/cmpcodesize/compare.py b/utils/cmpcodesize/cmpcodesize/compare.py index ee4a35da6844b..5395767ad114a 100644 --- a/utils/cmpcodesize/cmpcodesize/compare.py +++ b/utils/cmpcodesize/cmpcodesize/compare.py @@ -1,4 +1,4 @@ -# ====--- compare.py - Compare built products' sizes --*- coding: utf-8 -*-===// +# ====--- compare.py - Compare built products' sizes -*- coding: utf-8 -*-===// # # This source file is part of the Swift.org open source project # diff --git a/utils/cmpcodesize/cmpcodesize/main.py b/utils/cmpcodesize/cmpcodesize/main.py index 94a5eb9c02dd5..77aa9fc366b37 100644 --- a/utils/cmpcodesize/cmpcodesize/main.py +++ b/utils/cmpcodesize/cmpcodesize/main.py @@ -38,9 +38,9 @@ def main(): Environment variables: SWIFT_NEW_BUILDDIR The new build-dir -E.g. $HOME/swiftnew/build/Ninja-ReleaseAssert+stdlib-Release/swift-macosx-x86_64 +E.g. .../swiftnew/build/Ninja-ReleaseAssert+stdlib-Release/swift-macosx-x86_64 SWIFT_OLD_BUILDDIR The old build-dir -E.g. $HOME/swiftold/build/Ninja-ReleaseAssert+stdlib-Release/swift-macosx-x86_64 +E.g. .../swiftold/build/Ninja-ReleaseAssert+stdlib-Release/swift-macosx-x86_64 How to specify files: 1) No files: diff --git a/utils/gyb.py b/utils/gyb.py index 3a862339f0ecb..ff485ae88b66c 100755 --- a/utils/gyb.py +++ b/utils/gyb.py @@ -360,7 +360,8 @@ def code_starts_with_dedent_keyword(source_lines): False >>> code_starts_with_dedent_keyword(split_lines('except ifSomethingElse:')) True - >>> code_starts_with_dedent_keyword(split_lines('\n# comment\nelse: # yes')) + >>> code_starts_with_dedent_keyword( + split_lines('\n# comment\nelse: # yes')) True """ token_text = None @@ -449,7 +450,7 @@ def token_generator(self, base_tokens): ... '''% for x in [1, 2, 3]: ... % if x == 1: ... literal1 - ... % elif x > 1: # add an output line after this line to fix the bug + ... % elif x > 1: # add an output line after this line to fix bug ... % if x == 2: ... literal2 ... % end @@ -544,7 +545,8 @@ def next_token(self): class ExecutionContext(object): """State we pass around during execution of a template""" - def __init__(self, line_directive='// ###sourceLocation', **local_bindings): + def __init__(self, line_directive='// ###sourceLocation', + **local_bindings): self.local_bindings = local_bindings self.line_directive = line_directive self.local_bindings['__context__'] = self @@ -753,7 +755,7 @@ def parse_template(filename, text=None): { if x == 1: __children__[0].execute(__context__) - elif x > 1: # add output line after this line to fix the bug + elif x > 1: # add output line after this line to fix bug __children__[1].execute(__context__) } [ diff --git a/utils/protocol_graph.py b/utils/protocol_graph.py index 8e47c525686a6..8220257b56b69 100644 --- a/utils/protocol_graph.py +++ b/utils/protocol_graph.py @@ -1,4 +1,4 @@ -# ===--- protocol_graph.py ----------------------------*- coding: utf-8 -*-===// +# ===--- protocol_graph.py ---------------------------*- coding: utf-8 -*-===// # # This source file is part of the Swift.org open source project # @@ -8,7 +8,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// # # Create a graph of the protocol refinement relationships, associated # types, operator requirements, and defaulted generic operators. @@ -21,7 +21,7 @@ # && dot -Tsvg /tmp/protocols.dot > /tmp/protocols.svg \ # && open /tmp/protocols.svg # -# ===----------------------------------------------------------------------===// +# ===---------------------------------------------------------------------===// from __future__ import print_function @@ -42,12 +42,12 @@ # Pattern to recognize a (possibly-generic) operator decl. operator = r''' (?:(?:prefix|postfix).*)? func \s* -(?=\S)[^A-Za-z_] # non-space, non-identifier: begins an operator name -(?:(?=\S)[^(){])* # rest of operator name +(?=\S)[^A-Za-z_] # non-space, non-identifier: begins an operator name +(?:(?=\S)[^(){])* # rest of operator name \s* -(<[^>{]+>)? # generic parameter list +(<[^>{]+>)? # generic parameter list \s* -\([^)]*\) # function parameter list +\([^)]*\) # function parameter list ''' # substitute local variables into the string @@ -180,7 +180,8 @@ def parse_protocol(m): requirements = body.get(node, []) generics = sorted(generic_operators.get(node, set())) style = 'solid' if node.startswith('_') else 'bold' - divider = '
| \n%s\n |