Skip to content

Commit

Permalink
STY: Apply ruff/pyupgrade rule UP031
Browse files Browse the repository at this point in the history
UP031 Use format specifiers instead of percent format
  • Loading branch information
DimitriPapadopoulos committed Nov 24, 2024
1 parent 9a558e3 commit 3400370
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nibabel/cmdline/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def table2string(table, out=None):
else:
raise RuntimeError(f'Should not get here with align={align}')

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

Expand Down
3 changes: 1 addition & 2 deletions nibabel/volumeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,10 @@ def pretty_mapping(
if getterfunc is None:
getterfunc = getitem
mxlen = max(len(str(name)) for name in mapping)
fmt = '%%-%ds : %%s' % mxlen
out = []
for name in mapping:
value = getterfunc(mapping, name)
out.append(fmt % (name, value))
out.append(f'{name:{mxlen}} : {value}')
return '\n'.join(out)


Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ ignore = [
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"doc/source/conf.py" = ["F401"]
"nibabel/benchmarks/*.py" = ["UP031"]

[tool.ruff.format]
quote-style = "single"
Expand Down

0 comments on commit 3400370

Please sign in to comment.