Skip to content

Commit

Permalink
[STYLE] Follow style conventions in variable names and functions calls
Browse files Browse the repository at this point in the history
- Avoid single character variables names outside list comprehension.
- Use a consistent pattern in function calls throughout the pull request.
  • Loading branch information
gkaf89 committed Jan 30, 2025
1 parent 5b5659a commit bf40ad9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
4 changes: 2 additions & 2 deletions easybuild/base/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ def assertNotExists(self, path, msg=None):

def assertAllExist(self, paths, msg=None):
"""Assert that all paths in the given list exist"""
for p in paths:
self.assertExists(p, msg)
for path in paths:
self.assertExists(path, msg)

def setUp(self):
"""Prepare test case."""
Expand Down
6 changes: 3 additions & 3 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4423,9 +4423,9 @@ def create_persistence_paths(operation_args):


def execute_and_log_persistence_operation(operation, source_paths, target_dir, msg, silent):
for p in source_paths:
if os.path.exists(p):
operation(p, target_dir)
for path in source_paths:
if os.path.exists(path):
operation(path, target_dir)
print_msg(msg, log=_log, silent=silent)


Expand Down
8 changes: 4 additions & 4 deletions easybuild/tools/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3126,8 +3126,8 @@ def get_first_nonexisting_parent_path(path):


def _delete_directories(paths):
for p in paths:
shutil.rmtree(p, ignore_errors=True)
for path in paths:
shutil.rmtree(path, ignore_errors=True)


def create_unused_dirs(paths, index_upper_bound=10000):
Expand Down Expand Up @@ -3175,7 +3175,7 @@ def create_unused_dirs(paths, index_upper_bound=10000):
raise EasyBuildError(f"Exceeded maximum number of attempts ({number}) to generate unique directories.")

# set group ID and sticky bits, if desired
for p in first_nonexisting_parent_paths:
set_gid_sticky_bits(p, recursive=True)
for path in first_nonexisting_parent_paths:
set_gid_sticky_bits(path, recursive=True)

return final_paths
18 changes: 10 additions & 8 deletions test/framework/filetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3825,8 +3825,8 @@ def test_create_unused_dirs(self):
os.path.join(test_root, 'folder_a'),
os.path.join(test_root, 'folder_b'),
]
for p in requested_paths:
os.mkdir(p)
for path in requested_paths:
os.mkdir(path)
for i in range(10):
paths = ft.create_unused_dirs(requested_paths)
self.assertEqual(paths, [f"{p}_{i}" for p in requested_paths])
Expand Down Expand Up @@ -3856,11 +3856,11 @@ def test_create_unused_dirs(self):

os.mkdir(os.path.join(test_root, f"existing_idx_b_{existing_idx}"))

def expected_idx(n):
if n == 0:
def expected_idx(n_calls_to_create_unused_dirs):
if n_calls_to_create_unused_dirs == 0:
return ""
new_idx = n - 1
if n > existing_idx:
new_idx = n_calls_to_create_unused_dirs - 1
if n_calls_to_create_unused_dirs > existing_idx:
new_idx += 1
return f"_{new_idx}"

Expand Down Expand Up @@ -3901,8 +3901,10 @@ def expected_idx(n):
ft.adjust_permissions(readonly_dir, stat.S_IREAD | stat.S_IEXEC, relative=False)
requested_path = [os.path.join(readonly_dir, "new_folder")]
try:
self.assertErrorRegex(EasyBuildError, "Failed to create directory",
ft.create_unused_dirs, requested_path)
self.assertErrorRegex(
EasyBuildError, "Failed to create directory",
ft.create_unused_dirs, requested_path
)
finally:
ft.adjust_permissions(readonly_dir, old_perms, relative=False)
shutil.rmtree(test_root)
Expand Down
12 changes: 8 additions & 4 deletions test/framework/toy_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,15 @@ def test_toy_broken_compilation(self):

base_ec = os.path.join(
os.path.dirname(__file__),
'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb')
'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb'
)

base_ec_txt = read_file(base_ec)
broken_compilation_ec_txt = re.sub(
r'toy-0\.0_fix-silly-typo-in-printf-statement\.patch',
r'toy-0.0_add-bug.patch',
base_ec_txt)
base_ec_txt
)
broken_compilation_ec = os.path.join(tmp_easyconfig_dir, 'toy-0.0-buggy.eb')
write_file(broken_compilation_ec, broken_compilation_ec_txt)

Expand All @@ -375,8 +377,10 @@ def test_toy_broken_compilation(self):

output_regexs = [r"^\s*toy\.c:5:44: error: expected (;|.;.) before"]

self.check_errorlog(output_regexs, outtxt, tmp_log_dir,
self.test_buildpath, tmp_log_error_dir, tmp_artifact_error_dir)
self.check_errorlog(
output_regexs, outtxt, tmp_log_dir,
self.test_buildpath, tmp_log_error_dir, tmp_artifact_error_dir
)

def test_toy_tweaked(self):
"""Test toy build with tweaked easyconfig, for testing extra easyconfig parameters."""
Expand Down

0 comments on commit bf40ad9

Please sign in to comment.