Skip to content

Commit bbb77d8

Browse files
STY: Apply ruff/pyupgrade rule UP031
New in ruff v0.4.2
1 parent 1e45712 commit bbb77d8

File tree

9 files changed

+35
-31
lines changed

9 files changed

+35
-31
lines changed

.maint/paper_author_list.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,26 @@ def _aslist(inlist):
4646
]
4747

4848
print(
49-
'Some people made commits, but are missing in .maint/ '
50-
'files: %s.' % ', '.join(unmatched),
49+
'Some people made commits, but are missing in .maint/ ' 'files: {}.'.format(
50+
', '.join(unmatched)
51+
),
5152
file=sys.stderr,
5253
)
5354

5455
print('Authors (%d):' % len(author_matches))
5556
print(
56-
'%s.'
57-
% '; '.join(
58-
[
59-
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
60-
for i, idx in zip(author_matches, aff_indexes, strict=False)
61-
]
57+
'{}.'.format(
58+
'; '.join(
59+
[
60+
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
61+
for i, idx in zip(author_matches, aff_indexes, strict=False)
62+
]
63+
)
6264
)
6365
)
6466

6567
print(
66-
'\n\nAffiliations:\n%s'
67-
% '\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
68+
'\n\nAffiliations:\n{}'.format(
69+
'\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
70+
)
6871
)

.maint/update_authors.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def zenodo(
206206
if isinstance(creator['affiliation'], list):
207207
creator['affiliation'] = creator['affiliation'][0]
208208

209-
Path(zenodo_file).write_text('%s\n' % json.dumps(zenodo, indent=2))
209+
Path(zenodo_file).write_text(f'{json.dumps(zenodo, indent=2)}\n')
210210

211211

212212
@cli.command()
@@ -274,18 +274,20 @@ def _aslist(value):
274274

275275
print('Authors (%d):' % len(hits))
276276
print(
277-
'%s.'
278-
% '; '.join(
279-
[
280-
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
281-
for i, idx in zip(hits, aff_indexes, strict=False)
282-
]
277+
'{}.'.format(
278+
'; '.join(
279+
[
280+
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
281+
for i, idx in zip(hits, aff_indexes, strict=False)
282+
]
283+
)
283284
)
284285
)
285286

286287
print(
287-
'\n\nAffiliations:\n%s'
288-
% '\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
288+
'\n\nAffiliations:\n{}'.format(
289+
'\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
290+
)
289291
)
290292

291293

.maint/update_zenodo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def loads_contributors(s):
146146

147147
print(
148148
'Some people made commits, but are missing in .maint/ '
149-
'files: %s.' % ', '.join(set(miss_creators).intersection(miss_contributors)),
149+
'files: {}.'.format(', '.join(set(miss_creators).intersection(miss_contributors))),
150150
file=sys.stderr,
151151
)
152152

@@ -162,4 +162,4 @@ def loads_contributors(s):
162162
if isinstance(creator['affiliation'], list):
163163
creator['affiliation'] = creator['affiliation'][0]
164164

165-
zenodo_file.write_text('%s\n' % json.dumps(zenodo, indent=2, ensure_ascii=False))
165+
zenodo_file.write_text(f'{json.dumps(zenodo, indent=2, ensure_ascii=False)}\n')

fmriprep/cli/parser.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,10 +881,9 @@ def parse_args(args=None, namespace=None):
881881
if output_dir == bids_dir:
882882
parser.error(
883883
'The selected output folder is the same as the input BIDS folder. '
884-
'Please modify the output path (suggestion: %s).'
885-
% bids_dir
884+
f'Please modify the output path (suggestion: {bids_dir}).'
886885
/ 'derivatives'
887-
/ ('fmriprep-%s' % version.split('+')[0])
886+
/ ('fmriprep-{}'.format(version.split('+')[0]))
888887
)
889888

890889
if bids_dir in work_dir.parents:
@@ -925,7 +924,7 @@ def parse_args(args=None, namespace=None):
925924
if missing_subjects:
926925
parser.error(
927926
'One or more participant labels were not found in the BIDS directory: '
928-
'%s.' % ', '.join(missing_subjects)
927+
'{}.'.format(', '.join(missing_subjects))
929928
)
930929

931930
config.execution.participant_label = sorted(participant_label)

fmriprep/cli/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def main():
147147

148148
config.loggers.workflow.log(
149149
15,
150-
'\n'.join(['fMRIPrep config:'] + ['\t\t%s' % s for s in config.dumps().splitlines()]),
150+
'\n'.join(['fMRIPrep config:'] + [f'\t\t{s}' for s in config.dumps().splitlines()]),
151151
)
152152
config.loggers.workflow.log(25, 'fMRIPrep started!')
153153
errno = 1 # Default is error exit unless otherwise set

fmriprep/cli/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def build_boilerplate(config_file, workflow):
174174
logs_path = config.execution.fmriprep_dir / 'logs'
175175
boilerplate = workflow.visit_desc()
176176
citation_files = {
177-
ext: logs_path / ('CITATION.%s' % ext) for ext in ('bib', 'tex', 'md', 'html')
177+
ext: logs_path / (f'CITATION.{ext}') for ext in ('bib', 'tex', 'md', 'html')
178178
}
179179

180180
if boilerplate:

fmriprep/utils/bids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def collect_derivatives(
6666
item = layout.get(return_type='filename', **query)
6767
if not item:
6868
continue
69-
derivs_cache['%s_boldref' % k] = item[0] if len(item) == 1 else item
69+
derivs_cache[f'{k}_boldref'] = item[0] if len(item) == 1 else item
7070

7171
for xfm, q in spec['transforms'].items():
7272
query = {**q, **entities}
@@ -237,7 +237,7 @@ def validate_input_dir(exec_env, bids_dir, participant_label, need_T1w=True):
237237
ignored_subs = all_subs.difference(selected_subs)
238238
if ignored_subs:
239239
for sub in ignored_subs:
240-
validator_config_dict['ignoredFiles'].append('/sub-%s/**' % sub)
240+
validator_config_dict['ignoredFiles'].append(f'/sub-{sub}/**')
241241
with tempfile.NamedTemporaryFile(mode='w+', suffix='.json') as temp:
242242
temp.write(json.dumps(validator_config_dict))
243243
temp.flush()

fmriprep/workflows/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def init_fmriprep_wf():
8484
spaces=config.workflow.spaces.get_fs_spaces(),
8585
minimum_fs_version='7.0.0',
8686
),
87-
name='fsdir_run_%s' % config.execution.run_uuid.replace('-', '_'),
87+
name='fsdir_run_{}'.format(config.execution.run_uuid.replace('-', '_')),
8888
run_without_submitting=True,
8989
)
9090
if config.execution.fs_subjects_dir is not None:

fmriprep/workflows/bold/resampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def init_bold_surf_wf(
126126
The BOLD time-series were resampled onto the following surfaces
127127
(FreeSurfer reconstruction nomenclature):
128128
{out_spaces}.
129-
""".format(out_spaces=', '.join(['*%s*' % s for s in surface_spaces]))
129+
""".format(out_spaces=', '.join([f'*{s}*' for s in surface_spaces]))
130130

131131
inputnode = pe.Node(
132132
niu.IdentityInterface(

0 commit comments

Comments
 (0)