refactor: ran pyupgrade second iteration (#27463)
This commit is contained in:
@@ -131,7 +131,7 @@ class TestPaverThemeAssetTasks(PaverTestCase):
|
||||
expected_messages.append('mkdir_p ' + repr(TEST_THEME_DIR / 'lms/static/css'))
|
||||
if force:
|
||||
expected_messages.append(
|
||||
'rm -rf {test_theme_dir}/lms/static/css/*.css'.format(test_theme_dir=str(TEST_THEME_DIR))
|
||||
f'rm -rf {str(TEST_THEME_DIR)}/lms/static/css/*.css'
|
||||
)
|
||||
expected_messages.append("libsass lms/static/sass")
|
||||
expected_messages.append(
|
||||
@@ -148,10 +148,10 @@ class TestPaverThemeAssetTasks(PaverTestCase):
|
||||
)
|
||||
if force:
|
||||
expected_messages.append(
|
||||
'rm -rf {test_theme_dir}/lms/static/css/*.css'.format(test_theme_dir=str(TEST_THEME_DIR))
|
||||
f'rm -rf {str(TEST_THEME_DIR)}/lms/static/css/*.css'
|
||||
)
|
||||
expected_messages.append(
|
||||
'libsass {test_theme_dir}/lms/static/sass'.format(test_theme_dir=str(TEST_THEME_DIR))
|
||||
f'libsass {str(TEST_THEME_DIR)}/lms/static/sass'
|
||||
)
|
||||
if force:
|
||||
expected_messages.append('rm -rf lms/static/css/*.css')
|
||||
@@ -171,7 +171,7 @@ class TestPaverThemeAssetTasks(PaverTestCase):
|
||||
expected_messages.append('mkdir_p ' + repr(TEST_THEME_DIR / 'cms/static/css'))
|
||||
if force:
|
||||
expected_messages.append(
|
||||
'rm -rf {test_theme_dir}/cms/static/css/*.css'.format(test_theme_dir=str(TEST_THEME_DIR))
|
||||
f'rm -rf {str(TEST_THEME_DIR)}/cms/static/css/*.css'
|
||||
)
|
||||
expected_messages.append('libsass cms/static/sass')
|
||||
expected_messages.append(
|
||||
@@ -182,10 +182,10 @@ class TestPaverThemeAssetTasks(PaverTestCase):
|
||||
)
|
||||
if force:
|
||||
expected_messages.append(
|
||||
'rm -rf {test_theme_dir}/cms/static/css/*.css'.format(test_theme_dir=str(TEST_THEME_DIR))
|
||||
f'rm -rf {str(TEST_THEME_DIR)}/cms/static/css/*.css'
|
||||
)
|
||||
expected_messages.append(
|
||||
'libsass {test_theme_dir}/cms/static/sass'.format(test_theme_dir=str(TEST_THEME_DIR))
|
||||
f'libsass {str(TEST_THEME_DIR)}/cms/static/sass'
|
||||
)
|
||||
if force:
|
||||
expected_messages.append('rm -rf cms/static/css/*.css')
|
||||
|
||||
@@ -109,7 +109,7 @@ class TestGenerate(TestCase):
|
||||
pof = pofile(path)
|
||||
pattern = re.compile('^#-#-#-#-#', re.M)
|
||||
match = pattern.findall(pof.header)
|
||||
assert len(match) == 3, ('Found {} (should be 3) merge comments in the header for {}'.format(len(match), path))
|
||||
assert len(match) == 3, (f'Found {len(match)} (should be 3) merge comments in the header for {path}')
|
||||
|
||||
|
||||
def random_name(size=6):
|
||||
|
||||
@@ -24,7 +24,7 @@ def display(message): # lint-amnesty, pylint: disable=missing-function-docstrin
|
||||
if message.get('event'):
|
||||
event = json.loads(message['event'])
|
||||
for k in sorted(event):
|
||||
print('\t{}: {}'.format(k, event[k]))
|
||||
print(f'\t{k}: {event[k]}')
|
||||
print()
|
||||
|
||||
while 1:
|
||||
|
||||
@@ -383,4 +383,4 @@ if __name__ == "__main__":
|
||||
if len(course_data) > 0:
|
||||
write_block_summary_report(course_data)
|
||||
write_course_block_detail_report(course_data)
|
||||
print('Start time: {} Total run time: {}'.format(str(start_time), str(datetime.now() - start_time)))
|
||||
print(f'Start time: {str(start_time)} Total run time: {str(datetime.now() - start_time)}')
|
||||
|
||||
@@ -77,7 +77,7 @@ def main(log_file, test_suite, fast, verbose):
|
||||
|
||||
test_list_with_failures, pytest_command = _find_fewest_tests_with_failures(failing_test_list, 'ALL')
|
||||
if test_list_with_failures:
|
||||
print('Found failures running {} tests.'.format(len(test_list_with_failures)))
|
||||
print(f'Found failures running {len(test_list_with_failures)} tests.')
|
||||
print(f'Use: {pytest_command}')
|
||||
return
|
||||
|
||||
@@ -102,7 +102,7 @@ def _strip_console_for_tests_with_failure(log_file, test_suite):
|
||||
worker_test_dict = {}
|
||||
test_base_included = {}
|
||||
failing_worker_num = None
|
||||
with open(log_file, 'r') as console_file:
|
||||
with open(log_file) as console_file:
|
||||
for line in console_file:
|
||||
regex_search = re.search(fr'\[gw(\d+)] (PASSED|FAILED|SKIPPED|ERROR) (\S+)', line)
|
||||
if regex_search:
|
||||
@@ -159,7 +159,7 @@ def _create_and_check_test_files_for_failures(test_list, test_type):
|
||||
|
||||
Returns the pytest command to run if failures are found.
|
||||
"""
|
||||
print("Testing {}, includes {} test(s)...".format(test_type, len(test_list)))
|
||||
print(f"Testing {test_type}, includes {len(test_list)} test(s)...")
|
||||
global test_suite_option
|
||||
output_file_name = "{}_failing_test_list_{}_{}.txt".format(
|
||||
OUTPUT_FOLDER_NAME, test_suite_option, test_type, len(test_list)
|
||||
|
||||
@@ -30,7 +30,7 @@ import click
|
||||
)
|
||||
def main(log_file, test_suite):
|
||||
worker_test_dict = {}
|
||||
with open(log_file, 'r') as console_file:
|
||||
with open(log_file) as console_file:
|
||||
for line in console_file:
|
||||
regex_search = re.search(fr'\[gw(\d+)] (PASSED|FAILED|SKIPPED|ERROR) (\S+)', line)
|
||||
if regex_search:
|
||||
|
||||
@@ -100,7 +100,7 @@ class PytestWorkerManager():
|
||||
not_running.append(instance_info['InstanceId'])
|
||||
|
||||
if len(not_running) > 0:
|
||||
logger.info("Still waiting on {} workers to spin up".format(len(not_running)))
|
||||
logger.info(f"Still waiting on {len(not_running)} workers to spin up")
|
||||
time.sleep(5)
|
||||
else:
|
||||
logger.info("Finished spinning up workers")
|
||||
|
||||
@@ -53,7 +53,7 @@ class BaseLinter:
|
||||
A string containing the files contents.
|
||||
|
||||
"""
|
||||
with open(file_full_path, 'r') as input_file:
|
||||
with open(file_full_path) as input_file:
|
||||
file_contents = input_file.read()
|
||||
return file_contents
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ class SummaryResults:
|
||||
print("", file=out)
|
||||
for rule_id in sorted(self.totals_by_rule.keys()):
|
||||
padding = " " * (max_rule_id_len - len(rule_id))
|
||||
print("{}: {}{} violations".format(rule_id, padding, self.totals_by_rule[rule_id]), file=out)
|
||||
print(f"{rule_id}: {padding}{self.totals_by_rule[rule_id]} violations", file=out)
|
||||
print("", file=out)
|
||||
|
||||
# matches output of eslint for simplicity
|
||||
|
||||
@@ -20,7 +20,7 @@ def is_skip_dir(skip_dirs, directory):
|
||||
"""
|
||||
for skip_dir in skip_dirs:
|
||||
skip_dir_regex = re.compile(
|
||||
"(.*/)*{}(/.*)*".format(re.escape(skip_dir)))
|
||||
f"(.*/)*{re.escape(skip_dir)}(/.*)*")
|
||||
if skip_dir_regex.match(directory) is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user