mirror of
https://ghfast.top/https://github.com/aeroxw/easy_tdx_max.git
synced 2026-09-12 15:44:18 +08:00
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:
@@ -2,15 +2,12 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
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:
|
||||
"""从 app.state 获取共享的 AsyncTdxClient 实例。"""
|
||||
return typing.cast(AsyncTdxClient, request.app.state.tdx_client)
|
||||
client: AsyncTdxClient = request.app.state.tdx_client
|
||||
return client
|
||||
|
||||
Reference in New Issue
Block a user