Skip to content

Commit 66734bd

Browse files
committed
STY: ruff --fix --unsafe-fixes (with cleanup) [git-blame-ignore-rev]
1 parent 311686e commit 66734bd

File tree

15 files changed

+48
-42
lines changed

15 files changed

+48
-42
lines changed

.maint/paper_author_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _aslist(inlist):
5555
'%s.'
5656
% '; '.join(
5757
[
58-
'%s \\ :sup:`%s`\\ ' % (i['name'], idx)
58+
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
5959
for i, idx in zip(author_matches, aff_indexes, strict=False)
6060
]
6161
)

.maint/update_authors.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ def get_git_lines(fname='line-contributors.txt'):
119119
if not lines:
120120
raise RuntimeError(
121121
"""\
122-
Could not find line-contributors from git repository.%s"""
123-
% """ \
122+
Could not find line-contributors from git repository.{}""".format(
123+
""" \
124124
git-line-summary not found, please install git-extras. """
125-
* (git_line_summary_path is None)
125+
* (git_line_summary_path is None)
126+
)
126127
)
127128
return [' '.join(line.strip().split()[1:-1]) for line in lines if '%' in line]
128129

@@ -242,7 +243,7 @@ def publication(
242243
hits = [hit for hit in hits if hit['name'] not in pi_names] + pi_hits
243244

244245
def _aslist(value):
245-
if isinstance(value, (list, tuple)):
246+
if isinstance(value, list | tuple):
246247
return value
247248
return [value]
248249

@@ -273,7 +274,12 @@ def _aslist(value):
273274
print('Authors (%d):' % len(hits))
274275
print(
275276
'%s.'
276-
% '; '.join(['%s \\ :sup:`%s`\\ ' % (i['name'], idx) for i, idx in zip(hits, aff_indexes, strict=False)])
277+
% '; '.join(
278+
[
279+
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
280+
for i, idx in zip(hits, aff_indexes, strict=False)
281+
]
282+
)
277283
)
278284

279285
print(

.maint/update_zenodo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ def get_git_lines(fname='line-contributors.txt'):
8080
if not lines:
8181
raise RuntimeError(
8282
"""\
83-
Could not find line-contributors from git repository.%s"""
84-
% """ \
83+
Could not find line-contributors from git repository.{}""".format(
84+
""" \
8585
git-(line-)summary not found, please install git-extras. """
86-
* (cmd[0] is None)
86+
* (cmd[0] is None)
87+
)
8788
)
8889
return [' '.join(line.strip().split()[1:-1]) for line in lines if '%' in line]
8990

fmriprep/cli/parser.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -719,24 +719,22 @@ def _slice_time_ref(value, parser):
719719
latest = check_latest()
720720
if latest is not None and currentv < latest:
721721
print(
722-
"""\
723-
You are using fMRIPrep-%s, and a newer version of fMRIPrep is available: %s.
722+
f"""\
723+
You are using fMRIPrep-{currentv}, and a newer version of fMRIPrep is available: {latest}.
724724
Please check out our documentation about how and when to upgrade:
725-
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading"""
726-
% (currentv, latest),
725+
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading""",
727726
file=sys.stderr,
728727
)
729728

730729
_blist = is_flagged()
731730
if _blist[0]:
732731
_reason = _blist[1] or 'unknown'
733732
print(
734-
"""\
735-
WARNING: Version %s of fMRIPrep (current) has been FLAGGED
736-
(reason: %s).
733+
f"""\
734+
WARNING: Version {config.environment.version} of fMRIPrep (current) has been FLAGGED
735+
(reason: {_reason}).
737736
That means some severe flaw was found in it and we strongly
738-
discourage its usage."""
739-
% (config.environment.version, _reason),
737+
discourage its usage.""",
740738
file=sys.stderr,
741739
)
742740

fmriprep/cli/tests/test_parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
@pytest.mark.parametrize(
39-
'args,code',
39+
('args', 'code'),
4040
[
4141
([], 2),
4242
(MIN_ARGS, 2), # bids_dir does not exist
@@ -70,7 +70,7 @@ def test_parser_valid(tmp_path, args):
7070

7171

7272
@pytest.mark.parametrize(
73-
'argval,gb',
73+
('argval', 'gb'),
7474
[
7575
('1G', 1),
7676
('1GB', 1),
@@ -99,7 +99,7 @@ def test_memory_arg(tmp_path, argval, gb):
9999
assert opts.memory_gb == gb
100100

101101

102-
@pytest.mark.parametrize('current,latest', [('1.0.0', '1.3.2'), ('1.3.2', '1.3.2')])
102+
@pytest.mark.parametrize(('current', 'latest'), [('1.0.0', '1.3.2'), ('1.3.2', '1.3.2')])
103103
def test_get_parser_update(monkeypatch, capsys, current, latest):
104104
"""Make sure the out-of-date banner is shown."""
105105
expectation = Version(current) < Version(latest)
@@ -199,7 +199,7 @@ def test_slice_time_ref(tmp_path, st_ref):
199199

200200

201201
@pytest.mark.parametrize(
202-
'args, expectation',
202+
('args', 'expectation'),
203203
(
204204
([], False),
205205
(['--use-syn-sdc'], 'error'),

fmriprep/cli/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def check_latest():
8787
def is_flagged():
8888
"""Check whether current version is flagged."""
8989
# https://raw.githubusercontent.com/nipreps/fmriprep/master/.versions.json
90-
flagged = tuple()
90+
flagged = ()
9191
try:
9292
response = requests.get(
9393
url="""\

fmriprep/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
class _Config:
210210
"""An abstract class forbidding instantiation."""
211211

212-
_paths = tuple()
212+
_paths = ()
213213

214214
def __init__(self):
215215
"""Avert instantiation."""
@@ -223,7 +223,7 @@ def load(cls, settings, init=True, ignore=None):
223223
if k in ignore or v is None:
224224
continue
225225
if k in cls._paths:
226-
if isinstance(v, (list, tuple)):
226+
if isinstance(v, list | tuple):
227227
setattr(cls, k, [Path(val).absolute() for val in v])
228228
else:
229229
setattr(cls, k, Path(v).absolute())
@@ -248,7 +248,7 @@ def get(cls):
248248
if callable(getattr(cls, k)):
249249
continue
250250
if k in cls._paths:
251-
if isinstance(v, (list, tuple)):
251+
if isinstance(v, list | tuple):
252252
v = [str(val) for val in v]
253253
else:
254254
v = str(v)

fmriprep/data/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from functools import cached_property
2020
from pathlib import Path
2121
from types import ModuleType
22-
from typing import Union
2322

2423
try:
2524
from functools import cache
@@ -111,7 +110,7 @@ class Loader:
111110
.. automethod:: cached
112111
"""
113112

114-
def __init__(self, anchor: Union[str, ModuleType]):
113+
def __init__(self, anchor: str | ModuleType):
115114
self._anchor = anchor
116115
self.files = files(anchor)
117116
self.exit_stack = ExitStack()

fmriprep/interfaces/confounds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def _run_interface(self, runtime):
415415
names = {}
416416

417417
for conf_el in self.inputs.confounds_list:
418-
if isinstance(conf_el, (list, tuple)):
418+
if isinstance(conf_el, list | tuple):
419419
headers.append(conf_el[0])
420420
if conf_el[1] is not None:
421421
units[conf_el[0]] = conf_el[1]

fmriprep/interfaces/tests/test_reports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
@pytest.mark.parametrize(
29-
'orientation,pe_dir,expected',
29+
('orientation', 'pe_dir', 'expected'),
3030
[
3131
('RAS', 'j', 'Posterior-Anterior'),
3232
('RAS', 'j-', 'Anterior-Posterior'),

0 commit comments

Comments
 (0)