Skip to content

chore: fix mypy errors in tests/chat

What does this merge request do and why?

Address the 17 errors across 2 files found by running mypy and then remove the exclusion of the tests/chat directory.

Running mypy check...
tests/chat/test_gl_agent_remote.py:103: error: Need type annotation for "executor"  [var-annotated]
tests/chat/test_gl_agent_remote.py:116: error: Argument 1 to "set" has incompatible type "Any | None"; expected "Iterable[Any]"  [arg-type]
tests/chat/test_gl_agent_remote.py:333: error: Need type annotation for "executor"  [var-annotated]
tests/chat/test_gl_agent_remote.py:398: error: Need type annotation for "executor"  [var-annotated]
tests/chat/test_agent_react.py:59: error: Unexpected keyword argument "log" for "AgentToolAction"  [call-arg]
tests/chat/test_agent_react.py:69: error: Unexpected keyword argument "thought" for "AgentFinalAnswer"  [call-arg]
tests/chat/test_agent_react.py:69: error: Unexpected keyword argument "log" for "AgentFinalAnswer"  [call-arg]
tests/chat/test_agent_react.py:380: error: Argument "model_class_provider" to "ChatAnthropicParams" has incompatible type "Literal['anthropic']"; expected "Literal[ModelClassProvider.ANTHROPIC]"  [arg-type]
tests/chat/test_agent_react.py:395: error: Argument "model_class_provider" to "ChatAnthropicParams" has incompatible type "Literal['anthropic']"; expected "Literal[ModelClassProvider.ANTHROPIC]"  [arg-type]
tests/chat/test_agent_react.py:410: error: Argument "model_class_provider" to "ChatLiteLLMParams" has incompatible type "Literal['litellm']"; expected "Literal[ModelClassProvider.LITE_LLM]"  [arg-type]
tests/chat/test_agent_react.py:425: error: Argument "model_class_provider" to "ChatLiteLLMParams" has incompatible type "Literal['litellm']"; expected "Literal[ModelClassProvider.LITE_LLM]"  [arg-type]
tests/chat/test_agent_react.py:440: error: Argument "model_class_provider" to "ChatLiteLLMParams" has incompatible type "Literal['litellm']"; expected "Literal[ModelClassProvider.LITE_LLM]"  [arg-type]
tests/chat/test_agent_react.py:454: error: Argument 1 to "set" of "ContextVar" has incompatible type "list[str]"; expected "set[str]"  [arg-type]
tests/chat/test_agent_react.py:456: error: Argument 1 to "set" of "ContextVar" has incompatible type "list[Never]"; expected "set[str]"  [arg-type]
tests/chat/test_agent_react.py:460: error: "PromptValue" has no attribute "messages"; maybe "to_messages"?  [attr-defined]
tests/chat/test_agent_react.py:464: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]"  [index]
tests/chat/test_agent_react.py:465: error: Invalid index type "str" for "str"; expected type "SupportsIndex | slice[Any, Any, Any]"  [index]
Found 17 errors in 2 files (checked 131 source files)

Solving these and enabling correct type linting will improve the maintainability and reliability of the AIGW!

After this MR we are down to zero issues in tests/chat/*

This is part of a broader effort: #715 (closed) to make mypy runnable against AIGW

How to set up and validate locally

Setting up the project and running linting, and the tests, while paying close attention to tests/chat/test_agent_react.py and tests/chat/test_gl_agent_remote.py.

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.

Closes #840 (closed)

Edited by Stephan Rayner

Merge request reports

Loading