The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
test(assets): keep test typing 3.10-compatible (#16305)
Simon Pinfoldeecbfb404637
diff --git a/tests-unit/assets_test/helpers.py b/tests-unit/assets_test/helpers.pyindex 06569de65..4e400184b 100644--- a/tests-unit/assets_test/helpers.py+++ b/tests-unit/assets_test/helpers.py@@ -7,7 +7,7 @@ import uuidfrom collections.abc import Iterator, Mappingfrom dataclasses import dataclassfrom datetime import datetime, timedelta-from typing import NotRequired, TypeAlias, TypedDict+from typing import TypeAlias, TypedDictimport pytestimport requests@@ -22,17 +22,23 @@ from app.assets.database.queries.records import create_content, create_recordfrom app.database.models import Base-class AssetItem(TypedDict):+class _AssetItemOptional(TypedDict, total=False):+ preview_id: str+++class AssetItem(_AssetItemOptional):id: strname: str- preview_id: NotRequired[str]-class AssetListBody(TypedDict):+class _AssetListBodyOptional(TypedDict, total=False):+ next_cursor: str+++class AssetListBody(_AssetListBodyOptional):assets: list[AssetItem]total: inthas_more: bool- next_cursor: NotRequired[str]class ErrorItem(TypedDict):diff --git a/tests-unit/assets_test/test_api_surface.py b/tests-unit/assets_test/test_api_surface.pyindex 9d2e504ff..946016d62 100644--- a/tests-unit/assets_test/test_api_surface.py+++ b/tests-unit/assets_test/test_api_surface.py@@ -6,7 +6,7 @@ import uuidfrom collections.abc import Callable, Collection, Sequencefrom dataclasses import dataclassfrom pathlib import Path-from typing import Literal, TypedDict, assert_never+from typing import Literal, NoReturn, TypedDictimport pytestimport requests@@ -86,6 +86,10 @@ ROUTE_SPECS: tuple[RouteSpec, ...] = (EXPECTED_ROUTE_KEYS = {f"{spec.method} {spec.path}" for spec in ROUTE_SPECS}+def _assert_never(value: NoReturn) -> NoReturn:+ raise AssertionError(f"unhandled route kind: {value!r}")++def _normalize_route_path(raw_path: str) -> str:path = raw_path.replace("{{", "{").replace("}}", "}")path = NESTED_PARAM_RE.sub(r"{\g<name>}", path)@@ -233,7 +237,7 @@ def _request_for_spec(spec: RouteSpec, ctx: SmokeContext) -> requests.Response:case "prune_missing_assets":return ctx.http.post(f"{ctx.api_base}/api/assets/prune", timeout=120)case _:- assert_never(spec.kind)+ _assert_never(spec.kind)def test_route_coverage_guard_rejects_extra_route() -> None: