Skip to content

Commit

Permalink
[NFC] Python Lint: Fix E275(missing whitespace after keyword) issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
YOCKOW committed Aug 21, 2022
1 parent 8f096bf commit d103815
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 68 deletions.
20 changes: 10 additions & 10 deletions test/Driver/Inputs/filelists/check-filelist-abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

with open(filelistFile, 'r') as f:
lines = f.readlines()
assert(lines[0].endswith("/a.swift\n") or
lines[0].endswith("/a.swiftmodule\n"))
assert(lines[1].endswith("/b.swift\n") or
lines[1].endswith("/b.swiftmodule\n"))
assert(lines[2].endswith("/c.swift\n") or
lines[2].endswith("/c.swiftmodule\n"))
assert (lines[0].endswith("/a.swift\n") or
lines[0].endswith("/a.swiftmodule\n"))
assert (lines[1].endswith("/b.swift\n") or
lines[1].endswith("/b.swiftmodule\n"))
assert (lines[2].endswith("/c.swift\n") or
lines[2].endswith("/c.swiftmodule\n"))

if primaryFile:
print("Command-line primary", os.path.basename(primaryFile))
Expand All @@ -42,7 +42,7 @@
primaryFilelistFile = sys.argv[sys.argv.index('-primary-filelist') + 1]
with open(primaryFilelistFile, 'r') as f:
lines = f.readlines()
assert(len(lines) == 1)
assert len(lines) == 1
print("Handled", os.path.basename(lines[0]).rstrip())
elif lines[0].endswith(".swiftmodule\n"):
print("Handled modules")
Expand All @@ -63,7 +63,7 @@
outputListFile = sys.argv[sys.argv.index('-output-filelist') + 1]
with open(outputListFile, 'r') as f:
lines = f.readlines()
assert(lines[0].endswith("/a.o\n") or lines[0].endswith("/a.bc\n"))
assert(lines[1].endswith("/b.o\n") or lines[1].endswith("/b.bc\n"))
assert(lines[2].endswith("/c.o\n") or lines[2].endswith("/c.bc\n"))
assert lines[0].endswith("/a.o\n") or lines[0].endswith("/a.bc\n")
assert lines[1].endswith("/b.o\n") or lines[1].endswith("/b.bc\n")
assert lines[2].endswith("/c.o\n") or lines[2].endswith("/c.bc\n")
print("...with output!")
2 changes: 1 addition & 1 deletion test/Serialization/Inputs/binary_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

(_, old, new) = sys.argv
assert(len(old) == len(new))
assert len(old) == len(new)

if sys.version_info[0] < 3:
data = sys.stdin.read()
Expand Down
2 changes: 1 addition & 1 deletion tools/SourceKit/bindings/python/sourcekitd/capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def to_python_object(self):
elif var_ty == VariantType.UID:
return UIdent(conf.lib.sourcekitd_variant_uid_get_value(self))
else:
assert(var_ty == VariantType.BOOL)
assert var_ty == VariantType.BOOL
return conf.lib.sourcekitd_variant_bool_get_value(self)

def to_python_array(self):
Expand Down
22 changes: 11 additions & 11 deletions utils/GYBUnicodeDataUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def verify(self, unicode_property):
for cp in range(0, 0x110000):
expected_value = unicode_property.get_value(cp)
actual_value = self.get_value(cp)
assert(expected_value == actual_value)
assert expected_value == actual_value

def freeze(self):
"""Compress internal trie representation.
Expand Down Expand Up @@ -405,12 +405,12 @@ def map_index(idx):

def _int_to_le_bytes(self, data, width):
if width == 1:
assert(data & ~0xff == 0)
assert data & ~0xff == 0
return [data]
if width == 2:
assert(data & ~0xffff == 0)
assert data & ~0xffff == 0
return [data & 0xff, data & 0xff00]
assert(False)
assert False

def _int_list_to_le_bytes(self, ints, width):
return [
Expand Down Expand Up @@ -512,7 +512,7 @@ def get_extended_grapheme_cluster_rules_matrix(grapheme_cluster_break_table):
rules_matrix[first][second] = action

# Make sure we can pack one row of the matrix into a 'uint16_t'.
assert(len(any_value) <= 16)
assert len(any_value) <= 16

result = []
for first in any_value:
Expand Down Expand Up @@ -572,9 +572,9 @@ def _convert_line(line):
return (test, boundaries)

# Self-test.
assert(_convert_line(u'÷ 0903 × 0308 ÷ AC01 ÷ # abc') == (
'\\xe0\\xa4\\x83\\xcc\\x88\\xea\\xb0\\x81', [0, 5, 8]))
assert(_convert_line(u'÷ D800 ÷ # abc') == ('\\xe2\\x80\\x8b', [0, 3]))
assert (_convert_line(u'÷ 0903 × 0308 ÷ AC01 ÷ # abc') ==
('\\xe0\\xa4\\x83\\xcc\\x88\\xea\\xb0\\x81', [0, 5, 8]))
assert _convert_line(u'÷ D800 ÷ # abc') == ('\\xe2\\x80\\x8b', [0, 3])

result = []

Expand Down Expand Up @@ -627,9 +627,9 @@ def _convert_line(line):
return (test, boundaries)

# Self-test.
assert(_convert_line('÷ 0903 × 0308 ÷ AC01 ÷ # abc') == ([
0x0903, 0x0308, 0xac01], [0, 2, 3]))
assert(_convert_line('÷ D800 ÷ # abc') == ([0x200b], [0, 1]))
assert (_convert_line('÷ 0903 × 0308 ÷ AC01 ÷ # abc') ==
([0x0903, 0x0308, 0xac01], [0, 2, 3]))
assert _convert_line('÷ D800 ÷ # abc') == ([0x200b], [0, 1])

result = []

Expand Down
6 changes: 3 additions & 3 deletions utils/backtrace-check
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def main():
# First see if we found the start of our stack trace start. If so, set
# the found stack trace flag and continue.
if line == 'Current stack trace:':
assert(not found_stack_trace_start)
assert not found_stack_trace_start
found_stack_trace_start = True
continue

Expand All @@ -97,11 +97,11 @@ def main():

# Check for unavailable symbols, if that was requested.
if args.check_unavailable:
assert('unavailable' not in matches.group('routine'))
assert 'unavailable' not in matches.group('routine')

# Once we have processed all of the lines, make sure that we found at least
# one stack trace entry.
assert(found_stack_trace_entry)
assert found_stack_trace_entry


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions utils/bug_reducer/bug_reducer/list_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _test_prefix_suffix(self, mid, prefix, suffix):
self._reset_progress()
return False

assert(result == TESTRESULT_NOFAILURE)
assert result == TESTRESULT_NOFAILURE
# The property does not hold. Some of the elements we removed must
# be necessary to maintain the property.
self.mid_top = mid
Expand Down Expand Up @@ -165,7 +165,7 @@ def _trim_try_backjump_and_trim_suffix(self):
def reduce_list(self):
random.seed(0x6e5ea738) # Seed the random number generator
(result, self.target_list, kept) = self.run_test(self.target_list, [])
assert(result in TESTRESULTS)
assert result in TESTRESULTS
(should_continue, result) = self._should_continue(result)
if not should_continue:
return result
Expand Down
16 changes: 8 additions & 8 deletions utils/bug_reducer/bug_reducer/swift_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def tool(self):
return self.tools.sil_opt

def _cmdline(self, input_file, passes, emit_sib, output_file='-'):
assert(isinstance(emit_sib, bool))
assert(isinstance(output_file, str))
assert isinstance(emit_sib, bool)
assert isinstance(output_file, str)
base_args = self.base_args(emit_sib)
sanity_check_file_exists(input_file)
base_args.extend([input_file, '-o', output_file])
Expand Down Expand Up @@ -189,12 +189,12 @@ def tool(self):

def _cmdline(self, input_file, funclist_path, emit_sib, output_file='-',
invert=False):
assert(isinstance(emit_sib, bool))
assert(isinstance(output_file, str))
assert isinstance(emit_sib, bool)
assert isinstance(output_file, str)

sanity_check_file_exists(input_file)
sanity_check_file_exists(funclist_path)
assert(isinstance(funclist_path, str))
assert isinstance(funclist_path, str)
base_args = self.base_args(emit_sib)
base_args.extend([input_file, '-o', output_file,
'-func-file=%s' % funclist_path])
Expand All @@ -204,7 +204,7 @@ def _cmdline(self, input_file, funclist_path, emit_sib, output_file='-',

def _invoke(self, input_file, funclist_path, output_filename,
invert=False):
assert(isinstance(funclist_path, str))
assert isinstance(funclist_path, str)
cmdline = self._cmdline(input_file,
funclist_path,
True,
Expand All @@ -214,7 +214,7 @@ def _invoke(self, input_file, funclist_path, output_filename,

def invoke_with_functions(self, funclist_path, output_filename,
invert=False):
assert(isinstance(funclist_path, str))
assert isinstance(funclist_path, str)
return self._invoke(self.input_file, funclist_path, output_filename,
invert)

Expand All @@ -236,5 +236,5 @@ def get_symbols(self, input_file):
output = subprocess.check_output(cmdline)
for line in output.split("\n")[:-1]:
t = tuple(line.split(" "))
assert(len(t) == 2)
assert len(t) == 2
yield t
2 changes: 1 addition & 1 deletion utils/build_swift/tests/build_swift/test_cache_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_replaced_with_functools_lru_cache_python_3_2(self):
def func():
return None

assert(mock_lru_cache.called)
assert mock_lru_cache.called

def test_call_with_no_args(self):
# Increments the counter once per unique call.
Expand Down
4 changes: 2 additions & 2 deletions utils/build_swift/tests/build_swift/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_echo_command(self):

mock_stream.write.assert_called_with(
'>>> {}\n'.format(shell.quote(test_command)))
assert(mock_stream.flush.called)
assert mock_stream.flush.called

@utils.requires_module('unittest.mock')
def test_echo_command_custom_prefix(self):
Expand All @@ -124,7 +124,7 @@ def test_echo_command_custom_prefix(self):
shell._echo_command('ls', mock_stream, prefix='$ ')

mock_stream.write.assert_called_with('$ ls\n')
assert(mock_stream.flush.called)
assert mock_stream.flush.called

# -------------------------------------------------------------------------
# _normalize_args
Expand Down
2 changes: 1 addition & 1 deletion utils/dev-scripts/scurve_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def main():
ax.set_xlim(0.0, 1.0)
y_min = args.y_axis_min or 1.0 - y_limit
y_max = args.y_axis_max or 1.0 + y_limit
assert(y_min <= y_max)
assert y_min <= y_max
ax.set_ylim(y_min, y_max)
ax.grid(True)
ax.xaxis.set_ticks(np.arange(0.0, 1.0, 0.05))
Expand Down
2 changes: 1 addition & 1 deletion utils/gyb_syntax_support/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, name, description=None, kind=None, traits=None,
self.omit_when_empty = omit_when_empty
self.collection_element = element or ""
# For SyntaxCollections make sure that the element_name is set.
assert(not self.is_syntax_collection() or element_name or element)
assert not self.is_syntax_collection() or element_name or element
# If there's a preferred name for the collection element that differs
# from its supertype, use that.
self.collection_element_name = element_name or self.collection_element
Expand Down
8 changes: 4 additions & 4 deletions utils/jobstats/jobstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ def __init__(self, jobkind, jobid, module, start_usec, dur_usec,

def driver_jobs_ran(self):
"""Return the count of a driver job's ran sub-jobs"""
assert(self.is_driver_job())
assert self.is_driver_job()
return self.stats.get("Driver.NumDriverJobsRun", 0)

