Skip to content

Commit bb6236f

Browse files
authored
Merge pull request #1352 from DimitriPapadopoulos/B
STY: Apply ruff/flake8-bugbear rules (B)
2 parents d1930e9 + f064b62 commit bb6236f

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

nibabel/gifti/tests/test_parse_gifti_fast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def test_load_dataarray1():
241241
me = img.darrays[0].meta
242242
assert 'AnatomicalStructurePrimary' in me
243243
assert 'AnatomicalStructureSecondary' in me
244-
me['AnatomicalStructurePrimary'] == 'CortexLeft'
244+
assert me['AnatomicalStructurePrimary'] == 'CortexLeft'
245245
assert_array_almost_equal(img.darrays[0].coordsys.xform, np.eye(4, 4))
246246
assert xform_codes.niistring[img.darrays[0].coordsys.dataspace] == 'NIFTI_XFORM_TALAIRACH'
247247
assert xform_codes.niistring[img.darrays[0].coordsys.xformspace] == 'NIFTI_XFORM_TALAIRACH'
@@ -279,7 +279,7 @@ def test_load_dataarray4():
279279
def test_dataarray5():
280280
img5 = load(DATA_FILE5)
281281
for da in img5.darrays:
282-
gifti_endian_codes.byteorder[da.endian] == 'little'
282+
assert gifti_endian_codes.byteorder[da.endian] == 'little'
283283
assert_array_almost_equal(img5.darrays[0].data, DATA_FILE5_darr1)
284284
assert_array_almost_equal(img5.darrays[1].data, DATA_FILE5_darr2)
285285
# Round trip tested below

nibabel/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Generate dynamic fixtures
77
def pytest_generate_tests(metafunc):
88
if 'supported_dtype' in metafunc.fixturenames:
9-
if metafunc.cls is None or not getattr(metafunc.cls, 'image_class'):
9+
if metafunc.cls is None or not metafunc.cls.image_class:
1010
raise pytest.UsageError(
1111
'Attempting to use supported_dtype fixture outside an image test case'
1212
)

nibabel/tests/test_openers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,17 +431,17 @@ def test_DeterministicGzipFile_fileobj():
431431
with open('test.gz', 'wb') as fobj:
432432
with DeterministicGzipFile(filename='', mode='wb', fileobj=fobj) as gzobj:
433433
gzobj.write(msg)
434-
md5sum('test.gz') == ref_chksum
434+
assert md5sum('test.gz') == ref_chksum
435435

436436
with open('test.gz', 'wb') as fobj:
437437
with DeterministicGzipFile(fileobj=fobj, mode='wb') as gzobj:
438438
gzobj.write(msg)
439-
md5sum('test.gz') == ref_chksum
439+
assert md5sum('test.gz') == ref_chksum
440440

441441
with open('test.gz', 'wb') as fobj:
442442
with DeterministicGzipFile(filename='test.gz', mode='wb', fileobj=fobj) as gzobj:
443443
gzobj.write(msg)
444-
md5sum('test.gz') == ref_chksum
444+
assert md5sum('test.gz') == ref_chksum
445445

446446

447447
def test_bitwise_determinism():

nibabel/viewers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def _set_position(self, x, y, z, notify=True):
447447
# Matplotlib handlers ####################################################
448448
def _in_axis(self, event):
449449
"""Return axis index if within one of our axes, else None"""
450-
if getattr(event, 'inaxes') is None:
450+
if event.inaxes is None:
451451
return None
452452
for ii, ax in enumerate(self._axes):
453453
if event.inaxes is ax:

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,23 @@ exclude = ["doc", "nibabel/externals", "tools", "version.py", "versioneer.py"]
116116

117117
[tool.ruff.lint]
118118
select = [
119+
"B",
119120
"F",
120121
"I",
121122
"Q",
122123
"UP",
123124
]
124125
ignore = [
126+
"B006", # TODO: enable
127+
"B008", # TODO: enable
128+
"B007",
129+
"B011",
130+
"B017", # TODO: enable
131+
"B018",
132+
"B020",
133+
"B023", # TODO: enable
134+
"B028",
135+
"B904",
125136
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
126137
"W191",
127138
"E111",

0 commit comments

Comments
 (0)