Skip to content

Commit 453fa77

Browse files
STY: Apply ruff/flake8-bugbear rule B006
B006 Do not use mutable data structures for argument defaults
1 parent 289b4fd commit 453fa77

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

nipype/interfaces/ants/resampling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def _list_outputs(self):
138138
)
139139
return outputs
140140

141-
def _run_interface(self, runtime, correct_return_codes=[0]):
142-
runtime = super()._run_interface(runtime, correct_return_codes=[0, 1])
141+
def _run_interface(self, runtime, correct_return_codes=(0,)):
142+
runtime = super()._run_interface(runtime, correct_return_codes=(0, 1))
143143
if "100 % complete" not in runtime.stdout:
144144
self.raise_exception(runtime)
145145
return runtime

nipype/interfaces/ants/segmentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ def _format_arg(self, opt, spec, val):
770770
return retval
771771
return super()._format_arg(opt, spec, val)
772772

773-
def _run_interface(self, runtime, correct_return_codes=[0]):
773+
def _run_interface(self, runtime, correct_return_codes=(0,)):
774774
priors_directory = os.path.join(os.getcwd(), "nipype_priors")
775775
if not os.path.exists(priors_directory):
776776
os.makedirs(priors_directory)

nipype/interfaces/dipy/simulate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def _compute_voxel(args):
319319
return signal.tolist()
320320

321321

322-
def _generate_gradients(ndirs=64, values=[1000, 3000], nb0s=1):
322+
def _generate_gradients(ndirs=64, values=(1000, 3000), nb0s=1):
323323
"""
324324
Automatically generate a `gradient table
325325
<http://nipy.org/dipy/examples_built/gradients_spheres.html#example-gradients-spheres>`_

nipype/interfaces/io.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2790,8 +2790,9 @@ class JSONFileSink(IOBase):
27902790
input_spec = JSONFileSinkInputSpec
27912791
output_spec = JSONFileSinkOutputSpec
27922792

2793-
def __init__(self, infields=[], force_run=True, **inputs):
2793+
def __init__(self, infields=None, force_run=True, **inputs):
27942794
super().__init__(**inputs)
2795+
infields = infields or []
27952796
self._input_names = infields
27962797

27972798
undefined_traits = {}

nipype/interfaces/slicer/generate_classes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ def configuration(parent_package='',top_path=None):
118118

119119

120120
def generate_all_classes(
121-
modules_list=[], launcher=[], redirect_x=False, mipav_hacks=False
121+
modules_list=None, launcher=None, redirect_x=False, mipav_hacks=False
122122
):
123123
"""modules_list contains all the SEM compliant tools that should have wrappers created for them.
124124
launcher containtains the command line prefix wrapper arguments needed to prepare
125125
a proper environment for each of the modules.
126126
"""
127+
modules_list = modules_list or []
128+
launcher = launcher or []
127129
all_code = {}
128130
for module in modules_list:
129131
print("=" * 80)

nipype/utils/docparse.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def get_doc(cmd, opt_map, help_flag=None, trap_error=True):
257257
return build_doc(doc, opts)
258258

259259

260-
def _parse_doc(doc, style=["--"]):
260+
def _parse_doc(doc, style=None):
261261
"""Parses a help doc for inputs
262262
263263
Parameters
@@ -276,7 +276,9 @@ def _parse_doc(doc, style=["--"]):
276276
# individual flag/option.
277277
doclist = doc.split("\n")
278278
optmap = {}
279-
if isinstance(style, (str, bytes)):
279+
if style is None:
280+
style = ["--"]
281+
elif isinstance(style, (str, bytes)):
280282
style = [style]
281283
for line in doclist:
282284
linelist = line.split()

nipype/utils/draw_gantt_chart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def generate_gantt_chart(
407407
cores,
408408
minute_scale=10,
409409
space_between_minutes=50,
410-
colors=["#7070FF", "#4E4EB2", "#2D2D66", "#9B9BFF"],
410+
colors=("#7070FF", "#4E4EB2", "#2D2D66", "#9B9BFF"),
411411
):
412412
"""
413413
Generates a gantt chart in html showing the workflow execution based on a callback log file.

0 commit comments

Comments
 (0)