Skip to content

Commit 05c11f9

Browse files
Apply ruff/pyupgrade rule UP031
UP031 Use format specifiers instead of percent format
1 parent df147de commit 05c11f9

File tree

6 files changed

+17
-19
lines changed

6 files changed

+17
-19
lines changed

.maint/update_authors.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def zenodo(
233233
creator['affiliation'] = creator['affiliation'][0]
234234

235235
Path(zenodo_file).write_text(
236-
'%s\n' % json.dumps(zenodo, indent=2)
236+
f'{json.dumps(zenodo, indent=2)}\n'
237237
)
238238

239239

@@ -301,20 +301,18 @@ def _aslist(value):
301301

302302
print('Authors (%d):' % len(hits))
303303
print(
304-
'%s.'
305-
% '; '.join(
304+
'{}.'.format('; '.join(
306305
[
307306
'{} \\ :sup:`{}`\\ '.format(i['name'], idx)
308307
for i, idx in zip(hits, aff_indexes)
309308
]
310-
)
309+
))
311310
)
312311

313312
print(
314-
'\n\nAffiliations:\n%s'
315-
% '\n'.join(
313+
'\n\nAffiliations:\n{}'.format('\n'.join(
316314
[f'{i + 1: >2}. {a}' for i, a in enumerate(affiliations)]
317-
)
315+
))
318316
)
319317

320318

mriqc/bin/abide2bids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def fetch(args: (str, str, str, str)) -> (str, str):
127127
out_dir = op.abspath(out_dir)
128128

129129
pkg_id = [u[9:] for u in url.split('/') if u.startswith('NITRC_IR_')][0]
130-
sub_file = op.join(tmpdir, '%s.zip' % pkg_id)
130+
sub_file = op.join(tmpdir, f'{pkg_id}.zip')
131131

132132
cmd = [_curl_cmd, '-s', '-u', f'{user}:{password}', '-o', sub_file, url]
133133
sp.check_call(cmd)

mriqc/bin/fs2gif.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ def main():
114114
center = np.average([bbox_min, bbox_max], axis=0)
115115

116116
if opts.hist_eq:
117-
ref_file = op.join(tmp_sub, '%s.mgz' % subid)
117+
ref_file = op.join(tmp_sub, f'{subid}.mgz')
118118
img = nb.load(op.join(sub_path, 'mri', 'norm.mgz'))
119119
data = exposure.equalize_adapthist(img.get_fdata(), clip_limit=0.03)
120120
nb.MGHImage(data, img.affine, img.header).to_filename(ref_file)
121121

122122
if not opts.zoom:
123123
# Export tiffs for left hemisphere
124-
tcl_file = op.join(tmp_sub, '%s.tcl' % subid)
124+
tcl_file = op.join(tmp_sub, f'{subid}.tcl')
125125
with open(tcl_file, 'w') as tclfp:
126126
tclfp.write(tcl_contents)
127127
tclfp.write(
@@ -147,7 +147,7 @@ def main():
147147
if opts.use_xvfb:
148148
cmd = _xvfb_run() + cmd
149149

150-
print('Running tkmedit: %s' % ' '.join(cmd))
150+
print('Running tkmedit: {}'.format(' '.join(cmd)))
151151
sp.call(cmd, env=environ)
152152
# Convert to animated gif
153153
print('Stacking coronal slices')
@@ -165,7 +165,7 @@ def main():
165165

166166
else:
167167
# Export tiffs for left hemisphere
168-
tcl_file = op.join(tmp_sub, 'lh-%s.tcl' % subid)
168+
tcl_file = op.join(tmp_sub, f'lh-{subid}.tcl')
169169
with open(tcl_file, 'w') as tclfp:
170170
tclfp.write(tcl_contents)
171171
tclfp.write('SetZoomLevel 2')
@@ -184,13 +184,13 @@ def main():
184184
if opts.use_xvfb:
185185
cmd = _xvfb_run() + cmd
186186

187-
print('Running tkmedit: %s' % ' '.join(cmd))
187+
print('Running tkmedit: {}'.format(' '.join(cmd)))
188188
sp.call(cmd, env=environ)
189189
# Convert to animated gif
190190
print('Stacking coronal slices')
191191

192192
# Export tiffs for right hemisphere
193-
tcl_file = op.join(tmp_sub, 'rh-%s.tcl' % subid)
193+
tcl_file = op.join(tmp_sub, f'rh-{subid}.tcl')
194194
with open(tcl_file, 'w') as tclfp:
195195
tclfp.write(tcl_contents)
196196
tclfp.write('SetZoomLevel 2')
@@ -209,7 +209,7 @@ def main():
209209
if opts.use_xvfb:
210210
cmd = _xvfb_run() + cmd
211211

212-
print('Running tkmedit: %s' % ' '.join(cmd))
212+
print('Running tkmedit: {}'.format(' '.join(cmd)))
213213
sp.call(cmd, env=environ)
214214
# Convert to animated gif
215215
print('Stacking coronal slices')
@@ -260,7 +260,7 @@ def _xvfb_run(wait=5, server_args='-screen 0, 1600x1200x24', logs=None):
260260

261261

262262
def _myerror(msg):
263-
print('WARNING: Error deleting temporal files: %s' % msg)
263+
print(f'WARNING: Error deleting temporal files: {msg}')
264264

265265

266266
if __name__ == '__main__':

mriqc/bin/labeler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def main():
5454
finished[j - 1] = finished[j - 1] + 1
5555
hold[j - 1, i - 1] = int(file[i][j])
5656
finished = np.divide(np.round(np.divide(finished, total) * 1000), 10)
57-
print(f'Completed: {" ".join(["%g%%" % f for f in finished])}')
57+
print(f'Completed: {" ".join([f"{f:g}%" for f in finished])}')
5858
print(f'Total: {np.round(np.divide(np.sum(finished), 3))}%')
5959
input('Waiting: [enter]')
6060

mriqc/cli/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def check_latest():
7878
if cachefile is not None and latest is not None:
7979
with suppress(Exception):
8080
cachefile.write_text(
81-
'|'.join(('%s' % latest, datetime.now(tz=UTC).strftime(DATE_FMT)))
81+
'|'.join((f'{latest}', datetime.now(tz=UTC).strftime(DATE_FMT)))
8282
)
8383

8484
return latest

mriqc/reports/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def gen_html(csv_file, mod, csv_failed=None, out_file=None):
185185
(['efc'], None),
186186
(['fber'], None),
187187
(['fwhm', 'fwhm_x', 'fwhm_y', 'fwhm_z'], 'mm'),
188-
(['gsr_%s' % a for a in ('x', 'y')], None),
188+
([f'gsr_{a}' for a in ('x', 'y')], None),
189189
(['snr'], None),
190190
(['dvars_std', 'dvars_vstd'], None),
191191
(['dvars_nstd'], None),

0 commit comments

Comments
 (0)