Skip to content

Commit e6fc937

Browse files
STY: Apply ruff/pyupgrade rule UP031
UP031 Use format specifiers instead of percent format
1 parent 3bb6f57 commit e6fc937

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

nibabel/cmdline/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def table2string(table, out=None):
8989
else:
9090
raise RuntimeError(f'Should not get here with align={align}')
9191

92-
string_ += '%%%ds%%s%%%ds ' % (nspacesl, nspacesr) % ('', item, '')
92+
string_ += f'{" " * nspacesl}{item}{" " * nspacesr} '
9393
string += string_.rstrip() + '\n'
9494
out.write(string)
9595

nibabel/volumeutils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,10 @@ def pretty_mapping(
338338
if getterfunc is None:
339339
getterfunc = getitem
340340
mxlen = max(len(str(name)) for name in mapping)
341-
fmt = '%%-%ds : %%s' % mxlen
342341
out = []
343342
for name in mapping:
344343
value = getterfunc(mapping, name)
345-
out.append(fmt % (name, value))
344+
out.append(f'{name:{mxlen}} : {value}')
346345
return '\n'.join(out)
347346

348347

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ ignore = [
182182
[tool.ruff.lint.per-file-ignores]
183183
"__init__.py" = ["F401"]
184184
"doc/source/conf.py" = ["F401"]
185+
"nibabel/benchmarks/*.py" = ["UP031"]
185186

186187
[tool.ruff.format]
187188
quote-style = "single"

0 commit comments

Comments
 (0)