Skip to content

Commit f89e319

Browse files
committed
FIX: Remove dead code paths identified by coverage, add PY310 tag
1 parent 434dd07 commit f89e319

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

nibabel/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,7 @@ def bench(label=None, verbose=1, extra_argv=None):
170170
code : ExitCode
171171
Returns the result of running the tests as a ``pytest.ExitCode`` enum
172172
"""
173-
try:
174-
from importlib.resources import as_file, files
175-
except ImportError:
176-
from importlib_resources import as_file, files
173+
from importlib.resources import as_file, files
177174

178175
args = []
179176
if extra_argv is not None:

nibabel/conftest.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010

1111
@pytest.fixture(scope='session', autouse=True)
1212
def legacy_printoptions():
13-
from packaging.version import Version
14-
15-
if Version(np.__version__) >= Version('1.22'):
16-
np.set_printoptions(legacy='1.21')
13+
np.set_printoptions(legacy='1.21')
1714

1815

1916
@pytest.fixture
@@ -24,7 +21,7 @@ def max_digits():
2421
orig_max_str_digits = sys.get_int_max_str_digits()
2522
yield sys.set_int_max_str_digits
2623
sys.set_int_max_str_digits(orig_max_str_digits)
27-
except AttributeError: # pragma: no cover
24+
except AttributeError: # PY310 # pragma: no cover
2825
# Nothing to do for versions of Python that lack these methods
2926
# They were added as DoS protection in Python 3.11 and backported to
3027
# some other versions.

nibabel/tests/test_init.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import pathlib
22
import unittest
3+
from importlib.resources import files
34
from unittest import mock
45

56
import pytest
67

7-
try:
8-
from importlib.resources import files
9-
except ImportError:
10-
from importlib_resources import files
11-
128
import nibabel as nib
139

1410

0 commit comments

Comments
 (0)