def driver_jobs_skipped(self):
"""Return the count of a driver job's skipped sub-jobs"""
assert(self.is_driver_job())
assert self.is_driver_job()
return self.stats.get("Driver.NumDriverJobsSkipped", 0)

def driver_jobs_total(self):
"""Return the total count of a driver job's ran + skipped sub-jobs"""
assert(self.is_driver_job())
assert self.is_driver_job()
return self.driver_jobs_ran() + self.driver_jobs_skipped()

def merged_with(self, other, merge_by="sum"):
Expand Down Expand Up @@ -126,7 +126,7 @@ def divided_by(self, n):
def incrementality_percentage(self):
"""Assuming the job is a driver job, return the amount of
jobs that actually ran, as a percentage of the total number."""
assert(self.is_driver_job())
assert self.is_driver_job()
ran = self.driver_jobs_ran()
total = self.driver_jobs_total()
return round((float(ran) / float(total)) * 100.0, 2)
Expand Down
4 changes: 2 additions & 2 deletions utils/line-directive
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def map_line_to_source_file(target_filename, target_line_num):
>>> t.close()
>>> os.remove(t.name)
"""
assert(target_line_num > 0)
assert target_line_num > 0
map = fline_map(target_filename)
index = bisect.bisect_left(map, (target_line_num, '', 0))
base = map[index - 1]
Expand Down Expand Up @@ -191,7 +191,7 @@ def map_line_from_source_file(source_filename, source_line_num,
>>> t.close()
>>> os.remove(t.name)
"""
assert(source_line_num > 0)
assert source_line_num > 0
map = fline_map(target_filename)

