Skip to content

Commit 7e5d584

Browse files
committed
STY: ruff format [git-blame-ignore-rev]
1 parent f81f5a7 commit 7e5d584

23 files changed

+40
-43
lines changed

nibabel/benchmarks/bench_arrayproxy_slicing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def fmt_sliceobj(sliceobj):
9696
slcstr.append(s)
9797
else:
9898
slcstr.append(str(int(s * SHAPE[i])))
99-
return f"[{', '.join(slcstr)}]"
99+
return f'[{", ".join(slcstr)}]'
100100

101101
with InTemporaryDirectory():
102102
print(f'Generating test data... ({int(round(np.prod(SHAPE) * 4 / 1048576.0))} MB)')

nibabel/benchmarks/butils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
def print_git_title(title):
77
"""Prints title string with git hash if possible, and underline"""
8-
title = f"{title} for git revision {get_info()['commit_hash']}"
8+
title = f'{title} for git revision {get_info()["commit_hash"]}'
99
print(title)
1010
print('-' * len(title))

nibabel/cifti2/cifti2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ def __setitem__(self, key, value):
294294
self._labels[key] = Cifti2Label(*([key] + list(value)))
295295
except ValueError:
296296
raise ValueError(
297-
'Key should be int, value should be sequence '
298-
'of str and 4 floats between 0 and 1'
297+
'Key should be int, value should be sequence of str and 4 floats between 0 and 1'
299298
)
300299

301300
def __delitem__(self, key):

nibabel/cifti2/parse_cifti2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ def StartElementHandler(self, name, attrs):
384384
model = self.struct_state[-1]
385385
if not isinstance(model, Cifti2BrainModel):
386386
raise Cifti2HeaderError(
387-
'VertexIndices element can only be a child '
388-
'of the CIFTI-2 BrainModel element'
387+
'VertexIndices element can only be a child of the CIFTI-2 BrainModel element'
389388
)
390389
self.fsm_state.append('VertexIndices')
391390
model.vertex_indices = index

nibabel/cmdline/ls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ def proc_file(f, opts):
103103

104104
row += [
105105
str(safe_get(h, 'data_dtype')),
106-
f"@l[{ap(safe_get(h, 'data_shape'), '%3g')}]",
107-
f"@l{ap(safe_get(h, 'zooms'), '%.2f', 'x')}",
106+
f'@l[{ap(safe_get(h, "data_shape"), "%3g")}]',
107+
f'@l{ap(safe_get(h, "zooms"), "%.2f", "x")}',
108108
]
109109
# Slope
110110
if (

nibabel/cmdline/tests/test_conform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def test_nondefault(tmpdir):
4747
voxel_size = (1, 2, 4)
4848
orientation = 'LAS'
4949
args = (
50-
f"{infile} {outfile} --out-shape {' '.join(map(str, out_shape))} "
51-
f"--voxel-size {' '.join(map(str, voxel_size))} --orientation {orientation}"
50+
f'{infile} {outfile} --out-shape {" ".join(map(str, out_shape))} '
51+
f'--voxel-size {" ".join(map(str, voxel_size))} --orientation {orientation}'
5252
)
5353
main(args.split())
5454
assert outfile.isfile()

nibabel/cmdline/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def table2string(table, out=None):
5555
# eat whole entry while computing width for @w (for wide)
5656
markup_strip = re.compile('^@([lrc]|w.*)')
5757
col_width = [max(len(markup_strip.sub('', x)) for x in column) for column in zip(*table)]
58-
trans = str.maketrans("lrcw", "<>^^")
58+
trans = str.maketrans('lrcw', '<>^^')
5959
lines = []
6060
for row in table:
6161
line = []

nibabel/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def make_datasource(pkg_def, **kwargs):
290290
pkg_hint = pkg_def.get('install hint', DEFAULT_INSTALL_HINT)
291291
msg = f'{e}; Is it possible you have not installed a data package?'
292292
if 'name' in pkg_def:
293-
msg += f"\n\nYou may need the package \"{pkg_def['name']}\""
293+
msg += f'\n\nYou may need the package "{pkg_def["name"]}"'
294294
if pkg_hint is not None:
295295
msg += f'\n\n{pkg_hint}'
296296
raise DataError(msg)

nibabel/deprecator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def __call__(
212212
messages.append('* deprecated from version: ' + since)
213213
if until:
214214
messages.append(
215-
f"* {'Raises' if self.is_bad_version(until) else 'Will raise'} "
215+
f'* {"Raises" if self.is_bad_version(until) else "Will raise"} '
216216
f'{exception} as of version: {until}'
217217
)
218218
message = '\n'.join(messages)

nibabel/gifti/tests/test_parse_gifti_fast.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ def assert_default_types(loaded):
177177
continue
178178
with suppress_warnings():
179179
loadedtype = type(getattr(loaded, attr))
180-
assert (
181-
loadedtype == defaulttype
182-
), f'Type mismatch for attribute: {attr} ({loadedtype} != {defaulttype})'
180+
assert loadedtype == defaulttype, (
181+
f'Type mismatch for attribute: {attr} ({loadedtype} != {defaulttype})'
182+
)
183183

184184

185185
def test_default_types():

0 commit comments

Comments
 (0)