Skip to content

Commit 4fa64e6

Browse files
authored
Merge pull request #3687 from DimitriPapadopoulos/PERF
STY: Apply ruff/Perflint rules (PERF) again
2 parents a1378d0 + 2edc66d commit 4fa64e6

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Diff for: nipype/pipeline/engine/utils.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -1479,19 +1479,21 @@ def clean_working_directory(
14791479
needed_files = temp
14801480
logger.debug("Needed files: %s", ";".join(needed_files))
14811481
logger.debug("Needed dirs: %s", ";".join(needed_dirs))
1482-
files2remove = []
14831482
if str2bool(config["execution"]["remove_unnecessary_outputs"]):
1484-
for f in walk_files(cwd):
1485-
if f not in needed_files and not f.startswith(tuple(needed_dirs)):
1486-
files2remove.append(f)
1483+
files2remove = [
1484+
f
1485+
for f in walk_files(cwd)
1486+
if f not in needed_files and not f.startswith(tuple(needed_dirs))
1487+
]
1488+
elif not str2bool(config["execution"]["keep_inputs"]):
1489+
input_files = {
1490+
path for path, type in walk_outputs(inputs.trait_get()) if type == "f"
1491+
}
1492+
files2remove = [
1493+
f for f in walk_files(cwd) if f in input_files and f not in needed_files
1494+
]
14871495
else:
1488-
if not str2bool(config["execution"]["keep_inputs"]):
1489-
input_files = {
1490-
path for path, type in walk_outputs(inputs.trait_get()) if type == "f"
1491-
}
1492-
files2remove.extend(
1493-
f for f in walk_files(cwd) if f in input_files and f not in needed_files
1494-
)
1496+
files2remove = []
14951497
logger.debug("Removing files: %s", ";".join(files2remove))
14961498
for f in files2remove:
14971499
os.remove(f)

0 commit comments

Comments
 (0)