From ed7ec5158be766ec2596e6a0cf5b2a7a1d13641f Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:37:14 +0100 Subject: [PATCH 1/3] STY: Apply ruff/refurb rule FURB113 FURB113 Use `.extend(...)` instead of repeatedly calling `.append()` --- niworkflows/utils/tests/test_utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/niworkflows/utils/tests/test_utils.py b/niworkflows/utils/tests/test_utils.py index 952c55533fa..7890b5acfed 100644 --- a/niworkflows/utils/tests/test_utils.py +++ b/niworkflows/utils/tests/test_utils.py @@ -83,12 +83,13 @@ def test_clean_symlink(tmp_path): def _gen_skeleton(root): - dirs, files = [], [] - files.append(root / 'file1') - files.append(root / '.file2') - dirs.append(root / 'subdir1') - files.append(dirs[0] / 'file3') - files.append(dirs[0] / '.file4') + dirs = [root / 'subdir1'] + files = [ + root / 'file1', + root / '.file2', + dirs[0] / 'file3', + dirs[0] / '.file4', + ] for d in dirs: d.mkdir() for f in files: From 6798eab8f1451246848d345d8fa79a3e3f9f2d36 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:39:29 +0100 Subject: [PATCH 2/3] STY: Apply ruff/refurb rule FURB188 FURB188 Prefer `removeprefix` over conditionally replacing with slice. --- niworkflows/reports/core.py | 2 +- niworkflows/utils/bids.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/niworkflows/reports/core.py b/niworkflows/reports/core.py index f6f5a6ffd3a..54cfbb6bdd3 100644 --- a/niworkflows/reports/core.py +++ b/niworkflows/reports/core.py @@ -285,7 +285,7 @@ def __init__( self.packagename = packagename self.subject_id = subject_id if subject_id is not None: - self.subject_id = subject_id[4:] if subject_id.startswith('sub-') else subject_id + self.subject_id = subject_id.removeprefix('sub-') self.out_filename = f'sub-{self.subject_id}.html' # Default template from niworkflows diff --git a/niworkflows/utils/bids.py b/niworkflows/utils/bids.py index 621d642055e..d1cbc997e60 100644 --- a/niworkflows/utils/bids.py +++ b/niworkflows/utils/bids.py @@ -134,7 +134,7 @@ def collect_participants(bids_dir, participant_label=None, strict=False, bids_va participant_label = [participant_label] # Drop sub- prefixes - participant_label = [sub[4:] if sub.startswith('sub-') else sub for sub in participant_label] + participant_label = [sub.removeprefix('sub-') for sub in participant_label] # Remove duplicates participant_label = sorted(set(participant_label)) # Remove labels not found From 1f432a70a86d9f841aa27bffcbe97ccfbcc8b505 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sun, 2 Mar 2025 14:32:49 +0100 Subject: [PATCH 3/3] SYT: Disable ruff/refurb rule FURB118 FURB118 Use `operator.add` instead of defining a function --- niworkflows/engine/tests/test_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/niworkflows/engine/tests/test_plugin.py b/niworkflows/engine/tests/test_plugin.py index 4ac852aee2c..7f3f5de5f3b 100644 --- a/niworkflows/engine/tests/test_plugin.py +++ b/niworkflows/engine/tests/test_plugin.py @@ -8,7 +8,7 @@ from ..plugin import MultiProcPlugin -def add(x, y): +def add(x, y): # noqa: FURB118 # the Function interface does not support builtin functions return x + y