mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Improve formatting of Python files (#30919)
Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
df157dcc03
commit
554b35b705
8 changed files with 48 additions and 54 deletions
6
.flake8
6
.flake8
|
@ -16,9 +16,3 @@ exclude =
|
||||||
python/mach
|
python/mach
|
||||||
components
|
components
|
||||||
tests
|
tests
|
||||||
# We should fix those
|
|
||||||
etc/ci
|
|
||||||
./python/wpt/run.py
|
|
||||||
./python/tidy/tidy.py
|
|
||||||
./etc/servo_automation_screenshot.py
|
|
||||||
./etc/memory_reports_over_time.py
|
|
||||||
|
|
|
@ -54,9 +54,9 @@ def print_line(value1, value2, key):
|
||||||
for key in keys:
|
for key in keys:
|
||||||
value1 = data1.get(key)
|
value1 = data1.get(key)
|
||||||
value2 = data2.get(key)
|
value2 = data2.get(key)
|
||||||
if value1 and not(value2):
|
if value1 and not (value2):
|
||||||
print("{}Test {}: missing from {}.{}".format(WARNING, key, args.file2, END))
|
print("{}Test {}: missing from {}.{}".format(WARNING, key, args.file2, END))
|
||||||
elif value2 and not(value1):
|
elif value2 and not (value1):
|
||||||
print("{}Test {}: missing from {}.{}".format(WARNING, key, args.file1, END))
|
print("{}Test {}: missing from {}.{}".format(WARNING, key, args.file1, END))
|
||||||
elif value1 and value2:
|
elif value1 and value2:
|
||||||
total1 += value1
|
total1 += value1
|
||||||
|
|
|
@ -63,7 +63,7 @@ Shutting down the Constellation after generating an output file or exit flag spe
|
||||||
"loadEventEnd": None
|
"loadEventEnd": None
|
||||||
}]
|
}]
|
||||||
result = runner.parse_log(mock_log, mock_url)
|
result = runner.parse_log(mock_log, mock_url)
|
||||||
assert(expected == list(result))
|
assert (expected == list(result))
|
||||||
|
|
||||||
|
|
||||||
def test_log_parser_complex():
|
def test_log_parser_complex():
|
||||||
|
@ -146,7 +146,7 @@ Shutting down the Constellation after generating an output file or exit flag spe
|
||||||
"loadEventEnd": None
|
"loadEventEnd": None
|
||||||
}]
|
}]
|
||||||
result = runner.parse_log(mock_log, mock_url)
|
result = runner.parse_log(mock_log, mock_url)
|
||||||
assert(expected == list(result))
|
assert (expected == list(result))
|
||||||
|
|
||||||
|
|
||||||
def test_log_parser_empty():
|
def test_log_parser_empty():
|
||||||
|
@ -187,7 +187,7 @@ def test_log_parser_empty():
|
||||||
"loadEventEnd": -1
|
"loadEventEnd": -1
|
||||||
}]
|
}]
|
||||||
result = runner.parse_log(mock_log, mock_testcase)
|
result = runner.parse_log(mock_log, mock_testcase)
|
||||||
assert(expected == list(result))
|
assert (expected == list(result))
|
||||||
|
|
||||||
|
|
||||||
def test_log_parser_error():
|
def test_log_parser_error():
|
||||||
|
@ -220,7 +220,7 @@ def test_log_parser_error():
|
||||||
"loadEventEnd": -1
|
"loadEventEnd": -1
|
||||||
}]
|
}]
|
||||||
result = runner.parse_log(mock_log, mock_testcase)
|
result = runner.parse_log(mock_log, mock_testcase)
|
||||||
assert(expected == list(result))
|
assert (expected == list(result))
|
||||||
|
|
||||||
|
|
||||||
def test_log_parser_bad_testcase_name():
|
def test_log_parser_bad_testcase_name():
|
||||||
|
@ -280,7 +280,7 @@ Shutting down the Constellation after generating an output file or exit flag spe
|
||||||
"loadEventEnd": -1
|
"loadEventEnd": -1
|
||||||
}]
|
}]
|
||||||
result = runner.parse_log(mock_log, mock_testcase)
|
result = runner.parse_log(mock_log, mock_testcase)
|
||||||
assert(expected == list(result))
|
assert (expected == list(result))
|
||||||
|
|
||||||
|
|
||||||
def test_manifest_loader():
|
def test_manifest_loader():
|
||||||
|
@ -297,7 +297,7 @@ http://localhost/page_load_test/tp5n/aljazeera.net/aljazeera.net/portal.html
|
||||||
("http://localhost/page_load_test/tp5n/56.com/www.56.com/index.html", False),
|
("http://localhost/page_load_test/tp5n/56.com/www.56.com/index.html", False),
|
||||||
("http://localhost/page_load_test/tp5n/aljazeera.net/aljazeera.net/portal.html", False)
|
("http://localhost/page_load_test/tp5n/aljazeera.net/aljazeera.net/portal.html", False)
|
||||||
]
|
]
|
||||||
assert(expected == list(runner.parse_manifest(text)))
|
assert (expected == list(runner.parse_manifest(text)))
|
||||||
|
|
||||||
|
|
||||||
def test_manifest_loader_async():
|
def test_manifest_loader_async():
|
||||||
|
@ -310,7 +310,7 @@ async http://localhost/page_load_test/tp5n/56.com/www.56.com/index.html
|
||||||
("http://localhost/page_load_test/tp5n/163.com/www.163.com/index.html", False),
|
("http://localhost/page_load_test/tp5n/163.com/www.163.com/index.html", False),
|
||||||
("http://localhost/page_load_test/tp5n/56.com/www.56.com/index.html", True),
|
("http://localhost/page_load_test/tp5n/56.com/www.56.com/index.html", True),
|
||||||
]
|
]
|
||||||
assert(expected == list(runner.parse_manifest(text)))
|
assert (expected == list(runner.parse_manifest(text)))
|
||||||
|
|
||||||
|
|
||||||
def test_filter_result_by_manifest():
|
def test_filter_result_by_manifest():
|
||||||
|
@ -334,7 +334,7 @@ def test_filter_result_by_manifest():
|
||||||
("http://localhost:8000/page_load_test/56.com/www.56.com/index.html", False)
|
("http://localhost:8000/page_load_test/56.com/www.56.com/index.html", False)
|
||||||
]
|
]
|
||||||
|
|
||||||
assert(expected == runner.filter_result_by_manifest(input_json, manifest))
|
assert (expected == runner.filter_result_by_manifest(input_json, manifest))
|
||||||
|
|
||||||
|
|
||||||
def test_filter_result_by_manifest_error():
|
def test_filter_result_by_manifest_error():
|
||||||
|
@ -374,7 +374,7 @@ def test_take_result_median_odd():
|
||||||
"domLoading": 1460358380002
|
"domLoading": 1460358380002
|
||||||
}]
|
}]
|
||||||
|
|
||||||
assert(expected == runner.take_result_median(input_json, len(input_json)))
|
assert (expected == runner.take_result_median(input_json, len(input_json)))
|
||||||
|
|
||||||
|
|
||||||
def test_take_result_median_even():
|
def test_take_result_median_even():
|
||||||
|
@ -394,7 +394,7 @@ def test_take_result_median_even():
|
||||||
"domLoading": 1460358380001.5
|
"domLoading": 1460358380001.5
|
||||||
}]
|
}]
|
||||||
|
|
||||||
assert(expected == runner.take_result_median(input_json, len(input_json)))
|
assert (expected == runner.take_result_median(input_json, len(input_json)))
|
||||||
|
|
||||||
|
|
||||||
def test_take_result_median_error():
|
def test_take_result_median_error():
|
||||||
|
@ -414,7 +414,7 @@ def test_take_result_median_error():
|
||||||
"domLoading": 1460358380001.5
|
"domLoading": 1460358380001.5
|
||||||
}]
|
}]
|
||||||
|
|
||||||
assert(expected == runner.take_result_median(input_json, len(input_json)))
|
assert (expected == runner.take_result_median(input_json, len(input_json)))
|
||||||
|
|
||||||
|
|
||||||
def test_log_result():
|
def test_log_result():
|
||||||
|
@ -437,4 +437,4 @@ Failure summary:
|
||||||
- http://localhost:8000/page_load_test/56.com/www.56.com/index.html
|
- http://localhost:8000/page_load_test/56.com/www.56.com/index.html
|
||||||
========================================
|
========================================
|
||||||
"""
|
"""
|
||||||
assert(expected == runner.format_result_summary(results))
|
assert (expected == runner.format_result_summary(results))
|
||||||
|
|
|
@ -8,18 +8,18 @@ import submit_to_perfherder
|
||||||
|
|
||||||
|
|
||||||
def test_format_testcase_name():
|
def test_format_testcase_name():
|
||||||
assert('about:blank' == submit_to_perfherder.format_testcase_name(
|
assert ('about:blank' == submit_to_perfherder.format_testcase_name(
|
||||||
'about:blank'))
|
'about:blank'))
|
||||||
assert('163.com' == submit_to_perfherder.format_testcase_name((
|
assert ('163.com' == submit_to_perfherder.format_testcase_name((
|
||||||
'http://localhost:8000/page_load_test/163.com/p.mail.163.com/'
|
'http://localhost:8000/page_load_test/163.com/p.mail.163.com/'
|
||||||
'mailinfo/shownewmsg_www_1222.htm.html')))
|
'mailinfo/shownewmsg_www_1222.htm.html')))
|
||||||
assert(('1234567890223456789032345678904234567890'
|
assert (('1234567890223456789032345678904234567890'
|
||||||
'5234567890623456789072345678908234567890')
|
'5234567890623456789072345678908234567890')
|
||||||
== submit_to_perfherder.format_testcase_name((
|
== submit_to_perfherder.format_testcase_name((
|
||||||
'1234567890223456789032345678904234567890'
|
'1234567890223456789032345678904234567890'
|
||||||
'52345678906234567890723456789082345678909234567890')))
|
'52345678906234567890723456789082345678909234567890')))
|
||||||
assert('news.ycombinator.com' == submit_to_perfherder.format_testcase_name(
|
assert ('news.ycombinator.com' == submit_to_perfherder.format_testcase_name(
|
||||||
'http://localhost:8000/tp6/news.ycombinator.com/index.html'))
|
'http://localhost:8000/tp6/news.ycombinator.com/index.html'))
|
||||||
|
|
||||||
|
|
||||||
def test_format_perf_data():
|
def test_format_perf_data():
|
||||||
|
@ -94,7 +94,7 @@ def test_format_perf_data():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = submit_to_perfherder.format_perf_data(mock_result)
|
result = submit_to_perfherder.format_perf_data(mock_result)
|
||||||
assert(expected == result)
|
assert (expected == result)
|
||||||
|
|
||||||
|
|
||||||
def test_format_bad_perf_data():
|
def test_format_bad_perf_data():
|
||||||
|
@ -131,4 +131,4 @@ def test_format_bad_perf_data():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = submit_to_perfherder.format_perf_data(mock_result)
|
result = submit_to_perfherder.format_perf_data(mock_result)
|
||||||
assert(expected == result)
|
assert (expected == result)
|
||||||
|
|
|
@ -38,7 +38,7 @@ def parse_memory_report(lines):
|
||||||
parents = []
|
parents = []
|
||||||
last_separator_index = None
|
last_separator_index = None
|
||||||
for line in lines:
|
for line in lines:
|
||||||
assert(line[0] == '|')
|
assert (line[0] == '|')
|
||||||
line = line[1:]
|
line = line[1:]
|
||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
|
@ -80,7 +80,7 @@ def test_extract_memory_reports():
|
||||||
"| 107.88 MiB -- system-heap-unclassified\n",
|
"| 107.88 MiB -- system-heap-unclassified\n",
|
||||||
"End memory reports\n"]
|
"End memory reports\n"]
|
||||||
expected = ([['|', '| 107.88 MiB -- system-heap-unclassified']], ['reports'])
|
expected = ([['|', '| 107.88 MiB -- system-heap-unclassified']], ['reports'])
|
||||||
assert(extract_memory_reports(input) == expected)
|
assert (extract_memory_reports(input) == expected)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,9 +114,9 @@ def test():
|
||||||
}
|
}
|
||||||
report = parse_memory_report(input.split('\n'))
|
report = parse_memory_report(input.split('\n'))
|
||||||
transformed = transform_report_for_test(report)
|
transformed = transform_report_for_test(report)
|
||||||
assert(sorted(transformed.keys()) == sorted(expected.keys()))
|
assert (sorted(transformed.keys()) == sorted(expected.keys()))
|
||||||
for k, v in transformed.items():
|
for k, v in transformed.items():
|
||||||
assert(v == expected[k])
|
assert (v == expected[k])
|
||||||
test_extract_memory_reports()
|
test_extract_memory_reports()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ def print_help():
|
||||||
|
|
||||||
|
|
||||||
def servo_ready_to_accept(url, payload, headers):
|
def servo_ready_to_accept(url, payload, headers):
|
||||||
while(True):
|
while (True):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Before sending an additional request, we wait for one second each time
|
# Before sending an additional request, we wait for one second each time
|
||||||
|
|
|
@ -476,7 +476,7 @@ def check_shell(file_name, lines):
|
||||||
if next_idx < len(stripped):
|
if next_idx < len(stripped):
|
||||||
next_char = stripped[next_idx]
|
next_char = stripped[next_idx]
|
||||||
if not (next_char == '{' or next_char == '('):
|
if not (next_char == '{' or next_char == '('):
|
||||||
yield(idx + 1, "variable substitutions should use the full \"${VAR}\" form")
|
yield (idx + 1, "variable substitutions should use the full \"${VAR}\" form")
|
||||||
|
|
||||||
|
|
||||||
def rec_parse(current_path, root_node):
|
def rec_parse(current_path, root_node):
|
||||||
|
@ -491,7 +491,7 @@ def rec_parse(current_path, root_node):
|
||||||
|
|
||||||
def check_manifest_dirs(config_file, print_text=True):
|
def check_manifest_dirs(config_file, print_text=True):
|
||||||
if not os.path.exists(config_file):
|
if not os.path.exists(config_file):
|
||||||
yield(config_file, 0, "%s manifest file is required but was not found" % config_file)
|
yield (config_file, 0, "%s manifest file is required but was not found" % config_file)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Load configs from include.ini
|
# Load configs from include.ini
|
||||||
|
@ -508,7 +508,7 @@ def check_manifest_dirs(config_file, print_text=True):
|
||||||
if '_mozilla' in path or '_webgl' in path or '_webgpu' in path:
|
if '_mozilla' in path or '_webgl' in path or '_webgpu' in path:
|
||||||
continue
|
continue
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
yield(config_file, idx + 1, "Path in manifest was not found: {}".format(path))
|
yield (config_file, idx + 1, "Path in manifest was not found: {}".format(path))
|
||||||
|
|
||||||
|
|
||||||
def check_rust(file_name, lines):
|
def check_rust(file_name, lines):
|
||||||
|
@ -647,14 +647,14 @@ def check_rust(file_name, lines):
|
||||||
features = list(map(lambda w: w.strip(), match.group(1).split(',')))
|
features = list(map(lambda w: w.strip(), match.group(1).split(',')))
|
||||||
sorted_features = sorted(features)
|
sorted_features = sorted(features)
|
||||||
if sorted_features != features and check_alphabetical_order:
|
if sorted_features != features and check_alphabetical_order:
|
||||||
yield(idx + 1, decl_message.format("feature attribute")
|
yield (idx + 1, decl_message.format("feature attribute")
|
||||||
+ decl_expected.format(tuple(sorted_features))
|
+ decl_expected.format(tuple(sorted_features))
|
||||||
+ decl_found.format(tuple(features)))
|
+ decl_found.format(tuple(features)))
|
||||||
|
|
||||||
if prev_feature_name > sorted_features[0] and check_alphabetical_order:
|
if prev_feature_name > sorted_features[0] and check_alphabetical_order:
|
||||||
yield(idx + 1, decl_message.format("feature attribute")
|
yield (idx + 1, decl_message.format("feature attribute")
|
||||||
+ decl_expected.format(prev_feature_name + " after " + sorted_features[0])
|
+ decl_expected.format(prev_feature_name + " after " + sorted_features[0])
|
||||||
+ decl_found.format(prev_feature_name + " before " + sorted_features[0]))
|
+ decl_found.format(prev_feature_name + " before " + sorted_features[0]))
|
||||||
|
|
||||||
prev_feature_name = sorted_features[0]
|
prev_feature_name = sorted_features[0]
|
||||||
else:
|
else:
|
||||||
|
@ -678,9 +678,9 @@ def check_rust(file_name, lines):
|
||||||
if match == -1 and not line.endswith(";"):
|
if match == -1 and not line.endswith(";"):
|
||||||
yield (idx + 1, "mod declaration spans multiple lines")
|
yield (idx + 1, "mod declaration spans multiple lines")
|
||||||
if prev_mod[indent] and mod < prev_mod[indent] and check_alphabetical_order:
|
if prev_mod[indent] and mod < prev_mod[indent] and check_alphabetical_order:
|
||||||
yield(idx + 1, decl_message.format("mod declaration")
|
yield (idx + 1, decl_message.format("mod declaration")
|
||||||
+ decl_expected.format(prev_mod[indent])
|
+ decl_expected.format(prev_mod[indent])
|
||||||
+ decl_found.format(mod))
|
+ decl_found.format(mod))
|
||||||
prev_mod[indent] = mod
|
prev_mod[indent] = mod
|
||||||
else:
|
else:
|
||||||
# we now erase previous entries
|
# we now erase previous entries
|
||||||
|
@ -695,9 +695,9 @@ def check_rust(file_name, lines):
|
||||||
# sort, compare and report
|
# sort, compare and report
|
||||||
sorted_derives = sorted(derives)
|
sorted_derives = sorted(derives)
|
||||||
if sorted_derives != derives and check_alphabetical_order:
|
if sorted_derives != derives and check_alphabetical_order:
|
||||||
yield(idx + 1, decl_message.format("derivable traits list")
|
yield (idx + 1, decl_message.format("derivable traits list")
|
||||||
+ decl_expected.format(", ".join(sorted_derives))
|
+ decl_expected.format(", ".join(sorted_derives))
|
||||||
+ decl_found.format(", ".join(derives)))
|
+ decl_found.format(", ".join(derives)))
|
||||||
|
|
||||||
|
|
||||||
# Avoid flagging <Item=Foo> constructs
|
# Avoid flagging <Item=Foo> constructs
|
||||||
|
|
|
@ -271,7 +271,7 @@ class TrackerDashboardFilter():
|
||||||
except urllib.error.HTTPError as e:
|
except urllib.error.HTTPError as e:
|
||||||
print(e)
|
print(e)
|
||||||
print(e.readlines())
|
print(e.readlines())
|
||||||
raise(e)
|
raise (e)
|
||||||
|
|
||||||
for result in unexpected_results:
|
for result in unexpected_results:
|
||||||
result.issues = known_intermittents.get(result.path, [])
|
result.issues = known_intermittents.get(result.path, [])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue