Skip to content

Commit

Permalink
STY: Apply ruff/flake8-comprehensions rule C419
Browse files Browse the repository at this point in the history
C419 Unnecessary list comprehension
  • Loading branch information
DimitriPapadopoulos committed Sep 22, 2024
1 parent fedef7a commit 8b4c8ef
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion nipype/interfaces/ants/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def _format_arg(self, opt, spec, val):
priors_paths[0] % i for i in range(1, n_classes + 1)
]

if not all([os.path.exists(p) for p in priors_paths]):
if not all(os.path.exists(p) for p in priors_paths):
raise FileNotFoundError(
"One or more prior images do not exist: "
"%s." % ", ".join(priors_paths)
Expand Down
4 changes: 2 additions & 2 deletions nipype/interfaces/freesurfer/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,11 +691,11 @@ def _get_runs(self):
if self.inputs.seq_list:
if self.inputs.ignore_single_slice:
if (int(s[8]) > 1) and any(
[s[12].startswith(sn) for sn in self.inputs.seq_list]
s[12].startswith(sn) for sn in self.inputs.seq_list
):
runs.append(int(s[2]))
else:
if any([s[12].startswith(sn) for sn in self.inputs.seq_list]):
if any(s[12].startswith(sn) for sn in self.inputs.seq_list):
runs.append(int(s[2]))
else:
runs.append(int(s[2]))
Expand Down
6 changes: 3 additions & 3 deletions nipype/interfaces/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ def _list_outputs(self):
if self.inputs.sort_filelist:
outfiles = human_order_sorted(outfiles)
outputs[key].append(simplify_list(outfiles))
if any([val is None for val in outputs[key]]):
if any(val is None for val in outputs[key]):
outputs[key] = []
if len(outputs[key]) == 0:
outputs[key] = None
Expand Down Expand Up @@ -1299,7 +1299,7 @@ def _list_outputs(self):
if self.inputs.drop_blank_outputs:
outputs[key] = [x for x in outputs[key] if x is not None]
else:
if any([val is None for val in outputs[key]]):
if any(val is None for val in outputs[key]):
outputs[key] = []
if len(outputs[key]) == 0:
outputs[key] = None
Expand Down Expand Up @@ -2644,7 +2644,7 @@ def _list_outputs(self):
outputs[key].append(self._get_files_over_ssh(filledtemplate))

# disclude where there was any invalid matches
if any([val is None for val in outputs[key]]):
if any(val is None for val in outputs[key]):
outputs[key] = []

# no outputs is None, not empty list
Expand Down
2 changes: 1 addition & 1 deletion nipype/pipeline/engine/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ def _collate_results(self, nodes):
)
setattr(finalresult.outputs, key, values)

if returncode and any([code is not None for code in returncode]):
if returncode and any(code is not None for code in returncode):
msg = []
for i, code in enumerate(returncode):
if code is not None:
Expand Down
2 changes: 1 addition & 1 deletion nipype/pipeline/engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ def clean_working_directory(
if f not in needed_files:
if not needed_dirs:
files2remove.append(f)
elif not any([f.startswith(dname) for dname in needed_dirs]):
elif not any(f.startswith(dname) for dname in needed_dirs):
files2remove.append(f)
else:
if not str2bool(config["execution"]["keep_inputs"]):
Expand Down
12 changes: 4 additions & 8 deletions nipype/pipeline/engine/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,8 @@ def connect(self, *args, **kwargs):
and (
".io" in str(destnode._interface.__class__)
or any(
[
".io" in str(val)
for val in destnode._interface.__class__.__bases__
]
".io" in str(val)
for val in destnode._interface.__class__.__bases__
)
)
):
Expand All @@ -205,10 +203,8 @@ def connect(self, *args, **kwargs):
and (
".io" in str(srcnode._interface.__class__)
or any(
[
".io" in str(val)
for val in srcnode._interface.__class__.__bases__
]
".io" in str(val)
for val in srcnode._interface.__class__.__bases__
)
)
):
Expand Down
2 changes: 1 addition & 1 deletion nipype/utils/docparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def _parse_doc(doc, style=["--"]):
flag = [
item
for i, item in enumerate(linelist)
if i < 2 and any([item.startswith(s) for s in style]) and len(item) > 1
if i < 2 and any(item.startswith(s) for s in style) and len(item) > 1
]
if flag:
if len(flag) == 1:
Expand Down
2 changes: 1 addition & 1 deletion nipype/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def trim(docstring, marker=None):
if (
marker is not None
and stripped
and all([s == stripped[0] for s in stripped])
and all(s == stripped[0] for s in stripped)
and stripped[0] not in [":"]
):
line = line.replace(stripped[0], marker)
Expand Down

0 comments on commit 8b4c8ef

Please sign in to comment.