Skip to content

Commit a85aa6c

Browse files
committed
avoid importing testing module
1 parent 9f879a6 commit a85aa6c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ show_missing = true
3030
skip_covered = true
3131
sort = "Name"
3232
exclude_lines = [
33-
"pragma: no cover",
34-
'\.\.\.',
35-
"raise NotImplementedError",
33+
# These are regex patterns
34+
'pragma: no cover',
35+
'...',
36+
'raise NotImplementedError',
37+
'if TYPE_CHECKING[\s:]',
3638
]
3739
omit = [
3840
"src/idom/__main__.py",

src/idom/widgets.py

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

33
from base64 import b64encode
4-
from typing import Any, Callable, Iterable, Tuple, TypeVar, Union
4+
from typing import TYPE_CHECKING, Any, Callable, Iterable, Tuple, TypeVar, Union
55

66
from typing_extensions import Protocol
77

@@ -10,7 +10,6 @@
1010
from . import html
1111
from ._warnings import warn
1212
from .core.types import ComponentConstructor, VdomDict
13-
from .testing.backend import _hotswap, _MountFunc
1413

1514

1615
def image(
@@ -95,6 +94,10 @@ def __call__(self, value: str) -> _CastTo:
9594
...
9695

9796

97+
if TYPE_CHECKING:
98+
from .testing.backend import _MountFunc
99+
100+
98101
def hotswap(
99102
update_on_change: bool = False,
100103
) -> Tuple[_MountFunc, ComponentConstructor]: # pragma: no cover
@@ -103,4 +106,6 @@ def hotswap(
103106
DeprecationWarning,
104107
stacklevel=2,
105108
)
109+
from .testing.backend import _hotswap
110+
106111
return _hotswap(update_on_change)

0 commit comments

Comments
 (0)