From b5f2161e34f0d4cdf3f448f26f766a25b922fe61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moura?= Date: Fri, 27 Dec 2024 16:31:20 -0300 Subject: [PATCH] fix linters --- src/crewai/tools/agent_tools/add_image_tool.py | 4 ++-- src/crewai/tools/agent_tools/delegate_work_tool.py | 4 ++-- src/crewai/tools/tool_usage.py | 11 +++++------ tests/crew_test.py | 10 ++++++---- tests/knowledge/knowledge_test.py | 2 +- tests/test_task_guardrails.py | 4 +--- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/crewai/tools/agent_tools/add_image_tool.py b/src/crewai/tools/agent_tools/add_image_tool.py index 0ace62f85..6b081ba2e 100644 --- a/src/crewai/tools/agent_tools/add_image_tool.py +++ b/src/crewai/tools/agent_tools/add_image_tool.py @@ -1,7 +1,7 @@ -from typing import Optional -from pydantic import BaseModel, Field from crewai.tools.base_tool import BaseTool from crewai.utilities import I18N +from pydantic import BaseModel, Field +from typing import Optional i18n = I18N() diff --git a/src/crewai/tools/agent_tools/delegate_work_tool.py b/src/crewai/tools/agent_tools/delegate_work_tool.py index 45f12772d..5ffc13570 100644 --- a/src/crewai/tools/agent_tools/delegate_work_tool.py +++ b/src/crewai/tools/agent_tools/delegate_work_tool.py @@ -1,6 +1,6 @@ -from typing import Optional -from pydantic import BaseModel, Field from crewai.tools.agent_tools.base_agent_tools import BaseAgentTool +from pydantic import BaseModel, Field +from typing import Optional class DelegateWorkToolSchema(BaseModel): diff --git a/src/crewai/tools/tool_usage.py b/src/crewai/tools/tool_usage.py index 87162b7a1..03b47998c 100644 --- a/src/crewai/tools/tool_usage.py +++ b/src/crewai/tools/tool_usage.py @@ -1,26 +1,25 @@ import ast import datetime -import time from difflib import SequenceMatcher +import time from textwrap import dedent from typing import Any, List, Union -from crewai.tools.structured_tool import CrewStructuredTool -import crewai.utilities.events as events from crewai.agents.tools_handler import ToolsHandler from crewai.task import Task from crewai.telemetry import Telemetry from crewai.tools import BaseTool +from crewai.tools.structured_tool import CrewStructuredTool from crewai.tools.tool_calling import InstructorToolCalling, ToolCalling from crewai.tools.tool_usage_events import ToolUsageError, ToolUsageFinished -from crewai.utilities import I18N, Converter, ConverterError, Printer +from crewai.utilities import Converter, ConverterError, I18N, Printer +import crewai.utilities.events as events try: import agentops # type: ignore except ImportError: agentops = None - -OPENAI_BIGGER_MODELS = ["gpt-4", "gpt-4o", "o1-preview", "o1-mini"] +OPENAI_BIGGER_MODELS = ["gpt-4", "gpt-4o", "o1-preview", "o1-mini", "o1", "o3", "o3-mini"] class ToolUsageErrorException(Exception): diff --git a/tests/crew_test.py b/tests/crew_test.py index 1b60a1a31..389771ad2 100644 --- a/tests/crew_test.py +++ b/tests/crew_test.py @@ -417,9 +417,11 @@ def test_crew_with_delegating_agents(): @pytest.mark.vcr(filter_headers=["authorization"]) def test_crew_with_delegating_agents_should_not_override_task_tools(): from typing import Type - from crewai.tools import BaseTool + from pydantic import BaseModel, Field + from crewai.tools import BaseTool + class TestToolInput(BaseModel): """Input schema for TestTool.""" query: str = Field(..., description="Query to process") @@ -470,9 +472,9 @@ def test_crew_with_delegating_agents_should_not_override_task_tools(): @pytest.mark.vcr(filter_headers=["authorization"]) def test_crew_with_delegating_agents_should_not_override_agent_tools(): - from typing import Type from crewai.tools import BaseTool from pydantic import BaseModel, Field + from typing import Type class TestToolInput(BaseModel): """Input schema for TestTool.""" @@ -584,9 +586,9 @@ def test_task_tools_override_agent_tools_with_allow_delegation(): """ Test that task tools override agent tools while preserving delegation tools when allow_delegation=True """ - from typing import Type from crewai.tools import BaseTool from pydantic import BaseModel, Field + from typing import Type class TestToolInput(BaseModel): query: str = Field(..., description="Query to process") @@ -2883,10 +2885,10 @@ def test_task_tools_preserve_code_execution_tools(): """ Test that task tools don't override code execution tools when allow_code_execution=True """ + from pydantic import BaseModel, Field from typing import Type from crewai.tools import BaseTool from crewai_tools import CodeInterpreterTool - from pydantic import BaseModel, Field class TestToolInput(BaseModel): """Input schema for TestTool.""" diff --git a/tests/knowledge/knowledge_test.py b/tests/knowledge/knowledge_test.py index ed3519c35..dc45787d3 100644 --- a/tests/knowledge/knowledge_test.py +++ b/tests/knowledge/knowledge_test.py @@ -1,10 +1,10 @@ """Test Knowledge creation and querying functionality.""" +import pytest from pathlib import Path from typing import List, Union from unittest.mock import patch -import pytest from crewai.knowledge.source.crew_docling_source import CrewDoclingSource from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSource from crewai.knowledge.source.excel_knowledge_source import ExcelKnowledgeSource diff --git a/tests/test_task_guardrails.py b/tests/test_task_guardrails.py index c788fd9dc..1bbabfade 100644 --- a/tests/test_task_guardrails.py +++ b/tests/test_task_guardrails.py @@ -1,11 +1,9 @@ """Tests for task guardrails functionality.""" -from unittest.mock import Mock - import pytest from crewai.task import Task from crewai.tasks.task_output import TaskOutput - +from unittest.mock import Mock def test_task_without_guardrail(): """Test that tasks work normally without guardrails (backward compatibility)."""