33from __future__ import annotations
44
55import inspect
6- from typing import Any , TypeVar
6+ from typing import TYPE_CHECKING , Any , TypeVar
77
88import pytest
99from pydantic import BaseModel
@@ -23,6 +23,15 @@ class MyTypeC(BaseModel):
2323 pass
2424
2525
26+ if TYPE_CHECKING :
27+
28+ class NonExistentType :
29+ pass
30+
31+ class MissingType :
32+ pass
33+
34+
2635_T = TypeVar ("_T" )
2736
2837
@@ -143,7 +152,7 @@ class BadResponseHandler(Executor): # pyright: ignore[reportUnusedClass]
143152 @response_handler # pyright: ignore[reportUnknownArgumentType]
144153 async def handle_response (
145154 self ,
146- original_request : NonExistentType , # type: ignore[name-defined] # noqa: F821
155+ original_request : NonExistentType ,
147156 response : int ,
148157 ctx : WorkflowContext [MyTypeA , MyTypeB ],
149158 ) -> None :
@@ -171,7 +180,7 @@ def test_annotation_resolver_falls_back_to_raw_annotations(self):
171180 """Test that annotation resolution preserves raw annotations when a hint is unresolved."""
172181 from agent_framework ._workflows ._typing_utils import _resolve_function_annotations
173182
174- def sample (value : MissingType ) -> None : # type: ignore[name-defined] # noqa: F821
183+ def sample (value : MissingType ) -> None :
175184 pass
176185
177186 params = list (inspect .signature (sample ).parameters .values ())
@@ -189,5 +198,5 @@ def test_handler_unresolvable_annotation_raises(self):
189198
190199 class Bad (Executor ): # pyright: ignore[reportUnusedClass]
191200 @handler # pyright: ignore[reportUnknownArgumentType]
192- async def example (self , input : NonExistentType , ctx : WorkflowContext [MyTypeA , MyTypeB ]) -> None : # type: ignore[name-defined] # ty: ignore[unresolved-reference] # noqa: F821
201+ async def example (self , input : NonExistentType , ctx : WorkflowContext [MyTypeA , MyTypeB ]) -> None :
193202 pass
0 commit comments