Skip to content

Commit

Permalink
MNT: Apply Repo-Review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Dec 25, 2023
1 parent f7b9bc4 commit 10c50af
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions nibabel/_compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .optpkg import optional_package

if ty.TYPE_CHECKING: # pragma: no cover
import indexed_gzip # type: ignore
import indexed_gzip # type: ignore[import-not-found]
import pyzstd

HAVE_INDEXED_GZIP = True
Expand All @@ -40,7 +40,7 @@
if HAVE_INDEXED_GZIP:
COMPRESSED_FILE_LIKES += (indexed_gzip.IndexedGzipFile,)
COMPRESSION_ERRORS += (indexed_gzip.ZranError,)
from indexed_gzip import IndexedGzipFile # type: ignore
from indexed_gzip import IndexedGzipFile # type: ignore[import-not-found]

Check warning on line 43 in nibabel/_compression.py

View check run for this annotation

Codecov / codecov/patch

nibabel/_compression.py#L43

Added line #L43 was not covered by tests
else:
IndexedGzipFile = gzip.GzipFile

Expand Down
2 changes: 1 addition & 1 deletion nibabel/benchmarks/bench_arrayproxy_slicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# if memory_profiler is installed, we get memory usage results
try:
from memory_profiler import memory_usage # type: ignore
from memory_profiler import memory_usage # type: ignore[import-not-found]
except ImportError:
memory_usage = None

Expand Down
2 changes: 1 addition & 1 deletion nibabel/cmdline/dicomfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class dummy_fuse:


try:
import fuse # type: ignore
import fuse # type: ignore[import-not-found]

uid = os.getuid()
gid = os.getgid()
Expand Down
2 changes: 1 addition & 1 deletion nibabel/externals/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
from contextlib import contextmanager

@contextmanager # type: ignore
@contextmanager # type: ignore[no-redef]
def _chdir(path):
cwd = os.getcwd()
os.chdir(path)
Expand Down
2 changes: 1 addition & 1 deletion nibabel/minc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Minc2Image(Minc1Image):
def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
# Import of h5py might take awhile for MPI-enabled builds
# So we are importing it here "on demand"
import h5py # type: ignore
import h5py # type: ignore[import-not-found]

holder = file_map['image']
if holder.filename is None:
Expand Down
2 changes: 1 addition & 1 deletion nibabel/parrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ def from_filename(
strict_sort=strict_sort,
)

load = from_filename # type: ignore
load = from_filename # type: ignore[assignment]


load = PARRECImage.from_filename
2 changes: 1 addition & 1 deletion nibabel/pydicom_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

if have_dicom:
# Values not imported by default
import pydicom.values # type: ignore
import pydicom.values # type: ignore[import-not-found]

Check warning on line 45 in nibabel/pydicom_compat.py

View check run for this annotation

Codecov / codecov/patch

nibabel/pydicom_compat.py#L45

Added line #L45 was not covered by tests
from pydicom.dicomio import dcmread as read_file # noqa:F401
from pydicom.sequence import Sequence # noqa:F401

Expand Down
2 changes: 1 addition & 1 deletion nibabel/spm99analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def from_file_map(klass, file_map, *, mmap=True, keep_file_open=None):
contents = matf.read()
if len(contents) == 0:
return ret
import scipy.io as sio # type: ignore
import scipy.io as sio # type: ignore[import-not-found]

Check warning on line 278 in nibabel/spm99analyze.py

View check run for this annotation

Codecov / codecov/patch

nibabel/spm99analyze.py#L278

Added line #L278 was not covered by tests

mats = sio.loadmat(BytesIO(contents))
if 'mat' in mats: # this overrides a 'M', and includes any flip
Expand Down
2 changes: 1 addition & 1 deletion nibabel/tmpdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from contextlib import chdir as _chdir
except ImportError: # PY310

@contextmanager # type: ignore
@contextmanager # type: ignore[no-redef]
def _chdir(path):
cwd = os.getcwd()
os.chdir(path)
Expand Down
2 changes: 1 addition & 1 deletion nibabel/xmlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def to_xml(self, enc='utf-8', **kwargs) -> bytes:
Additional keyword arguments to :func:`xml.etree.ElementTree.tostring`.
"""
ele = self._to_xml_element()
return b'' if ele is None else tostring(ele, enc, **kwargs)
return tostring(ele, enc, **kwargs)


class XmlBasedHeader(FileBasedHeader, XmlSerializable):
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ __version_tuple__ = version_tuple = {version_tuple!r}

[tool.blue]
line_length = 99
target-version = ["py37"]
target-version = ["py38"]
force-exclude = """
(
_version.py
Expand All @@ -130,6 +130,9 @@ python_version = "3.11"
exclude = [
"/tests",
]
# strict = true
warn_unreachable = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[tool.codespell]
skip = "*/data/*,./nibabel-data"
Expand Down

0 comments on commit 10c50af

Please sign in to comment.