Fix lint and type-checker issues

- Add ClassVar import to tests for proper type annotations
- Add type ignore comment for crewai_tools import to suppress mypy error
- Fix line length violations by breaking long assert statements
- Add ClassVar annotations for mutable class attributes in test classes

Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
Devin AI
2025-09-06 07:56:52 +00:00
parent 4e19ecbf7b
commit f06765c86d
2 changed files with 13 additions and 6 deletions

View File

@@ -90,7 +90,7 @@ def CrewBase(cls: T) -> T:
if not self.mcp_server_params:
return []
from crewai_tools import MCPServerAdapter
from crewai_tools import MCPServerAdapter # type: ignore[import-untyped]
adapter = getattr(self, '_mcp_server_adapter', None)
if not adapter:

View File

@@ -1,4 +1,5 @@
from typing import List
from typing import ClassVar
from unittest.mock import Mock, patch
import pytest
@@ -284,7 +285,9 @@ def test_internal_crew_with_mcp():
assert crew.reporting_analyst().tools == [simple_tool, another_simple_tool]
assert crew.researcher().tools == [simple_tool]
adapter_mock.assert_called_once_with({"host": "localhost", "port": 8000}, connect_timeout=30)
adapter_mock.assert_called_once_with(
{"host": "localhost", "port": 8000}, connect_timeout=30
)
def test_internal_crew_with_mcp_custom_timeout():
with patch("embedchain.client.Client.setup"):
@@ -293,7 +296,7 @@ def test_internal_crew_with_mcp_custom_timeout():
@CrewBase
class CrewWithCustomTimeout(InternalCrew):
mcp_server_params = {"host": "localhost", "port": 8000}
mcp_server_params: ClassVar = {"host": "localhost", "port": 8000}
@agent
def test_agent(self):
@@ -308,7 +311,9 @@ def test_internal_crew_with_mcp_custom_timeout():
crew = CrewWithCustomTimeout()
assert crew.test_agent().tools == [simple_tool]
adapter_mock.assert_called_once_with({"host": "localhost", "port": 8000}, connect_timeout=60)
adapter_mock.assert_called_once_with(
{"host": "localhost", "port": 8000}, connect_timeout=60
)
def test_internal_crew_with_mcp_backward_compatibility():
@@ -318,7 +323,7 @@ def test_internal_crew_with_mcp_backward_compatibility():
@CrewBase
class CrewWithoutTimeout(InternalCrew):
mcp_server_params = {"host": "localhost", "port": 8000}
mcp_server_params: ClassVar = {"host": "localhost", "port": 8000}
@agent
def test_agent(self):
@@ -333,4 +338,6 @@ def test_internal_crew_with_mcp_backward_compatibility():
crew = CrewWithoutTimeout()
assert crew.test_agent().tools == [simple_tool]
adapter_mock.assert_called_once_with({"host": "localhost", "port": 8000}, connect_timeout=30)
adapter_mock.assert_called_once_with(
{"host": "localhost", "port": 8000}, connect_timeout=30
)