diff --git a/src/pydicom/filebase.py b/src/pydicom/filebase.py index d7a082f940..817bc09262 100644 --- a/src/pydicom/filebase.py +++ b/src/pydicom/filebase.py @@ -1,12 +1,14 @@ # Copyright 2008-2020 pydicom authors. See LICENSE file for details. """Hold DicomFile class, which does basic I/O for a dicom file.""" -from collections.abc import Callable from io import BytesIO import os from struct import Struct from types import TracebackType -from typing import cast, Any, TypeVar, Protocol +from typing import TYPE_CHECKING, cast, Any, TypeVar, Protocol + +if TYPE_CHECKING: # pragma: no cover + from collections.abc import Callable ExitException = tuple[ diff --git a/src/pydicom/pixels/common.py b/src/pydicom/pixels/common.py index ee91a8660c..89852aabe3 100644 --- a/src/pydicom/pixels/common.py +++ b/src/pydicom/pixels/common.py @@ -1,7 +1,6 @@ # Copyright 2008-2024 pydicom authors. See LICENSE file for details. """Common objects for pixel data handling.""" -from collections.abc import Callable from enum import Enum, unique from importlib import import_module from typing import TYPE_CHECKING, Any, TypedDict @@ -11,6 +10,7 @@ from pydicom.uid import UID if TYPE_CHECKING: # pragma: no cover + from collections.abc import Callable from pydicom.dataset import Dataset from pydicom.pixels.decoders.base import DecodeOptions, DecodeFunction from pydicom.pixels.encoders.base import EncodeOptions, EncodeFunction diff --git a/src/pydicom/pixels/processing.py b/src/pydicom/pixels/processing.py index bbc56c4f43..967b3ceb20 100644 --- a/src/pydicom/pixels/processing.py +++ b/src/pydicom/pixels/processing.py @@ -4,7 +4,6 @@ from io import BytesIO from struct import unpack, unpack_from from typing import TYPE_CHECKING, cast -from collections.abc import Iterable try: import numpy as np @@ -27,6 +26,7 @@ from pydicom.valuerep import VR if TYPE_CHECKING: # pragma: no cover + from collections.abc import Iterable from pydicom.dataset import Dataset diff --git a/src/pydicom/pixels/utils.py b/src/pydicom/pixels/utils.py index 52b88ae4a5..b279a3e032 100644 --- a/src/pydicom/pixels/utils.py +++ b/src/pydicom/pixels/utils.py @@ -5,7 +5,6 @@ import importlib import logging from pathlib import Path -from os import PathLike from struct import unpack, Struct from sys import byteorder from typing import BinaryIO, Any, cast, TYPE_CHECKING @@ -32,6 +31,7 @@ from pydicom.valuerep import VR if TYPE_CHECKING: # pragma: no cover + from os import PathLike from pydicom.dataset import Dataset