Skip to content

Commit 12e7d20

Browse files
committed
fix types
1 parent 80af9d0 commit 12e7d20

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

idom/testing.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010
import idom
1111
from idom.core.element import AbstractElement, ElementConstructor
1212
from idom.server.sanic import SanicRenderServer, PerClientStateServer
13-
from idom.server.prefab import hotswap_server, multiview_server, MultiViewMount
13+
from idom.widgets.utils import MultiViewMount
14+
from idom.server.prefab import hotswap_server, multiview_server
1415
from idom.server.utils import find_available_port
1516
from idom.utils import Ref
1617

1718

1819
DisplayFunction = Callable[[Union[ElementConstructor, AbstractElement], str], None]
20+
DisplayFunctionContext = Callable[[], "AbstractContextManager[DisplayFunction]"]
1921

2022

2123
@contextmanager
2224
def open_selenium_chrome_driver_and_display_context(
2325
headless: bool, driver_timeout: float = 3.0, wait_for_server_start: float = 1.0
24-
) -> Iterator[Tuple[Chrome, DisplayFunction]]:
26+
) -> Iterator[Tuple[Chrome, DisplayFunctionContext]]:
2527
host = "127.0.0.1"
2628
port = find_available_port(host)
2729
server_url = f"http://{host}:{port}"
@@ -48,7 +50,7 @@ def create_selenium_page_get_and_display_context(
4850
server: "SanicRenderServerWithLastError",
4951
server_url: str,
5052
element_mount_function: Callable[..., None],
51-
) -> Tuple[Callable[[str], None], "AbstractContextManager[DisplayFunction]"]:
53+
) -> Tuple[Callable[[str], None], DisplayFunctionContext]:
5254
display_id = Ref(0)
5355

5456
def get_page(query: str = "") -> None:
@@ -80,7 +82,7 @@ def display_function(
8082
return None
8183

8284
@contextmanager
83-
def display_context():
85+
def display_context() -> Iterator[DisplayFunction]:
8486
server.last_server_error_for_idom_testing.current = None
8587
try:
8688
yield display_function
@@ -97,7 +99,7 @@ def create_sanic_multiview_mount_and_server(
9799
port: int,
98100
debug: bool = False,
99101
app: Optional[Sanic] = None,
100-
) -> Tuple[MultiViewMount, SanicRenderServer]:
102+
) -> Tuple[MultiViewMount, "SanicRenderServerWithLastError"]:
101103
return multiview_server(
102104
create_sanic_server_type_for_testing(server_type),
103105
host,
@@ -115,7 +117,7 @@ def create_sanic_hotswap_mount_and_server(
115117
sync_views: bool = False,
116118
debug: bool = False,
117119
app: Optional[Sanic] = None,
118-
) -> Tuple[Callable[..., None], SanicRenderServer]:
120+
) -> Tuple[Callable[..., None], "SanicRenderServerWithLastError"]:
119121

120122
return hotswap_server(
121123
create_sanic_server_type_for_testing(server_type),

0 commit comments

Comments
 (0)