diff --git a/pyproject.toml b/pyproject.toml index 3737fc5f..25f7056c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,6 +108,7 @@ source_pkgs = ["cattrs", "tests"] [tool.coverage.report] exclude_also = [ "@overload", + "if TYPE_CHECKING:", ] [tool.ruff] diff --git a/src/cattrs/gen/__init__.py b/src/cattrs/gen/__init__.py index 8999ec92..cf1ceb3f 100644 --- a/src/cattrs/gen/__init__.py +++ b/src/cattrs/gen/__init__.py @@ -1,7 +1,16 @@ from __future__ import annotations import re -from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, Tuple, TypeVar +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Iterable, + Literal, + Mapping, + Tuple, + TypeVar, +) from attrs import NOTHING, Factory, resolve_types @@ -31,9 +40,7 @@ from ._lc import generate_unique_filename from ._shared import find_structure_handler -if TYPE_CHECKING: # pragma: no cover - from typing_extensions import Literal - +if TYPE_CHECKING: from ..converters import BaseConverter __all__ = [ diff --git a/src/cattrs/gen/_shared.py b/src/cattrs/gen/_shared.py index c1095659..5a9e3aa7 100644 --- a/src/cattrs/gen/_shared.py +++ b/src/cattrs/gen/_shared.py @@ -8,8 +8,8 @@ from ..dispatch import StructureHook from ..fns import raise_error -if TYPE_CHECKING: # pragma: no cover - from cattr.converters import BaseConverter +if TYPE_CHECKING: + from ..converters import BaseConverter def find_structure_handler( diff --git a/src/cattrs/gen/typeddicts.py b/src/cattrs/gen/typeddicts.py index 13decdaa..5614d6f8 100644 --- a/src/cattrs/gen/typeddicts.py +++ b/src/cattrs/gen/typeddicts.py @@ -2,7 +2,7 @@ import re import sys -from typing import TYPE_CHECKING, Any, Callable, TypeVar +from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar from attrs import NOTHING, Attribute @@ -50,9 +50,7 @@ def get_annots(cl) -> dict[str, Any]: from ._lc import generate_unique_filename from ._shared import find_structure_handler -if TYPE_CHECKING: # pragma: no cover - from typing_extensions import Literal - +if TYPE_CHECKING: from ..converters import BaseConverter __all__ = ["make_dict_unstructure_fn", "make_dict_structure_fn"]