From 9d7a9161f72a14bc237cc98511f25a48f277a99f Mon Sep 17 00:00:00 2001 From: Justin Gu <97915@qq.com> Date: Fri, 12 Jun 2026 03:21:39 +0800 Subject: [PATCH] fix(web): remove TYPE_CHECKING guard for AsyncTdxClient in deps.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/easy_tdx/web/deps.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/easy_tdx/web/deps.py b/src/easy_tdx/web/deps.py index 877c8ca..f5c0881 100644 --- a/src/easy_tdx/web/deps.py +++ b/src/easy_tdx/web/deps.py @@ -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