Skip to content

Commit 3cbf147

Browse files
STY: Apply ruff/pyupgrade rule UP031 (#3280)
New in [ruff v0.4.2](https://github.com/astral-sh/ruff/releases/tag/v0.4.2). --------- Co-authored-by: Chris Markiewicz <effigies@gmail.com>
1 parent 1e45712 commit 3cbf147

File tree

9 files changed

+42
-38
lines changed

9 files changed

+42
-38
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+
rf'{i["name"]} \ :sup:`{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: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def zenodo(
187187
misses = set(miss_creators).intersection(miss_contributors)
188188
if misses:
189189
print(
190-
"Some people made commits, but are missing in .maint/ " f"files: {', '.join(misses)}",
190+
f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}",
191191
file=sys.stderr,
192192
)
193193

@@ -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()
@@ -268,24 +268,26 @@ def _aslist(value):
268268

269269
if misses:
270270
print(
271-
"Some people made commits, but are missing in .maint/ " f"files: {', '.join(misses)}",
271+
f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}",
272272
file=sys.stderr,
273273
)
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+
rf'{i["name"]} \ :sup:`{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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ def loads_contributors(s):
145145
zenodo['contributors'] = zen_contributors
146146

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

@@ -162,4 +163,4 @@ def loads_contributors(s):
162163
if isinstance(creator['affiliation'], list):
163164
creator['affiliation'] = creator['affiliation'][0]
164165

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

fmriprep/cli/parser.py

Lines changed: 6 additions & 6 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
886-
/ 'derivatives'
887-
/ ('fmriprep-%s' % version.split('+')[0])
884+
'Please modify the output path (suggestion: {}).'.format(
885+
bids_dir / 'derivatives' / f'fmriprep-{version.split("+")[0]}'
886+
)
888887
)
889888

890889
if bids_dir in work_dir.parents:
@@ -924,8 +923,9 @@ def parse_args(args=None, namespace=None):
924923
missing_subjects = participant_label - set(all_subjects)
925924
if missing_subjects:
926925
parser.error(
927-
'One or more participant labels were not found in the BIDS directory: '
928-
'%s.' % ', '.join(missing_subjects)
926+
'One or more participant labels were not found in the BIDS directory: {}.'.format(
927+
', '.join(missing_subjects)
928+
)
929929
)
930930

931931
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ def build_boilerplate(config_file, workflow):
173173
config.load(config_file)
174174
logs_path = config.execution.fmriprep_dir / 'logs'
175175
boilerplate = workflow.visit_desc()
176-
citation_files = {
177-
ext: logs_path / ('CITATION.%s' % ext) for ext in ('bib', 'tex', 'md', 'html')
178-
}
176+
citation_files = {ext: logs_path / f'CITATION.{ext}' for ext in ('bib', 'tex', 'md', 'html')}
179177

180178
if boilerplate:
181179
# To please git-annex users and also to guarantee consistency

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)