Skip to content

Commit

Permalink
STY: Apply ruff/pyupgrade rule UP031
Browse files Browse the repository at this point in the history
New in ruff v0.4.2
  • Loading branch information
DimitriPapadopoulos committed May 4, 2024
1 parent 1e45712 commit bbb77d8
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 31 deletions.
23 changes: 13 additions & 10 deletions .maint/paper_author_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,26 @@ def _aslist(inlist):
]

print(
'Some people made commits, but are missing in .maint/ '
'files: %s.' % ', '.join(unmatched),
'Some people made commits, but are missing in .maint/ ' 'files: {}.'.format(
', '.join(unmatched)
),
file=sys.stderr,
)

print('Authors (%d):' % len(author_matches))
print(
'%s.'
% '; '.join(
[
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
for i, idx in zip(author_matches, aff_indexes, strict=False)
]
'{}.'.format(
'; '.join(
[
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
for i, idx in zip(author_matches, aff_indexes, strict=False)
]
)
)
)

print(
'\n\nAffiliations:\n%s'
% '\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
'\n\nAffiliations:\n{}'.format(
'\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
)
)
20 changes: 11 additions & 9 deletions .maint/update_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def zenodo(
if isinstance(creator['affiliation'], list):
creator['affiliation'] = creator['affiliation'][0]

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


@cli.command()
Expand Down Expand Up @@ -274,18 +274,20 @@ def _aslist(value):

print('Authors (%d):' % len(hits))
print(
'%s.'
% '; '.join(
[
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
for i, idx in zip(hits, aff_indexes, strict=False)
]
'{}.'.format(
'; '.join(
[
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
for i, idx in zip(hits, aff_indexes, strict=False)
]
)
)
)

print(
'\n\nAffiliations:\n%s'
% '\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
'\n\nAffiliations:\n{}'.format(
'\n'.join([f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)])
)
)


Expand Down
4 changes: 2 additions & 2 deletions .maint/update_zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def loads_contributors(s):

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

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

zenodo_file.write_text('%s\n' % json.dumps(zenodo, indent=2, ensure_ascii=False))
zenodo_file.write_text(f'{json.dumps(zenodo, indent=2, ensure_ascii=False)}\n')
7 changes: 3 additions & 4 deletions fmriprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,9 @@ def parse_args(args=None, namespace=None):
if output_dir == bids_dir:
parser.error(
'The selected output folder is the same as the input BIDS folder. '
'Please modify the output path (suggestion: %s).'
% bids_dir
f'Please modify the output path (suggestion: {bids_dir}).'
/ 'derivatives'
/ ('fmriprep-%s' % version.split('+')[0])
/ ('fmriprep-{}'.format(version.split('+')[0]))
)

if bids_dir in work_dir.parents:
Expand Down Expand Up @@ -925,7 +924,7 @@ def parse_args(args=None, namespace=None):
if missing_subjects:
parser.error(
'One or more participant labels were not found in the BIDS directory: '
'%s.' % ', '.join(missing_subjects)
'{}.'.format(', '.join(missing_subjects))
)

config.execution.participant_label = sorted(participant_label)
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def main():

config.loggers.workflow.log(
15,
'\n'.join(['fMRIPrep config:'] + ['\t\t%s' % s for s in config.dumps().splitlines()]),
'\n'.join(['fMRIPrep config:'] + [f'\t\t{s}' for s in config.dumps().splitlines()]),
)
config.loggers.workflow.log(25, 'fMRIPrep started!')
errno = 1 # Default is error exit unless otherwise set
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def build_boilerplate(config_file, workflow):
logs_path = config.execution.fmriprep_dir / 'logs'
boilerplate = workflow.visit_desc()
citation_files = {
ext: logs_path / ('CITATION.%s' % ext) for ext in ('bib', 'tex', 'md', 'html')
ext: logs_path / (f'CITATION.{ext}') for ext in ('bib', 'tex', 'md', 'html')
}

if boilerplate:
Expand Down
4 changes: 2 additions & 2 deletions fmriprep/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def collect_derivatives(
item = layout.get(return_type='filename', **query)
if not item:
continue
derivs_cache['%s_boldref' % k] = item[0] if len(item) == 1 else item
derivs_cache[f'{k}_boldref'] = item[0] if len(item) == 1 else item

for xfm, q in spec['transforms'].items():
query = {**q, **entities}
Expand Down Expand Up @@ -237,7 +237,7 @@ def validate_input_dir(exec_env, bids_dir, participant_label, need_T1w=True):
ignored_subs = all_subs.difference(selected_subs)
if ignored_subs:
for sub in ignored_subs:
validator_config_dict['ignoredFiles'].append('/sub-%s/**' % sub)
validator_config_dict['ignoredFiles'].append(f'/sub-{sub}/**')
with tempfile.NamedTemporaryFile(mode='w+', suffix='.json') as temp:
temp.write(json.dumps(validator_config_dict))
temp.flush()
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def init_fmriprep_wf():
spaces=config.workflow.spaces.get_fs_spaces(),
minimum_fs_version='7.0.0',
),
name='fsdir_run_%s' % config.execution.run_uuid.replace('-', '_'),
name='fsdir_run_{}'.format(config.execution.run_uuid.replace('-', '_')),
run_without_submitting=True,
)
if config.execution.fs_subjects_dir is not None:
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/bold/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def init_bold_surf_wf(
The BOLD time-series were resampled onto the following surfaces
(FreeSurfer reconstruction nomenclature):
{out_spaces}.
""".format(out_spaces=', '.join(['*%s*' % s for s in surface_spaces]))
""".format(out_spaces=', '.join([f'*{s}*' for s in surface_spaces]))

inputnode = pe.Node(
niu.IdentityInterface(
Expand Down

0 comments on commit bbb77d8

Please sign in to comment.