fix(web): remove TYPE_CHECKING guard for AsyncTdxClient in deps.py

The typing.cast(AsyncTdxClient, ...) evaluated AsyncTdxClient at
runtime, but the import was gated behind TYPE_CHECKING, causing
NameError in production.  Direct import is safe here — web module
already depends on easy_tdx core.
This commit is contained in:
Justin Gu
2026-06-12 03:21:39 +08:00
parent 54dd65ed85
commit 9d7a9161f7
+3 -6
View File
@@ -2,15 +2,12 @@
from __future__ import annotations from __future__ import annotations
import typing
from typing import TYPE_CHECKING
from fastapi import Request from fastapi import Request
if TYPE_CHECKING: from easy_tdx.client import AsyncTdxClient
from easy_tdx.client import AsyncTdxClient
def get_client(request: Request) -> AsyncTdxClient: def get_client(request: Request) -> AsyncTdxClient:
"""从 app.state 获取共享的 AsyncTdxClient 实例。""" """从 app.state 获取共享的 AsyncTdxClient 实例。"""
return typing.cast(AsyncTdxClient, request.app.state.tdx_client) client: AsyncTdxClient = request.app.state.tdx_client
return client