for i, (target_line_num, found_source_filename,
Expand Down
2 changes: 1 addition & 1 deletion utils/process-stats-dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def vars_of_args(args):
# of each of "old" and "new", and the stats are those found in the respective
# dirs.
def load_paired_stats_dirs(args):
assert(len(args.remainder) == 2)
assert len(args.remainder) == 2
paired_stats = []
(old, new) = args.remainder
vargs = vars_of_args(args)
Expand Down
6 changes: 3 additions & 3 deletions utils/scale-test
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def converged(ctr, simplex, epsilon):
def Nelder_Mead_simplex(objective, params, bounds, epsilon=1.0e-6):
# By the book: https://en.wikipedia.org/wiki/Nelder%E2%80%93Mead_method
ndim = len(params)
assert(ndim >= 2)
assert ndim >= 2

def named(tup):
return params.__new__(params.__class__, *tup)
Expand Down Expand Up @@ -332,7 +332,7 @@ def Nelder_Mead_simplex(objective, params, bounds, epsilon=1.0e-6):
continue

# 5. Contraction
assert(vr >= simplex[-2].val)
assert vr >= simplex[-2].val
xc = tup_add(x0, tup_mul(rho, tup_sub(xw, x0)))
vc = f(xc)
if vc < vw:
Expand Down Expand Up @@ -362,7 +362,7 @@ def Nelder_Mead_simplex(objective, params, bounds, epsilon=1.0e-6):
# perfectly") and finally returns (fit_params, r_squared).
def fit_function_to_data_by_least_squares(objective, params, bounds, xs, ys):

assert(len(ys) > 0)
assert len(ys) > 0
mean_y = sum(ys) / len(ys)
ss_total = sum((y - mean_y) ** 2 for y in ys)
data = list(zip(xs, ys))
Expand Down
6 changes: 3 additions & 3 deletions utils/swift_build_support/swift_build_support/build_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _get_po_ordered_nodes(root, invertedDepMap):

# Then grab the dependents of our node.
deps = invertedDepMap.get(node, set([]))
assert(isinstance(deps, set))
assert isinstance(deps, set)

# Then visit those and see if we have not visited any of them. Push
# any such nodes onto the worklist and continue. If we have already
Expand Down Expand Up @@ -92,13 +92,13 @@ def add_edge(self, pred, succ):

def set_root(self, root):
# Assert that we always only have one root.
assert(self.root is None)
assert self.root is None
self.root = root

def produce_schedule(self):
# Grab the root and make sure it is not None
root = self.root
assert(root is not None)
assert root is not None

# Then perform a post order traversal from root using our inverted
# dependency map to compute a list of our nodes in post order.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ def execute(self):
if is_impl:
self._execute_impl(pipeline, all_hosts, perform_epilogue_opts)
else:
assert(index != last_impl_index)
assert index != last_impl_index
if index > last_impl_index:
non_darwin_cross_compile_hostnames = [
target for target in self.args.cross_compile_hosts if not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, stage, args):
self.__dict__['postfix'] = stage.postfix
self.__dict__['stage'] = stage
self.__dict__['args'] = args
assert(not isinstance(self.args, StageArgs))
assert not isinstance(self.args, StageArgs)

def _get_stage_prefix(self):
return self.__dict__['postfix']
Expand Down
Loading

0 comments on commit d103815

Please sign in to comment.