From 3783ce75b2dd0b82097dd9387662556eb7597926 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:32:01 +0100 Subject: [PATCH] STY: Apply ruff/flynt rule FLY002 FLY002 Consider f-string instead of string join --- niworkflows/interfaces/bids.py | 8 ++------ niworkflows/utils/spaces.py | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/niworkflows/interfaces/bids.py b/niworkflows/interfaces/bids.py index ec7131dff3a..508574fb3bf 100644 --- a/niworkflows/interfaces/bids.py +++ b/niworkflows/interfaces/bids.py @@ -603,9 +603,7 @@ def _run_interface(self, runtime): if custom_entities: # Example: f"{key}-{{{key}}}" -> "task-{task}" custom_pat = '_'.join(f'{key}-{{{key}}}' for key in sorted(custom_entities)) - patterns = [ - pat.replace('_{suffix', '_'.join(('', custom_pat, '{suffix'))) for pat in patterns - ] + patterns = [pat.replace('_{suffix', f'_{custom_pat}_{{suffix') for pat in patterns] # Build the output path(s) dest_files = build_path(out_entities, path_patterns=patterns) @@ -1108,9 +1106,7 @@ def _run_interface(self, runtime): if custom_entities: # Example: f"{key}-{{{key}}}" -> "task-{task}" custom_pat = '_'.join(f'{key}-{{{key}}}' for key in sorted(custom_entities)) - patterns = [ - pat.replace('_{suffix', '_'.join(('', custom_pat, '{suffix'))) for pat in patterns - ] + patterns = [pat.replace('_{suffix', f'_{custom_pat}_{{suffix') for pat in patterns] # Prepare SimpleInterface outputs object self._results['out_file'] = [] diff --git a/niworkflows/utils/spaces.py b/niworkflows/utils/spaces.py index eb82851bd7c..ca386bcff64 100644 --- a/niworkflows/utils/spaces.py +++ b/niworkflows/utils/spaces.py @@ -722,7 +722,7 @@ def __call__(self, parser, namespace, values, option_string=None): # relevant discussions: # https://github.com/nipreps/niworkflows/pull/457#discussion_r375510227 # https://github.com/nipreps/niworkflows/pull/494 - val = ':'.join((val, 'res-native')) + val = f'{val}:res-native' for sp in Reference.from_string(val): spaces.add(sp) setattr(namespace, self.dest, spaces)