diff --git a/nibabel/gifti/tests/test_parse_gifti_fast.py b/nibabel/gifti/tests/test_parse_gifti_fast.py index 8cb7c9679..6ca54df03 100644 --- a/nibabel/gifti/tests/test_parse_gifti_fast.py +++ b/nibabel/gifti/tests/test_parse_gifti_fast.py @@ -241,7 +241,7 @@ def test_load_dataarray1(): me = img.darrays[0].meta assert 'AnatomicalStructurePrimary' in me assert 'AnatomicalStructureSecondary' in me - me['AnatomicalStructurePrimary'] == 'CortexLeft' + assert me['AnatomicalStructurePrimary'] == 'CortexLeft' assert_array_almost_equal(img.darrays[0].coordsys.xform, np.eye(4, 4)) assert xform_codes.niistring[img.darrays[0].coordsys.dataspace] == 'NIFTI_XFORM_TALAIRACH' assert xform_codes.niistring[img.darrays[0].coordsys.xformspace] == 'NIFTI_XFORM_TALAIRACH' @@ -279,7 +279,7 @@ def test_load_dataarray4(): def test_dataarray5(): img5 = load(DATA_FILE5) for da in img5.darrays: - gifti_endian_codes.byteorder[da.endian] == 'little' + assert gifti_endian_codes.byteorder[da.endian] == 'little' assert_array_almost_equal(img5.darrays[0].data, DATA_FILE5_darr1) assert_array_almost_equal(img5.darrays[1].data, DATA_FILE5_darr2) # Round trip tested below diff --git a/nibabel/tests/conftest.py b/nibabel/tests/conftest.py index 3cf54a34c..fb1370845 100644 --- a/nibabel/tests/conftest.py +++ b/nibabel/tests/conftest.py @@ -6,7 +6,7 @@ # Generate dynamic fixtures def pytest_generate_tests(metafunc): if 'supported_dtype' in metafunc.fixturenames: - if metafunc.cls is None or not getattr(metafunc.cls, 'image_class'): + if metafunc.cls is None or not metafunc.cls.image_class: raise pytest.UsageError( 'Attempting to use supported_dtype fixture outside an image test case' ) diff --git a/nibabel/tests/test_openers.py b/nibabel/tests/test_openers.py index 15290d5ef..0b5879433 100644 --- a/nibabel/tests/test_openers.py +++ b/nibabel/tests/test_openers.py @@ -431,17 +431,17 @@ def test_DeterministicGzipFile_fileobj(): with open('test.gz', 'wb') as fobj: with DeterministicGzipFile(filename='', mode='wb', fileobj=fobj) as gzobj: gzobj.write(msg) - md5sum('test.gz') == ref_chksum + assert md5sum('test.gz') == ref_chksum with open('test.gz', 'wb') as fobj: with DeterministicGzipFile(fileobj=fobj, mode='wb') as gzobj: gzobj.write(msg) - md5sum('test.gz') == ref_chksum + assert md5sum('test.gz') == ref_chksum with open('test.gz', 'wb') as fobj: with DeterministicGzipFile(filename='test.gz', mode='wb', fileobj=fobj) as gzobj: gzobj.write(msg) - md5sum('test.gz') == ref_chksum + assert md5sum('test.gz') == ref_chksum def test_bitwise_determinism(): diff --git a/nibabel/viewers.py b/nibabel/viewers.py index 0dc2f0daf..4dd8a1c25 100644 --- a/nibabel/viewers.py +++ b/nibabel/viewers.py @@ -447,7 +447,7 @@ def _set_position(self, x, y, z, notify=True): # Matplotlib handlers #################################################### def _in_axis(self, event): """Return axis index if within one of our axes, else None""" - if getattr(event, 'inaxes') is None: + if event.inaxes is None: return None for ii, ax in enumerate(self._axes): if event.inaxes is ax: diff --git a/pyproject.toml b/pyproject.toml index 2840119c4..ead2782b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -116,12 +116,23 @@ exclude = ["doc", "nibabel/externals", "tools", "version.py", "versioneer.py"] [tool.ruff.lint] select = [ + "B", "F", "I", "Q", "UP", ] ignore = [ + "B006", # TODO: enable + "B008", # TODO: enable + "B007", + "B011", + "B017", # TODO: enable + "B018", + "B020", + "B023", # TODO: enable + "B028", + "B904", # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules "W191", "E111",