8000 STY: Apply ruff/flake8-comprehensions rules (C4) by DimitriPapadopoulos · Pull Request #3680 · nipy/nipype · GitHub
[go: up one dir, main page]

Skip to content

STY: Apply ruff/flake8-comprehensions rules (C4) #3680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
STY: Apply ruff/flake8-comprehensions rule C419
C419 Unnecessary list comprehension
  • Loading branch information
DimitriPapadopoulos committed Oct 6, 2024
commit 43fb83981b6ff6bf16e253cd9470720dd5e43c90
2 changes: 1 addition & 1 deletion nipype/interfaces/ants/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,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 @@ -692,11 +692,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/fsl/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,8 +1503,8 @@ def _run_interface(self, runtime):
regs = sorted(self.inputs.regressors.keys())
nwaves = len(regs)
npoints = len(self.inputs.regressors[regs[0]])
ntcons = sum([1 for con in self.inputs.contrasts if con[1] == "T"])
nfcons = sum([1 for con in self.inputs.contrasts if con[1] == "F"])
ntcons = sum(1 for con in self.inputs.contrasts if con[1] == "T")
nfcons = sum(1 for con in self.inputs.contrasts if con[1] == "F")
# write mat file
mat_txt = ["/NumWaves %d" % nwaves, "/NumPoints %d" % npoints]
ppheights = []
Expand Down Expand Up @@ -1591,7 +1591,7 @@ def _run_interface(self, runtime):

def _list_outputs(self):
outputs = self._outputs().get()
nfcons = sum([1 for con in self.inputs.contrasts if con[1] == "F"])
nfcons = sum(1 for con in self.inputs.contrasts if con[1] == "F")
for field in list(outputs.keys()):
if ("fts" in field) and (nfcons == 0):
continue
Expand Down
6 changes: 3 additions & 3 deletions nipype/interfaces/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,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 @@ -1297,7 +1297,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 @@ -2642,7 +2642,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]):
D7AE
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