Skip to content

Commit

Permalink
Consistently skip TYPE_CHECKING coverage (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche authored Feb 12, 2024
1 parent 66fae25 commit 93d0e9d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ source_pkgs = ["cattrs", "tests"]
[tool.coverage.report]
exclude_also = [
"@overload",
"if TYPE_CHECKING:",
]

[tool.ruff]
Expand Down
15 changes: 11 additions & 4 deletions src/cattrs/gen/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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__ = [
Expand Down
4 changes: 2 additions & 2 deletions src/cattrs/gen/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 2 additions & 4 deletions src/cattrs/gen/typeddicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"]
Expand Down

0 comments on commit 93d0e9d

Please sign in to comment.