Skip to content

Commit e01173d

Browse files
STY: Apply ruff rule RUF017
RUF017 Avoid quadratic list summation
1 parent 83e3903 commit e01173d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

nipype/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def get_nipype_gitversion():
187187

188188

189189
def _list_union(iterable):
190-
return list(set(sum(iterable, [])))
190+
return list(set(x for sublist in iterable for x in sublist))
191191

192192

193193
# Enable a handle to install all extra dependencies at once

nipype/interfaces/fsl/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,9 @@ class ExtractROI(FSLCommand):
483483

484484
def _format_arg(self, name, spec, value):
485485
if name == "crop_list":
486-
return " ".join(map(str, sum(list(map(list, value)), [])))
486+
return " ".join(
487+
map(str, (x for sublist in map(list, value) for x in sublist))
488+
)
487489
return super()._format_arg(name, spec, value)
488490

489491
def _list_outputs(self):

0 commit comments

Comments
 (0)