Skip to content

Commit 93d0e9d

Browse files
authored
Consistently skip TYPE_CHECKING coverage (#502)
1 parent 66fae25 commit 93d0e9d

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ source_pkgs = ["cattrs", "tests"]
108108
[tool.coverage.report]
109109
exclude_also = [
110110
"@overload",
111+
"if TYPE_CHECKING:",
111112
]
112113

113114
[tool.ruff]

src/cattrs/gen/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
from __future__ import annotations
22

33
import re
4-
from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, Tuple, TypeVar
4+
from typing import (
5+
TYPE_CHECKING,
6+
Any,
7+
Callable,
8+
Iterable,
9+
Literal,
10+
Mapping,
11+
Tuple,
12+
TypeVar,
13+
)
514

615
from attrs import NOTHING, Factory, resolve_types
716

@@ -31,9 +40,7 @@
3140
from ._lc import generate_unique_filename
3241
from ._shared import find_structure_handler
3342

34-
if TYPE_CHECKING: # pragma: no cover
35-
from typing_extensions import Literal
36-
43+
if TYPE_CHECKING:
3744
from ..converters import BaseConverter
3845

3946
__all__ = [

src/cattrs/gen/_shared.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from ..dispatch import StructureHook
99
from ..fns import raise_error
1010

11-
if TYPE_CHECKING: # pragma: no cover
12-
from cattr.converters import BaseConverter
11+
if TYPE_CHECKING:
12+
from ..converters import BaseConverter
1313

1414

1515
def find_structure_handler(

src/cattrs/gen/typeddicts.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import re
44
import sys
5-
from typing import TYPE_CHECKING, Any, Callable, TypeVar
5+
from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar
66

77
from attrs import NOTHING, Attribute
88

@@ -50,9 +50,7 @@ def get_annots(cl) -> dict[str, Any]:
5050
from ._lc import generate_unique_filename
5151
from ._shared import find_structure_handler
5252

53-
if TYPE_CHECKING: # pragma: no cover
54-
from typing_extensions import Literal
55-
53+
if TYPE_CHECKING:
5654
from ..converters import BaseConverter
5755

5856
__all__ = ["make_dict_unstructure_fn", "make_dict_structure_fn"]

0 commit comments

Comments
 (0)