Skip to content

Commit a94ebbd

Browse files
authored
Merge pull request #919 from DimitriPapadopoulos/RUF
STY: Apply ruff rules (RUF)
2 parents 21d5af6 + fd2b27d commit a94ebbd

File tree

15 files changed

+40
-38
lines changed

15 files changed

+40
-38
lines changed

niworkflows/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616

1717
__all__ = [
18-
'__version__',
19-
'__packagename__',
18+
'NIWORKFLOWS_LOG',
2019
'__copyright__',
2120
'__credits__',
22-
'NIWORKFLOWS_LOG',
21+
'__packagename__',
22+
'__version__',
2323
'load_resource',
2424
]
2525

niworkflows/engine/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def _local_hash_check(self, jobid, graph):
303303
overwrite = self.procs[jobid].overwrite
304304
always_run = self.procs[jobid].interface.always_run
305305

306-
if cached and updated and (overwrite is False or overwrite is None and not always_run):
306+
if cached and updated and (overwrite is False or (overwrite is None and not always_run)):
307307
try:
308308
self._task_finished_cb(jobid, cached=True)
309309
self._remove_node_dirs()

niworkflows/interfaces/bids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ def _get_tf_resolution(space: str, resolution: str) -> str:
14691469
res_meta = None
14701470

14711471
# Due to inconsistencies, resolution keys may or may not be zero-padded
1472-
padded_res = f'{str(resolution):0>2}'
1472+
padded_res = f'{resolution:0>2}'
14731473
for r in (resolution, padded_res):
14741474
if r in resolutions:
14751475
res_meta = resolutions[r]

niworkflows/interfaces/cifti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _prepare_cifti(grayordinates: str) -> tuple[list, str, dict]:
202202
'170k': {'surface-den': '59k', 'tf-res': '06', 'grayords': '170,494', 'res-mm': '1.6mm'},
203203
}
204204
if grayordinates not in grayord_key:
205-
raise NotImplementedError('Grayordinates {grayordinates} is not supported.')
205+
raise NotImplementedError(f'Grayordinates {grayordinates} is not supported.')
206206

207207
tf_vol_res = grayord_key[grayordinates]['tf-res']
208208
total_grayords = grayord_key[grayordinates]['grayords']

niworkflows/interfaces/confounds.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -534,20 +534,20 @@ def _expand_shorthand(model_formula, variables):
534534
nss = _get_matches_from_data('non_steady_state_outlier[0-9]+', variables)
535535
spikes = _get_matches_from_data('motion_outlier[0-9]+', variables)
536536

537-
model_formula = re.sub('wm', wm, model_formula)
538-
model_formula = re.sub('gsr', gsr, model_formula)
539-
model_formula = re.sub('rps', rps, model_formula)
540-
model_formula = re.sub('fd', fd, model_formula)
541-
model_formula = re.sub('acc', acc, model_formula)
542-
model_formula = re.sub('tcc', tcc, model_formula)
543-
model_formula = re.sub('dv', dv, model_formula)
544-
model_formula = re.sub('dvall', dvall, model_formula)
545-
model_formula = re.sub('nss', nss, model_formula)
546-
model_formula = re.sub('spikes', spikes, model_formula)
537+
model_formula = re.sub(r'wm', wm, model_formula)
538+
model_formula = re.sub(r'gsr', gsr, model_formula)
539+
model_formula = re.sub(r'rps', rps, model_formula)
540+
model_formula = re.sub(r'fd', fd, model_formula)
541+
model_formula = re.sub(r'acc', acc, model_formula)
542+
model_formula = re.sub(r'tcc', tcc, model_formula)
543+
model_formula = re.sub(r'dv', dv, model_formula)
544+
model_formula = re.sub(r'dvall', dvall, model_formula)
545+
model_formula = re.sub(r'nss', nss, model_formula)
546+
model_formula = re.sub(r'spikes', spikes, model_formula)
547547

548548
formula_variables = _get_variables_from_formula(model_formula)
549549
others = ' + '.join(set(variables) - set(formula_variables))
550-
model_formula = re.sub('others', others, model_formula)
550+
model_formula = re.sub(r'others', others, model_formula)
551551
return model_formula
552552

553553

niworkflows/interfaces/nibabel.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#
2323
"""Nibabel-based interfaces."""
2424

25+
from __future__ import annotations
26+
2527
from pathlib import Path
2628
from warnings import warn
2729

@@ -520,9 +522,9 @@ def _run_interface(self, runtime):
520522
def reorient_file(
521523
in_file: str,
522524
*,
523-
target_file: str = None,
524-
target_ornt: str = None,
525-
newpath: str = None,
525+
target_file: str | None = None,
526+
target_ornt: str | None = None,
527+
newpath: str | None = None,
526528
) -> str:
527529
"""
528530
Reorient an image.

niworkflows/interfaces/nilearn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
NILEARN_VERSION = 'unknown'
4848

4949
LOGGER = logging.getLogger('nipype.interface')
50-
__all__ = ['NILEARN_VERSION', 'MaskEPI', 'Merge', 'ComputeEPIMask']
50+
__all__ = ['NILEARN_VERSION', 'ComputeEPIMask', 'MaskEPI', 'Merge']
5151

5252

5353
class _MaskEPIInputSpec(BaseInterfaceInputSpec):

niworkflows/interfaces/tests/test_nibabel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def create_roi(tmp_path):
4949
def _create_roi(affine, img_data, roi_index):
5050
img_data[tuple(roi_index)] = 1
5151
nii = nb.Nifti1Image(img_data, affine)
52-
filename = tmp_path / f'{str(uuid.uuid4())}.nii.gz'
52+
filename = tmp_path / f'{uuid.uuid4()}.nii.gz'
5353
files.append(filename)
5454
nii.to_filename(filename)
5555
return filename

niworkflows/reports/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def generate_report(self):
384384

385385
if (logs_path / 'CITATION.html').exists():
386386
text = (
387-
re.compile('<body>(.*?)</body>', re.DOTALL | re.IGNORECASE)
387+
re.compile(r'<body>(.*?)</body>', re.DOTALL | re.IGNORECASE)
388388
.findall((logs_path / 'CITATION.html').read_text())[0]
389389
.strip()
390390
)

niworkflows/utils/bids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def group_multiecho(bold_sess):
388388
def _grp_echos(x):
389389
if '_echo-' not in x:
390390
return x
391-
echo = re.search('_echo-\\d*', x).group(0)
391+
echo = re.search(r'_echo-\d*', x).group(0)
392392
return x.replace(echo, '_echo-?')
393393

394394
ses_uids = []

0 commit comments

Comments
 (0)