Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: Update ruff to 0.8.2 #1389

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: check-merge-conflict
- id: check-vcs-permalinks
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
rev: v0.8.2
hooks:
- id: ruff
args: [ --fix ]
Expand Down
6 changes: 4 additions & 2 deletions nibabel/cifti2/cifti2_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,10 @@ def __eq__(self, other):
return (
(
self.affine is None
or np.allclose(self.affine, other.affine)
and self.volume_shape == other.volume_shape
or (
np.allclose(self.affine, other.affine)
and self.volume_shape == other.volume_shape
)
)
and self.nvertices == other.nvertices
and np.array_equal(self.name, other.name)
Expand Down
2 changes: 1 addition & 1 deletion nibabel/cmdline/dicomfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@

if opts.verbose:
logger.addHandler(logging.StreamHandler(sys.stdout))
logger.setLevel(opts.verbose > 1 and logging.DEBUG or logging.INFO)
logger.setLevel((opts.verbose > 1 and logging.DEBUG) or logging.INFO)

Check warning on line 234 in nibabel/cmdline/dicomfs.py

View check run for this annotation

Codecov / codecov/patch

nibabel/cmdline/dicomfs.py#L234

Added line #L234 was not covered by tests

if len(files) != 2:
sys.stderr.write(f'Please provide two arguments:\n{parser.usage}\n')
Expand Down
4 changes: 2 additions & 2 deletions nibabel/cmdline/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def table2string(table, out=None):
markup_strip = re.compile('^@([lrc]|w.*)')
col_width = [max(len(markup_strip.sub('', x)) for x in column) for column in atable.T]
string = ''
for i, table_ in enumerate(table):
for table_ in table:
string_ = ''
for j, item in enumerate(table_):
item = str(item)
Expand All @@ -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
2 changes: 1 addition & 1 deletion nibabel/pointset.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def to_mask(self, shape=None) -> SpatialImage:
class GridIndices:
"""Class for generating indices just-in-time"""

__slots__ = ('gridshape', 'dtype', 'shape')
__slots__ = ('dtype', 'gridshape', 'shape')
ndim = 2

def __init__(self, shape, dtype=None):
Expand Down
2 changes: 1 addition & 1 deletion nibabel/tests/test_nifti1.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def test_slice_times(self):
hdr.set_slice_duration(0.1)
# We need a function to print out the Nones and floating point
# values in a predictable way, for the tests below.
_stringer = lambda val: val is not None and f'{val:2.1f}' or None
_stringer = lambda val: (val is not None and f'{val:2.1f}') or None
_print_me = lambda s: list(map(_stringer, s))
# The following examples are from the nifti1.h documentation.
hdr['slice_code'] = slice_order_codes['sequential increasing']
Expand Down
7 changes: 3 additions & 4 deletions nibabel/volumeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
DT = ty.TypeVar('DT', bound=np.generic)

sys_is_le = sys.byteorder == 'little'
native_code = sys_is_le and '<' or '>'
swapped_code = sys_is_le and '>' or '<'
native_code = (sys_is_le and '<') or '>'
swapped_code = (sys_is_le and '>') or '<'

_endian_codes = ( # numpy code, aliases
('<', 'little', 'l', 'le', 'L', 'LE'),
Expand Down 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
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ ignore = [
"C416",
"PERF203",
"PIE790",
"PT004", # deprecated
"PT005", # deprecated
"PT007",
"PT011",
"PT012",
Expand All @@ -163,7 +161,6 @@ ignore = [
"RUF012", # TODO: enable
"RUF015",
"RUF017", # TODO: enable
"UP027", # deprecated
"UP038", # https://github.com/astral-sh/ruff/issues/7871
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
Expand All @@ -185,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
Loading