Skip to content

Commit 72a944e

Browse files
authored
Merge pull request #3678 from DimitriPapadopoulos/PIE
STY: Apply ruff/flake8-pie rules (PIE)
2 parents aeb988c + 3980037 commit 72a944e

File tree

17 files changed

+15
-27
lines changed

17 files changed

+15
-27
lines changed

nipype/algorithms/misc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def _run_interface(self, runtime):
714714
mx = shape[0]
715715
else:
716716
mx = 1
717-
for idx in range(0, mx):
717+
for idx in range(mx):
718718
extrafieldlist.append(self.inputs.extra_field)
719719
iflogger.info(len(extrafieldlist))
720720
output[extraheading] = extrafieldlist

nipype/interfaces/ants/registration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ def _format_metric(self, index):
10731073
# from the non-list inputs.
10741074
if isinstance(name_input, list):
10751075
items = list(stage_inputs.items())
1076-
indexes = list(range(0, len(name_input)))
1076+
indexes = list(range(len(name_input)))
10771077
specs = list()
10781078
for i in indexes:
10791079
temp = {k: v[i] for k, v in items}

nipype/interfaces/cmtk/cmtk.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def length(xyz, along=False):
7272
def get_rois_crossed(pointsmm, roiData, voxelSize):
7373
n_points = len(pointsmm)
7474
rois_crossed = []
75-
for j in range(0, n_points):
75+
for j in range(n_points):
7676
# store point
7777
x = int(pointsmm[j, 0] / float(voxelSize[0]))
7878
y = int(pointsmm[j, 1] / float(voxelSize[1]))
@@ -894,7 +894,7 @@ def _run_interface(self, runtime):
894894
iflogger.info("Number of labels in LUT: %s", numLUTLabels)
895895
LUTlabelDict = {}
896896
""" Create dictionary for input LUT table"""
897-
for labels in range(0, numLUTLabels):
897+
for labels in range(numLUTLabels):
898898
LUTlabelDict[LUTlabelsRGBA[labels][0]] = [
899899
LUTlabelsRGBA[labels][1],
900900
LUTlabelsRGBA[labels][2],

nipype/interfaces/cmtk/nx.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def add_edge_data(edge_array, ntwk, above=0, below=0):
353353
edge_ntwk = ntwk.copy()
354354
data = {}
355355
for x, row in enumerate(edge_array):
356-
for y in range(0, np.max(np.shape(edge_array[x]))):
356+
for y in range(np.max(np.shape(edge_array[x]))):
357357
if not edge_array[x, y] == 0:
358358
data["value"] = edge_array[x, y]
359359
if data["value"] <= below or data["value"] >= above:

nipype/interfaces/dcm2nii.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -471,20 +471,15 @@ def _parse_files(self, filenames):
471471
for filename in filenames:
472472
# search for relevant files, and sort accordingly
473473
for fl in search_files(filename, outtypes, self.inputs.crop):
474-
if (
475-
fl.endswith(".nii")
476-
or fl.endswith(".gz")
477-
or fl.endswith(".nrrd")
478-
or fl.endswith(".nhdr")
479-
):
474+
if fl.endswith((".nii", ".gz", ".nrrd", ".nhdr")):
480475
outfiles.append(fl)
481476
elif fl.endswith(".bval"):
482477
bvals.append(fl)
483478
elif fl.endswith(".bvec"):
484479
bvecs.append(fl)
485480
elif fl.endswith(".mvec"):
486481
mvecs.append(fl)
487-
elif fl.endswith(".json") or fl.endswith(".txt"):
482+
elif fl.endswith((".json", ".txt")):
488483
bids.append(fl)
489484

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

nipype/interfaces/dipy/reconstruction.py

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def _run_interface(self, runtime):
136136
)
137137
except:
138138
bias = 0.0
139-
pass
140139

141140
sigma = mean_std * (1 + bias)
142141

nipype/interfaces/dipy/simulate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def _generate_gradients(ndirs=64, values=[1000, 3000], nb0s=1):
344344
bvecs = np.vstack((bvecs, vertices))
345345
bvals = np.hstack((bvals, v * np.ones(vertices.shape[0])))
346346

