improve app_src typing (#4324)
This commit is contained in:
parent
e457d53924
commit
2cb193e8d6
@ -212,7 +212,7 @@ def app_with_one_page(
|
||||
"""
|
||||
root = tmp_path_factory.mktemp("app1")
|
||||
|
||||
yield AppHarness.create(root=root, app_source=AppWithOnePage) # type: ignore
|
||||
yield AppHarness.create(root=root, app_source=AppWithOnePage)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
@ -276,7 +276,7 @@ def app_with_thousand_pages(
|
||||
|
||||
yield AppHarness.create(
|
||||
root=root,
|
||||
app_source=functools.partial( # type: ignore
|
||||
app_source=functools.partial(
|
||||
AppWithThousandPages,
|
||||
render_comp=render_multiple_pages, # type: ignore
|
||||
),
|
||||
|
@ -118,7 +118,7 @@ class AppHarness:
|
||||
|
||||
app_name: str
|
||||
app_source: Optional[
|
||||
types.FunctionType | types.ModuleType | str | functools.partial[Any]
|
||||
Callable[[], None] | types.ModuleType | str | functools.partial[Any]
|
||||
]
|
||||
app_path: pathlib.Path
|
||||
app_module_path: pathlib.Path
|
||||
@ -138,7 +138,7 @@ class AppHarness:
|
||||
cls,
|
||||
root: pathlib.Path,
|
||||
app_source: Optional[
|
||||
types.FunctionType | types.ModuleType | str | functools.partial[Any]
|
||||
Callable[[], None] | types.ModuleType | str | functools.partial[Any]
|
||||
] = None,
|
||||
app_name: Optional[str] = None,
|
||||
) -> "AppHarness":
|
||||
|
@ -190,7 +190,7 @@ def background_task(
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("background_task"),
|
||||
app_source=BackgroundTask, # type: ignore
|
||||
app_source=BackgroundTask,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -355,7 +355,7 @@ def call_script(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("call_script"),
|
||||
app_source=CallScript, # type: ignore
|
||||
app_source=CallScript,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -137,7 +137,7 @@ def client_side(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("client_side"),
|
||||
app_source=ClientSide, # type: ignore
|
||||
app_source=ClientSide,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -115,7 +115,7 @@ def component_state_app(tmp_path) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=ComponentStateApp, # type: ignore
|
||||
app_source=ComponentStateApp,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -125,7 +125,7 @@ def computed_vars(
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("computed_vars"),
|
||||
app_source=ComputedVars, # type: ignore
|
||||
app_source=ComputedVars,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -52,7 +52,7 @@ def connection_banner(tmp_path) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=ConnectionBanner, # type: ignore
|
||||
app_source=ConnectionBanner,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -44,7 +44,7 @@ def deploy_url_sample(
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("deploy_url_sample"),
|
||||
app_source=DeployUrlSample, # type: ignore
|
||||
app_source=DeployUrlSample,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -85,7 +85,7 @@ def dynamic_components(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("dynamic_components"),
|
||||
app_source=DynamicComponents, # type: ignore
|
||||
app_source=DynamicComponents,
|
||||
) as harness:
|
||||
assert harness.app_instance is not None, "app is not running"
|
||||
yield harness
|
||||
|
@ -155,7 +155,7 @@ def dynamic_route(
|
||||
with app_harness_env.create(
|
||||
root=tmp_path_factory.mktemp("dynamic_route"),
|
||||
app_name=f"dynamicroute_{app_harness_env.__name__.lower()}",
|
||||
app_source=DynamicRoute, # type: ignore
|
||||
app_source=DynamicRoute,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -172,7 +172,7 @@ def event_action(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("event_action"),
|
||||
app_source=TestEventAction, # type: ignore
|
||||
app_source=TestEventAction,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -277,7 +277,7 @@ def event_chain(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("event_chain"),
|
||||
app_source=EventChain, # type: ignore
|
||||
app_source=EventChain,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -70,7 +70,7 @@ def test_app(
|
||||
with app_harness_env.create(
|
||||
root=tmp_path_factory.mktemp("test_app"),
|
||||
app_name=f"testapp_{app_harness_env.__name__.lower()}",
|
||||
app_source=TestApp, # type: ignore
|
||||
app_source=TestApp,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -159,7 +159,7 @@ def form_submit(request, tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
param_id = request._pyfuncitem.callspec.id.replace("-", "_")
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("form_submit"),
|
||||
app_source=request.param, # type: ignore
|
||||
app_source=request.param,
|
||||
app_name=request.param.func.__name__ + f"_{param_id}",
|
||||
) as harness:
|
||||
assert harness.app_instance is not None, "app is not running"
|
||||
|
@ -63,7 +63,7 @@ def fully_controlled_input(tmp_path) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=FullyControlledInput, # type: ignore
|
||||
app_source=FullyControlledInput,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -80,7 +80,7 @@ def lifespan_app(tmp_path) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=LifespanApp, # type: ignore
|
||||
app_source=LifespanApp,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -62,7 +62,7 @@ def login_sample(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("login_sample"),
|
||||
app_source=LoginSample, # type: ignore
|
||||
app_source=LoginSample,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -84,7 +84,7 @@ def media_app(tmp_path) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=MediaApp, # type: ignore
|
||||
app_source=MediaApp,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -52,7 +52,7 @@ def navigation_app(tmp_path) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=NavigationApp, # type: ignore
|
||||
app_source=NavigationApp,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -93,7 +93,7 @@ def server_side_event(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("server_side_event"),
|
||||
app_source=ServerSideEvent, # type: ignore
|
||||
app_source=ServerSideEvent,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -39,7 +39,7 @@ def shared_state(
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("shared_state"),
|
||||
app_source=SharedStateApp, # type: ignore
|
||||
app_source=SharedStateApp,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -217,7 +217,7 @@ def state_inheritance(
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("state_inheritance"),
|
||||
app_source=StateInheritance, # type: ignore
|
||||
app_source=StateInheritance,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -78,7 +78,7 @@ def tailwind_app(tmp_path, tailwind_disabled) -> Generator[AppHarness, None, Non
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=functools.partial(TailwindApp, tailwind_disabled=tailwind_disabled), # type: ignore
|
||||
app_source=functools.partial(TailwindApp, tailwind_disabled=tailwind_disabled),
|
||||
app_name="tailwind_disabled_app" if tailwind_disabled else "tailwind_app",
|
||||
) as harness:
|
||||
yield harness
|
||||
|
@ -133,7 +133,7 @@ def upload_file(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("upload_file"),
|
||||
app_source=UploadFile, # type: ignore
|
||||
app_source=UploadFile,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -613,7 +613,7 @@ def var_operations(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("var_operations"),
|
||||
app_source=VarOperations, # type: ignore
|
||||
app_source=VarOperations,
|
||||
) as harness:
|
||||
assert harness.app_instance is not None, "app is not running"
|
||||
yield harness
|
||||
|
@ -33,7 +33,7 @@ def stateless_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("stateless_app"),
|
||||
app_source=StatelessApp, # type: ignore
|
||||
app_source=StatelessApp,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -68,7 +68,7 @@ def table_app(tmp_path_factory) -> Generator[AppHarness, None, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path_factory.mktemp("table"),
|
||||
app_source=Table, # type: ignore
|
||||
app_source=Table,
|
||||
) as harness:
|
||||
assert harness.app_instance is not None, "app is not running"
|
||||
yield harness
|
||||
|
@ -43,7 +43,7 @@ def node_version_app(tmp_path) -> Generator[AppHarness, Any, None]:
|
||||
"""
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=TestNodeVersionApp, # type: ignore
|
||||
app_source=TestNodeVersionApp,
|
||||
) as harness:
|
||||
yield harness
|
||||
|
||||
|
@ -29,7 +29,7 @@ def test_app_harness(tmp_path):
|
||||
|
||||
with AppHarness.create(
|
||||
root=tmp_path,
|
||||
app_source=BasicApp, # type: ignore
|
||||
app_source=BasicApp,
|
||||
) as harness:
|
||||
assert harness.app_instance is not None
|
||||
assert harness.backend is not None
|
||||
|
Loading…
Reference in New Issue
Block a user