From f6449de7c9d4524f858b1ef1afa48f8aa2fbcf37 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:43:57 +0100 Subject: [PATCH] STY: Apply ruff/flake8-comprehensions preview rule C409 C409 Unnecessary list comprehension passed to `tuple()` (rewrite as a generator) --- niworkflows/interfaces/bids.py | 8 ++------ niworkflows/reports/core.py | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/niworkflows/interfaces/bids.py b/niworkflows/interfaces/bids.py index 0dbfbae52ec..ec7131dff3a 100644 --- a/niworkflows/interfaces/bids.py +++ b/niworkflows/interfaces/bids.py @@ -647,9 +647,7 @@ def _run_interface(self, runtime): if self.inputs.check_hdr: hdr = nii.header - curr_units = tuple( - [None if u == 'unknown' else u for u in hdr.get_xyzt_units()] - ) + curr_units = tuple(None if u == 'unknown' else u for u in hdr.get_xyzt_units()) curr_codes = (int(hdr['qform_code']), int(hdr['sform_code'])) # Default to mm, use sec if data type is bold @@ -1164,9 +1162,7 @@ def _run_interface(self, runtime): if self.inputs.check_hdr: hdr = nii.header - curr_units = tuple( - [None if u == 'unknown' else u for u in hdr.get_xyzt_units()] - ) + curr_units = tuple(None if u == 'unknown' else u for u in hdr.get_xyzt_units()) curr_codes = (int(hdr['qform_code']), int(hdr['sform_code'])) # Default to mm, use sec if data type is bold diff --git a/niworkflows/reports/core.py b/niworkflows/reports/core.py index 90348f39c1b..64bbe1888e8 100644 --- a/niworkflows/reports/core.py +++ b/niworkflows/reports/core.py @@ -454,9 +454,9 @@ def _process_orderings(orderings, layout): for bids_file in layout.get() } # remove the all None member if it exists - none_member = tuple([None for k in orderings]) + none_member = tuple(None for k in orderings) if none_member in all_value_combos: - all_value_combos.remove(tuple([None for k in orderings])) + all_value_combos.remove(tuple(None for k in orderings)) # see what values exist for each entity unique_values = [ {value[idx] for value in all_value_combos} for idx in range(len(orderings))