347-
for i in range(0, nb0s):
347+
for i in range(nb0s):
348348
bvals = bvals.tolist()
349349
bvals.insert(0, 0)
350350

nipype/interfaces/freesurfer/preprocess.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def _list_outputs(self):
580580
stem = ".".join(outfile.split(".")[:-1])
581581
ext = "." + outfile.split(".")[-1]
582582
outfile = []
583-
for idx in range(0, tp):
583+
for idx in range(tp):
584584
outfile.append(stem + "%04d" % idx + ext)
585585
if isdefined(self.inputs.out_type):
586586
if self.inputs.out_type in ["spm", "analyze"]:

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/interfaces/fsl/model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def _create_ev_files(
259259
# add ev orthogonalization
260260
for i in range(1, num_evs[0] + 1):
261261
initial = ev_ortho.substitute(c0=i, c1=0, orthogonal=1)
262-
for j in range(0, num_evs[0] + 1):
262+
for j in range(num_evs[0] + 1):
263263
try:
264264
orthogonal = int(orthogonalization[i][j])
265265
except (KeyError, TypeError, ValueError, IndexError):

nipype/interfaces/mrtrix3/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def _format_arg(self, name, trait_spec, value):
103103
value = cpu_count()
104104
except:
105105
iflogger.warning("Number of threads could not be computed")
106-
pass
107106
return trait_spec.argstr % value
108107

109108
if name == "in_bvec":

nipype/pipeline/engine/tests/test_engine.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def func1(in1):
356356
# check that multiple json's don't trigger rerun
357357
with open(os.path.join(node.output_dir(), "test.json"), "w") as fp:
358358
fp.write("dummy file")
359-
w1.config["execution"].update(**{"stop_on_first_rerun": True})
359+
w1.config["execution"].update(stop_on_first_rerun=True)
360360

361361
w1.run()
362362

nipype/pipeline/plugins/sge.py

-4
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ def _qacct_verified_complete(taskid):
184184
except:
185185
sge_debug_print("NOTE: qacct call failed")
186186
time.sleep(5)
187-
pass
188187
return is_complete
189188

190189
def _parse_qstat_job_list(self, xml_job_list):
@@ -259,7 +258,6 @@ def _parse_qstat_job_list(self, xml_job_list):
259258
dictionary_job, self._task_dictionary[dictionary_job]
260259
)
261260
)
262-
pass
263261
if self._task_dictionary[dictionary_job].is_initializing():
264262
is_completed = self._qacct_verified_complete(dictionary_job)
265263
if is_completed:
@@ -271,7 +269,6 @@ def _parse_qstat_job_list(self, xml_job_list):
271269
dictionary_job, self._task_dictionary[dictionary_job]
272270
)
273271
)
274-
pass
275272

276273
def _run_qstat(self, reason_for_qstat, force_instant=True):
277274
"""request all job information for the current user in xmlformat.
@@ -320,7 +317,6 @@ def _run_qstat(self, reason_for_qstat, force_instant=True):
320317
)
321318
sge_debug_print(exception_message)
322319
time.sleep(5)
323-
pass
324320

325321
def print_dictionary(self):
326322
"""For debugging"""

nipype/pipeline/plugins/tests/test_legacymultiproc_nondaemon.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def dummyFunction(filename):
4040
This function writes the value 45 to the given filename.
4141
"""
4242
j = 0
43-
for i in range(0, 10):
43+
for i in range(10):
4444
j += i
4545

4646
# j is now 45 (0+1+2+3+4+5+6+7+8+9)

nipype/utils/draw_gantt_chart.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"Pandas not found; in order for full functionality of this module "
2121
"install the pandas package"
2222
)
23-
pass
2423

2524

2625
def create_event_dict(start_time, nodes_list):

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")

nipype/utils/nipype2boutiques.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def get_boutiques_input(
288288
if handler_type == "TraitCompound":
289289
input_list = []
290290
# Recursively create an input for each trait
291-
for i in range(0, len(trait_handler.handlers)):
291+
for i in range(len(trait_handler.handlers)):
292292
inp = get_boutiques_input(
293293
inputs,
294294
interface,

0 commit comments

Comments
 (0)