Skip to content

Commit 56b8c93

Browse files
STY: Apply ruff/flake8-pie rule PIE810
PIE810 Call `endswith` once with a `tuple`
1 parent cd4ef59 commit 56b8c93

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

nipype/interfaces/dcm2nii.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,7 @@ def _parse_files(self, filenames):
472472
# search for relevant files, and sort accordingly
473473
for fl in search_files(filename, outtypes, self.inputs.crop):
474474
if (
475-
fl.endswith(".nii")
476-
or fl.endswith(".gz")
477-
or fl.endswith(".nrrd")
478-
or fl.endswith(".nhdr")
475+
fl.endswith((".nii", ".gz", ".nrrd", ".nhdr"))
479476
):
480477
outfiles.append(fl)
481478
elif fl.endswith(".bval"):
@@ -484,7 +481,7 @@ def _parse_files(self, filenames):
484481
bvecs.append(fl)
485482
elif fl.endswith(".mvec"):
486483
mvecs.append(fl)
487-
elif fl.endswith(".json") or fl.endswith(".txt"):
484+
elif fl.endswith((".json", ".txt")):
488485
bids.append(fl)
489486

490487
# in siemens mosaic conversion nipype misread dcm2niix output and generate a duplicate list of results

nipype/interfaces/freesurfer/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2836,7 +2836,7 @@ def _format_arg(self, name, spec, value):
28362836
suffix = basename.split(".")[1]
28372837
return spec.argstr % suffix
28382838
elif name == "in_orig":
2839-
if value.endswith("lh.orig") or value.endswith("rh.orig"):
2839+
if value.endswith(("lh.orig", "rh.orig")):
28402840
# {lh,rh}.orig inputs are not specified on command line
28412841
return
28422842
else:

nipype/utils/filemanip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def load_json(filename):
566566

567567

568568
def loadcrash(infile, *args):
569-
if infile.endswith("pkl") or infile.endswith("pklz"):
569+
if infile.endswith(("pkl", "pklz")):
570570
return loadpkl(infile)
571571
else:
572572
raise ValueError("Only pickled crashfiles are supported")

0 commit comments

Comments
 (0)