Skip to content

Commit

Permalink
[Gardening] Remove trailing whitespaces in Python scripts. (W291)
Browse files Browse the repository at this point in the history
That has been marked as 'FIXME' for three years.
This commit fixes it.
  • Loading branch information
YOCKOW committed Aug 25, 2022
1 parent cf337a7 commit c1e154a
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 34 deletions.
3 changes: 0 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ ignore =
# compliant (https://github.com/psf/black#slices).
E203,

# FIXME: We should not have trailing whitespace.
W291,

# Line breaks before binary operators are not explicitly disallowed in
# PEP8, rather it should be consistent throughout the project. The black
# tool puts them on new lines which is to be considered a best practice
Expand Down
2 changes: 1 addition & 1 deletion benchmark/scripts/create_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_benchmark_file(name):


def add_import_benchmark(name):
"""Adds an `import` statement to the `main.swift` file for the new
"""Adds an `import` statement to the `main.swift` file for the new
benchmark.
"""
relative_path = create_relative_path("../utils/main.swift")
Expand Down
2 changes: 1 addition & 1 deletion utils/build_swift/build_swift/driver_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def create_argument_parser():
help='enable code coverage analysis in Swift (false, not-merged, '
'merged).')

option('--swift-disable-dead-stripping', toggle_true,
option('--swift-disable-dead-stripping', toggle_true,
help="Turn off Darwin-specific dead stripping for Swift host tools")

option('--build-subdir', store,
Expand Down
4 changes: 2 additions & 2 deletions utils/build_swift/build_swift/presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ def _get_preset(self, name):
def _interpolate_preset_vars(self, preset, vars):
interpolated_options = []
for (name, value) in preset.options:
# If the option is a key-value pair, e.g.
# If the option is a key-value pair, e.g.
# install-destdir=%(install_dir)s
# interpolate the value. If it is a raw option, e.g.
# interpolate the value. If it is a raw option, e.g.
# %(some_flag)s
# is a raw option without a value, expand the name.
if value:
Expand Down
2 changes: 1 addition & 1 deletion utils/gyb_syntax_support/CommonNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
Child('LeftBrace', kind='LeftBraceToken'),
Child('Statements', kind='CodeBlockItemList',
collection_element_name='Statement', is_indented=True),
Child('RightBrace', kind='RightBraceToken',
Child('RightBrace', kind='RightBraceToken',
requires_leading_newline=True),
]),

Expand Down
8 changes: 4 additions & 4 deletions utils/gyb_syntax_support/ExprNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@

Node('ClosureSignature', kind='Syntax',
children=[
Child('Attributes', kind='AttributeList',
Child('Attributes', kind='AttributeList',
collection_element_name='Attribute', is_optional=True),
Child('Capture', kind='ClosureCaptureSignature',
is_optional=True),
Expand Down Expand Up @@ -568,7 +568,7 @@
traits=['Parenthesized'],
children=[
Child('Backslash', kind='BackslashToken'),
Child('Delimiter', kind='RawStringDelimiterToken',
Child('Delimiter', kind='RawStringDelimiterToken',
is_optional=True),
Child('LeftParen', kind='LeftParenToken',
classification='StringInterpolationAnchor',
Expand All @@ -581,7 +581,7 @@
# e.g. "abc \(foo()) def"
Node('StringLiteralExpr', kind='Expr',
children=[
Child('OpenDelimiter', kind='RawStringDelimiterToken',
Child('OpenDelimiter', kind='RawStringDelimiterToken',
is_optional=True),
Child('OpenQuote', kind='Token',
token_choices=[
Expand All @@ -595,7 +595,7 @@
'StringQuoteToken',
'MultilineStringQuoteToken',
]),
Child('CloseDelimiter', kind='RawStringDelimiterToken',
Child('CloseDelimiter', kind='RawStringDelimiterToken',
is_optional=True),
]),

Expand Down
8 changes: 4 additions & 4 deletions utils/gyb_syntax_support/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Node(object):

def __init__(self, name, description=None, kind=None, traits=None,
children=[], element=None, element_name=None,
element_choices=None, omit_when_empty=False,
element_choices=None, omit_when_empty=False,
elements_separated_by_newline=False):
self.syntax_kind = name
self.element_name = element_name
Expand All @@ -24,7 +24,7 @@ def __init__(self, name, description=None, kind=None, traits=None,

self.traits = traits or []
self.children = []
# Add implicitly generated UnexpectedNodes children in between any two
# Add implicitly generated UnexpectedNodes children in between any two
# defined children
if kind != 'SyntaxCollection':
for i in range(2 * len(children)):
Expand All @@ -35,8 +35,8 @@ def __init__(self, name, description=None, kind=None, traits=None,
name = 'UnexpectedBetween%sAnd%s' % \
(children[int(i / 2) - 1].name, children[int(i / 2)].name)
self.children.append(Child(
name,
kind='UnexpectedNodes',
name,
kind='UnexpectedNodes',
collection_element_name=name,
is_optional=True
))
Expand Down
4 changes: 2 additions & 2 deletions utils/gyb_syntax_support/StmtNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@
Child('GuardResult', kind='Expr'),
]),

# for-in-stmt -> label? ':'?
# for-in-stmt -> label? ':'?
# 'for' 'try'? 'await'? 'case'? pattern 'in' expr 'where'?
# expr code-block ';'?
Node('ForInStmt', kind='Stmt',
traits=['WithCodeBlock'],
children=[
Child('ForKeyword', kind='ForToken'),
Child('TryKeyword', kind='TryToken',
Child('TryKeyword', kind='TryToken',
is_optional=True),
Child('AwaitKeyword', kind='IdentifierToken',
classification='Keyword',
Expand Down
4 changes: 2 additions & 2 deletions utils/gyb_syntax_support/Token.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def macro_name(self):
serialization_code=92),
Punctuator('RightSquareBracket', 'r_square', text=']',
serialization_code=93),
Punctuator('LeftAngle', 'l_angle', text='<', requires_leading_space=True,
Punctuator('LeftAngle', 'l_angle', text='<', requires_leading_space=True,
requires_trailing_space=True, serialization_code=94),
Punctuator('RightAngle', 'r_angle', text='>', requires_leading_space=True,
requires_trailing_space=True, serialization_code=95),
Expand All @@ -253,7 +253,7 @@ def macro_name(self):
Punctuator('Pound', 'pound', text='#', serialization_code=81),

Punctuator('PrefixAmpersand', 'amp_prefix', text='&',
requires_leading_space=True, requires_trailing_space=True,
requires_leading_space=True, requires_trailing_space=True,
serialization_code=96),
Punctuator('Arrow', 'arrow', text='->', requires_leading_space=True,
requires_trailing_space=True, serialization_code=78),
Expand Down
2 changes: 1 addition & 1 deletion utils/gyb_syntax_support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def make_missing_swift_child(child):
elif child.syntax_kind in SYNTAX_BASE_KINDS:
missing_kind = f"missing{child.syntax_kind}"
else:
missing_kind = child.swift_syntax_kind
missing_kind = child.swift_syntax_kind
return f'RawSyntax.makeEmptyLayout(kind: SyntaxKind.{missing_kind}, ' + \
'arena: .default)'

Expand Down
2 changes: 1 addition & 1 deletion utils/scale-test
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def run_once_with_primary(args, ast, rng, primary_idx):
if not args.save_temps:
shutil.rmtree(d)

return {k: v for (k, v) in r.items() if args.select in k and
return {k: v for (k, v) in r.items() if args.select in k and
not (args.exclude_timers and k.startswith('time.'))}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def compute_product_pipelines(self):
builder.add_product(products.SwiftDocC,
is_enabled=self.args.build_swiftdocc)
builder.add_product(products.SwiftDocCRender,
is_enabled=self.args.install_swiftdocc)
is_enabled=self.args.install_swiftdocc)

# Keep SwiftDriver at last.
# swift-driver's integration with the build scripts is not fully
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def build(self, host_target):
self.run_swiftsyntax_build_script(target=host_target,
command='verify-source-code')

self.run_swiftsyntax_build_script(target=host_target,
self.run_swiftsyntax_build_script(target=host_target,
command='build')

def should_test(self, host_target):
Expand All @@ -91,18 +91,18 @@ def test(self, host_target):
self.run_swiftsyntax_build_script(target=host_target,
command='test',
additional_params=[
'--filecheck-exec',
os.path.join(llvm_build_dir,
'bin',
'--filecheck-exec',
os.path.join(llvm_build_dir,
'bin',
'FileCheck')
])

def should_install(self, host_target):
return self.args.install_swiftsyntax

def install(self, target_name):
# SwiftSyntax doesn't produce any products thate should be installed
# into the toolchein. All tools using it link against SwiftSyntax
# SwiftSyntax doesn't produce any products thate should be installed
# into the toolchein. All tools using it link against SwiftSyntax
# statically.
pass

Expand Down
8 changes: 4 additions & 4 deletions utils/update_checkout/tests/test_update_worktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def setup_worktree(workspace_path, local_path, worktree_name):
for project in os.listdir(local_path):
local_project_path = os.path.join(local_path, project)
worktree_project_path = os.path.join(worktree_path, project)
call_quietly(['git',
'-C', local_project_path,
call_quietly(['git',
'-C', local_project_path,
'worktree', 'add', worktree_project_path])


Expand All @@ -39,8 +39,8 @@ def teardown_worktree(workspace_path, local_path, worktree_name):
for project in os.listdir(local_path):
local_project_path = os.path.join(local_path, project)
worktree_project_path = os.path.join(worktree_path, project)
call_quietly(['git',
'-C', local_project_path,
call_quietly(['git',
'-C', local_project_path,
'worktree', 'remove', worktree_project_path])


Expand Down
2 changes: 1 addition & 1 deletion utils/update_checkout/update_checkout/update_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def main():
action="append")
parser.add_argument(
"--all-repositories",
help="""Includes repositories not required for current platform.
help="""Includes repositories not required for current platform.
This will not override '--skip-repositories'""",
action='store_true')
parser.add_argument(
Expand Down

0 comments on commit c1e154a

Please sign in to comment.