Skip to content

Commit 16218ce

Browse files
aditik0303claude
andcommitted
test(llamaindex): make test_event_handler mypy-clean (fix CI lint)
Same pre-existing CI-lint failure (mypy runs over tests; this package has warn_unused_ignores=true so ignores must be exact): - FakeEvaluator evaluate_* -> (self, *args, **kwargs) -> Any so it satisfies EvaluatorProtocol; bare dict/list -> dict[str, Any]/list[Any]. - removed a now-unused call-arg ignore; added attr-defined ignore on the get_dispatcher import and an assignment ignore on the SimpleNamespace test context. (bedrock/vertex src errors are a local missing-extra artifact; CI installs --all-extras.) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 639b8c4 commit 16218ce

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

packages/uipath-llamaindex/tests/governance/test_event_handler.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
import pytest
1717
from llama_index.core.base.llms.types import ChatMessage, ChatResponse
18-
from llama_index.core.instrumentation import get_dispatcher
18+
from llama_index.core.instrumentation import ( # type: ignore[attr-defined]
19+
get_dispatcher,
20+
)
1921
from llama_index.core.instrumentation.events.agent import AgentToolCallEvent
2022
from llama_index.core.instrumentation.events.llm import (
2123
LLMChatEndEvent,
@@ -43,29 +45,29 @@ class FakeEvaluator:
4345

4446
def __init__(self, block_on: str | None = None) -> None:
4547
self.block_on = block_on
46-
self.calls: List[tuple[str, dict]] = []
48+
self.calls: List[tuple[str, dict[str, Any]]] = []
4749

4850
def _record(self, hook: str, **kwargs: Any) -> None:
4951
self.calls.append((hook, kwargs))
5052
if self.block_on == hook:
51-
raise GovernanceBlockException("blocked") # type: ignore[call-arg]
53+
raise GovernanceBlockException("blocked")
5254

53-
def evaluate_before_agent(self, **kwargs: Any) -> None:
55+
def evaluate_before_agent(self, *args: Any, **kwargs: Any) -> Any:
5456
self._record("before_agent", **kwargs)
5557

56-
def evaluate_after_agent(self, **kwargs: Any) -> None:
58+
def evaluate_after_agent(self, *args: Any, **kwargs: Any) -> Any:
5759
self._record("after_agent", **kwargs)
5860

59-
def evaluate_before_model(self, **kwargs: Any) -> None:
61+
def evaluate_before_model(self, *args: Any, **kwargs: Any) -> Any:
6062
self._record("before_model", **kwargs)
6163

62-
def evaluate_after_model(self, **kwargs: Any) -> None:
64+
def evaluate_after_model(self, *args: Any, **kwargs: Any) -> Any:
6365
self._record("after_model", **kwargs)
6466

65-
def evaluate_tool_call(self, **kwargs: Any) -> None:
67+
def evaluate_tool_call(self, *args: Any, **kwargs: Any) -> Any:
6668
self._record("tool_call", **kwargs)
6769

68-
def evaluate_after_tool(self, **kwargs: Any) -> None:
70+
def evaluate_after_tool(self, *args: Any, **kwargs: Any) -> Any:
6971
self._record("after_tool", **kwargs)
7072

7173

@@ -89,7 +91,7 @@ def _handler(ev: FakeEvaluator) -> GovernanceEventHandler:
8991
# --------------------------------------------------------------------------
9092

9193

92-
def _gov_handlers() -> list:
94+
def _gov_handlers() -> list[Any]:
9395
return [
9496
h
9597
for h in get_dispatcher().event_handlers
@@ -158,7 +160,7 @@ def _factory_without_init():
158160
from uipath_llamaindex.runtime.factory import UiPathLlamaIndexRuntimeFactory
159161

160162
f = UiPathLlamaIndexRuntimeFactory.__new__(UiPathLlamaIndexRuntimeFactory)
161-
f.context = SimpleNamespace(command="run") # read for debug_mode
163+
f.context = SimpleNamespace(command="run") # type: ignore[assignment] # read for debug_mode
162164
return f
163165

164166

0 commit comments

Comments
 (0)