Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
sort imports with isort rules by ruff linter (#1730)
Bowen Liang0b0f2d30ab07
diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.ymlindex 7ced70df9..f9853cf7c 100644--- a/.github/workflows/linter.yml+++ b/.github/workflows/linter.yml@@ -13,4 +13,4 @@ jobs:pip install ruff- name: Run Ruff Linter- run: ruff check --exclude "templates","__init__.py"+ run: ruff checkdiff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex dfa210d60..291f3f871 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -1,9 +1,7 @@repos:- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.4.4+ rev: v0.8.2hooks:- id: ruffargs: ["--fix"]- exclude: "templates"- id: ruff-format- exclude: "templates"diff --git a/.ruff.toml b/.ruff.tomlnew file mode 100644index 000000000..acc241bd4--- /dev/null+++ b/.ruff.toml@@ -0,0 +1,9 @@+exclude = [+ "templates",+ "__init__.py",+]++[lint]+select = [+ "I", # isort rules+]diff --git a/pyproject.toml b/pyproject.tomlindex f90110e85..5885d5c8e 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -54,7 +54,7 @@ mem0 = ["mem0ai>=0.1.29"][tool.uv]dev-dependencies = [- "ruff>=0.4.10",+ "ruff>=0.8.2","mypy>=1.10.0","pre-commit>=3.6.0","mkdocs>=1.4.3",diff --git a/src/crewai/agents/parser.py b/src/crewai/agents/parser.pyindex 2286900c1..b4629a8d2 100644--- a/src/crewai/agents/parser.py+++ b/src/crewai/agents/parser.py@@ -1,5 +1,6 @@import refrom typing import Any, Union+from json_repair import repair_jsonfrom crewai.utilities import I18Ndiff --git a/src/crewai/cli/authentication/main.py b/src/crewai/cli/authentication/main.pyindex c64045801..5a335e1f2 100644--- a/src/crewai/cli/authentication/main.py+++ b/src/crewai/cli/authentication/main.py@@ -5,9 +5,10 @@ from typing import Any, Dictimport requestsfrom rich.console import Console+from crewai.cli.tools.main import ToolCommand+from .constants import AUTH0_AUDIENCE, AUTH0_CLIENT_ID, AUTH0_DOMAINfrom .utils import TokenManager, validate_token-from crewai.cli.tools.main import ToolCommandconsole = Console()@@ -79,7 +80,9 @@ class AuthenticationCommand:style="yellow",)- console.print("\n[bold green]Welcome to CrewAI Enterprise![/bold green]\n")+ console.print(+ "\n[bold green]Welcome to CrewAI Enterprise![/bold green]\n"+ )returnif token_data["error"] not in ("authorization_pending", "slow_down"):diff --git a/src/crewai/cli/authentication/token.py b/src/crewai/cli/authentication/token.pyindex 889fdc2eb..30a33b4ba 100644--- a/src/crewai/cli/authentication/token.py+++ b/src/crewai/cli/authentication/token.py@@ -1,10 +1,9 @@from .utils import TokenManager+def get_auth_token() -> str:"""Get the authentication token."""access_token = TokenManager().get_token()if not access_token:raise Exception()return access_token--diff --git a/src/crewai/cli/command.py b/src/crewai/cli/command.pyindex f2af92bf5..2bef8985d 100644--- a/src/crewai/cli/command.py+++ b/src/crewai/cli/command.py@@ -1,8 +1,9 @@import requestsfrom requests.exceptions import JSONDecodeErrorfrom rich.console import Console-from crewai.cli.plus_api import PlusAPI+from crewai.cli.authentication.token import get_auth_token+from crewai.cli.plus_api import PlusAPIfrom crewai.telemetry.telemetry import Telemetryconsole = Console()diff --git a/src/crewai/cli/config.py b/src/crewai/cli/config.pyindex 000f1e6d0..8e30767ca 100644--- a/src/crewai/cli/config.py+++ b/src/crewai/cli/config.py@@ -1,13 +1,19 @@import jsonfrom pathlib import Path-from pydantic import BaseModel, Fieldfrom typing import Optional+from pydantic import BaseModel, Field+DEFAULT_CONFIG_PATH = Path.home() / ".config" / "crewai" / "settings.json"+class Settings(BaseModel):- tool_repository_username: Optional[str] = Field(None, description="Username for interacting with the Tool Repository")- tool_repository_password: Optional[str] = Field(None, description="Password for interacting with the Tool Repository")+ tool_repository_username: Optional[str] = Field(+ None, description="Username for interacting with the Tool Repository"+ )+ tool_repository_password: Optional[str] = Field(+ None, description="Password for interacting with the Tool Repository"+ )config_path: Path = Field(default=DEFAULT_CONFIG_PATH, exclude=True)def __init__(self, config_path: Path = DEFAULT_CONFIG_PATH, **data):diff --git a/src/crewai/cli/plus_api.py b/src/crewai/cli/plus_api.pyindex 2fce0d6d8..23032ca8f 100644--- a/src/crewai/cli/plus_api.py+++ b/src/crewai/cli/plus_api.py@@ -1,8 +1,10 @@+from os import getenvfrom typing import Optional+from urllib.parse import urljoin+import requests-from os import getenv+from crewai.cli.version import get_crewai_version-from urllib.parse import urljoinclass PlusAPI:diff --git a/src/crewai/cli/reset_memories_command.py b/src/crewai/cli/reset_memories_command.pyindex 31624cfc3..554232f52 100644--- a/src/crewai/cli/reset_memories_command.py+++ b/src/crewai/cli/reset_memories_command.py@@ -1,11 +1,12 @@import subprocess+import click+from crewai.knowledge.storage.knowledge_storage import KnowledgeStoragefrom crewai.memory.entity.entity_memory import EntityMemoryfrom crewai.memory.long_term.long_term_memory import LongTermMemoryfrom crewai.memory.short_term.short_term_memory import ShortTermMemoryfrom crewai.utilities.task_output_storage_handler import TaskOutputStorageHandler-from crewai.knowledge.storage.knowledge_storage import KnowledgeStoragedef reset_memories_command(diff --git a/src/crewai/cli/version.py b/src/crewai/cli/version.pyindex 543be9c32..a7c1087a7 100644--- a/src/crewai/cli/version.py+++ b/src/crewai/cli/version.py@@ -1,6 +1,6 @@import importlib.metadata+def get_crewai_version() -> str:"""Get the version number of CrewAI running the CLI"""return importlib.metadata.version("crewai")-diff --git a/src/crewai/knowledge/storage/base_knowledge_storage.py b/src/crewai/knowledge/storage/base_knowledge_storage.pyindex 78d370e04..d4887e85b 100644--- a/src/crewai/knowledge/storage/base_knowledge_storage.py+++ b/src/crewai/knowledge/storage/base_knowledge_storage.py@@ -1,5 +1,5 @@from abc import ABC, abstractmethod-from typing import Dict, Any, List, Optional+from typing import Any, Dict, List, Optionalclass BaseKnowledgeStorage(ABC):diff --git a/src/crewai/knowledge/storage/knowledge_storage.py b/src/crewai/knowledge/storage/knowledge_storage.pyindex acbbe75a1..7f79877ed 100644--- a/src/crewai/knowledge/storage/knowledge_storage.py+++ b/src/crewai/knowledge/storage/knowledge_storage.py@@ -14,9 +14,9 @@ from chromadb.config import Settingsfrom crewai.knowledge.storage.base_knowledge_storage import BaseKnowledgeStoragefrom crewai.utilities import EmbeddingConfigurator+from crewai.utilities.constants import KNOWLEDGE_DIRECTORYfrom crewai.utilities.logger import Loggerfrom crewai.utilities.paths import db_storage_path-from crewai.utilities.constants import KNOWLEDGE_DIRECTORY@contextlib.contextmanagerdiff --git a/src/crewai/memory/contextual/contextual_memory.py b/src/crewai/memory/contextual/contextual_memory.pyindex 9598fe6ee..cdb9cf836 100644--- a/src/crewai/memory/contextual/contextual_memory.py+++ b/src/crewai/memory/contextual/contextual_memory.py@@ -1,4 +1,4 @@-from typing import Optional, Dict, Any+from typing import Any, Dict, Optionalfrom crewai.memory import EntityMemory, LongTermMemory, ShortTermMemory, UserMemorydiff --git a/src/crewai/memory/memory.py b/src/crewai/memory/memory.pyindex 4869f8e6b..46af2c04d 100644--- a/src/crewai/memory/memory.py+++ b/src/crewai/memory/memory.py@@ -1,4 +1,4 @@-from typing import Any, Dict, Optional, List+from typing import Any, Dict, List, Optionalfrom crewai.memory.storage.rag_storage import RAGStoragediff --git a/src/crewai/memory/short_term/short_term_memory.py b/src/crewai/memory/short_term/short_term_memory.pyindex 4ade7eb93..4e5fbbb77 100644--- a/src/crewai/memory/short_term/short_term_memory.py+++ b/src/crewai/memory/short_term/short_term_memory.py@@ -1,4 +1,5 @@from typing import Any, Dict, Optional+from crewai.memory.memory import Memoryfrom crewai.memory.short_term.short_term_memory_item import ShortTermMemoryItemfrom crewai.memory.storage.rag_storage import RAGStorage@@ -32,7 +33,10 @@ class ShortTermMemory(Memory):storageif storageelse RAGStorage(- type="short_term", embedder_config=embedder_config, crew=crew, path=path+ type="short_term",+ embedder_config=embedder_config,+ crew=crew,+ path=path,))super().__init__(storage)diff --git a/src/crewai/memory/storage/mem0_storage.py b/src/crewai/memory/storage/mem0_storage.pyindex 34aab9716..e4e84fab4 100644--- a/src/crewai/memory/storage/mem0_storage.py+++ b/src/crewai/memory/storage/mem0_storage.py@@ -2,6 +2,7 @@ import osfrom typing import Any, Dict, Listfrom mem0 import MemoryClient+from crewai.memory.storage.interface import Storagediff --git a/src/crewai/project/utils.py b/src/crewai/project/utils.pyindex 2e95c755d..e8876d941 100644--- a/src/crewai/project/utils.py+++ b/src/crewai/project/utils.py@@ -1,5 +1,6 @@from functools import wraps+def memoize(func):cache = {}diff --git a/src/crewai/task.py b/src/crewai/task.pyindex cedb73c09..b585e0c69 100644--- a/src/crewai/task.py+++ b/src/crewai/task.py@@ -1,11 +1,11 @@import datetimeimport json-from pathlib import Pathimport threadingimport uuidfrom concurrent.futures import Futurefrom copy import copyfrom hashlib import md5+from pathlib import Pathfrom typing import Any, Dict, List, Optional, Set, Tuple, Type, Unionfrom opentelemetry.trace import Spandiff --git a/src/crewai/telemetry/telemetry.py b/src/crewai/telemetry/telemetry.pyindex e191f8d4d..aa0f8b9ff 100644--- a/src/crewai/telemetry/telemetry.py+++ b/src/crewai/telemetry/telemetry.py@@ -21,7 +21,9 @@ with suppress_warnings():from opentelemetry import trace # noqa: E402-from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter # noqa: E402+from opentelemetry.exporter.otlp.proto.http.trace_exporter import (+ OTLPSpanExporter, # noqa: E402+)from opentelemetry.sdk.resources import SERVICE_NAME, Resource # noqa: E402from opentelemetry.sdk.trace import TracerProvider # noqa: E402from opentelemetry.sdk.trace.export import BatchSpanProcessor # noqa: E402diff --git a/src/crewai/tools/agent_tools/agent_tools.py b/src/crewai/tools/agent_tools/agent_tools.pyindex 1db55a29b..08383c244 100644--- a/src/crewai/tools/agent_tools/agent_tools.py+++ b/src/crewai/tools/agent_tools/agent_tools.py@@ -1,9 +1,9 @@-from crewai.tools.base_tool import BaseToolfrom crewai.agents.agent_builder.base_agent import BaseAgent+from crewai.tools.base_tool import BaseToolfrom crewai.utilities import I18N-from .delegate_work_tool import DelegateWorkToolfrom .ask_question_tool import AskQuestionTool+from .delegate_work_tool import DelegateWorkToolclass AgentTools:diff --git a/src/crewai/tools/agent_tools/ask_question_tool.py b/src/crewai/tools/agent_tools/ask_question_tool.pyindex af739b8fc..9294770e5 100644--- a/src/crewai/tools/agent_tools/ask_question_tool.py+++ b/src/crewai/tools/agent_tools/ask_question_tool.py@@ -1,7 +1,9 @@-from crewai.tools.agent_tools.base_agent_tools import BaseAgentToolfrom typing import Optional+from pydantic import BaseModel, Field+from crewai.tools.agent_tools.base_agent_tools import BaseAgentTool+class AskQuestionToolSchema(BaseModel):question: str = Field(..., description="The question to ask")diff --git a/src/crewai/tools/agent_tools/base_agent_tools.py b/src/crewai/tools/agent_tools/base_agent_tools.pyindex 4311be6a3..ea63dd51e 100644--- a/src/crewai/tools/agent_tools/base_agent_tools.py+++ b/src/crewai/tools/agent_tools/base_agent_tools.py@@ -1,9 +1,10 @@from typing import Optional, Union+from pydantic import Field-from crewai.tools.base_tool import BaseToolfrom crewai.agents.agent_builder.base_agent import BaseAgentfrom crewai.task import Task+from crewai.tools.base_tool import BaseToolfrom crewai.utilities import I18Ndiff --git a/src/crewai/tools/agent_tools/delegate_work_tool.py b/src/crewai/tools/agent_tools/delegate_work_tool.pyindex 7f2007597..9dbf6c920 100644--- a/src/crewai/tools/agent_tools/delegate_work_tool.py+++ b/src/crewai/tools/agent_tools/delegate_work_tool.py@@ -1,8 +1,9 @@-from crewai.tools.agent_tools.base_agent_tools import BaseAgentToolfrom typing import Optionalfrom pydantic import BaseModel, Field+from crewai.tools.agent_tools.base_agent_tools import BaseAgentTool+class DelegateWorkToolSchema(BaseModel):task: str = Field(..., description="The task to delegate")diff --git a/src/crewai/tools/tool_usage_events.py b/src/crewai/tools/tool_usage_events.pyindex fea9d3f3c..3c1d16113 100644--- a/src/crewai/tools/tool_usage_events.py+++ b/src/crewai/tools/tool_usage_events.py@@ -1,6 +1,7 @@+from datetime import datetimefrom typing import Any, Dict+from pydantic import BaseModel-from datetime import datetimeclass ToolUsageEvent(BaseModel):diff --git a/src/crewai/utilities/crew_json_encoder.py b/src/crewai/utilities/crew_json_encoder.pyindex c3f95fcf6..70c1e9274 100644--- a/src/crewai/utilities/crew_json_encoder.py+++ b/src/crewai/utilities/crew_json_encoder.py@@ -1,8 +1,9 @@-from datetime import datetime, dateimport json+from datetime import date, datetime+from decimal import Decimalfrom uuid import UUID+from pydantic import BaseModel-from decimal import Decimalclass CrewJSONEncoder(json.JSONEncoder):diff --git a/src/crewai/utilities/crew_pydantic_output_parser.py b/src/crewai/utilities/crew_pydantic_output_parser.pyindex 5c5fa0d94..c269f3189 100644--- a/src/crewai/utilities/crew_pydantic_output_parser.py+++ b/src/crewai/utilities/crew_pydantic_output_parser.py@@ -1,10 +1,11 @@import json-import regexfrom typing import Any, Type-from crewai.agents.parser import OutputParserException+import regexfrom pydantic import BaseModel, ValidationError+from crewai.agents.parser import OutputParserException+class CrewPydanticOutputParser:"""Parses the text into pydantic models"""diff --git a/src/crewai/utilities/embedding_configurator.py b/src/crewai/utilities/embedding_configurator.pyindex f0f77ffca..44e832ec2 100644--- a/src/crewai/utilities/embedding_configurator.py+++ b/src/crewai/utilities/embedding_configurator.py@@ -1,6 +1,7 @@import osfrom typing import Any, Dict, cast-from chromadb import EmbeddingFunction, Documents, Embeddings++from chromadb import Documents, EmbeddingFunction, Embeddingsfrom chromadb.api.types import validate_embedding_functiondiff --git a/src/crewai/utilities/evaluators/crew_evaluator_handler.py b/src/crewai/utilities/evaluators/crew_evaluator_handler.pyindex e251f76f2..3387d91b3 100644--- a/src/crewai/utilities/evaluators/crew_evaluator_handler.py+++ b/src/crewai/utilities/evaluators/crew_evaluator_handler.py@@ -1,14 +1,15 @@from collections import defaultdict-from crewai.agent import Agent-from crewai.task import Task-from crewai.tasks.task_output import TaskOutput-from crewai.telemetry import Telemetryfrom pydantic import BaseModel, Fieldfrom rich.box import HEAVY_EDGEfrom rich.console import Consolefrom rich.table import Table+from crewai.agent import Agent+from crewai.task import Task+from crewai.tasks.task_output import TaskOutput+from crewai.telemetry import Telemetry+class TaskEvaluationPydanticOutput(BaseModel):quality: float = Field(diff --git a/src/crewai/utilities/events.py b/src/crewai/utilities/events.pyindex 75425fca2..11175e0d2 100644--- a/src/crewai/utilities/events.py+++ b/src/crewai/utilities/events.py@@ -1,7 +1,7 @@-from typing import Any, Callable, Generic, List, Dict, Type, TypeVarfrom functools import wraps-from pydantic import BaseModel+from typing import Any, Callable, Dict, Generic, List, Type, TypeVar+from pydantic import BaseModelT = TypeVar("T")EVT = TypeVar("EVT", bound=BaseModel)diff --git a/src/crewai/utilities/planning_handler.py b/src/crewai/utilities/planning_handler.pyindex 14a9a50a6..590f42389 100644--- a/src/crewai/utilities/planning_handler.py+++ b/src/crewai/utilities/planning_handler.py@@ -1,4 +1,5 @@from typing import Any, List, Optional+from pydantic import BaseModel, Fieldfrom crewai.agent import Agentdiff --git a/src/crewai/utilities/prompts.py b/src/crewai/utilities/prompts.pyindex cecd6cb71..66909644f 100644--- a/src/crewai/utilities/prompts.py+++ b/src/crewai/utilities/prompts.py@@ -1,5 +1,7 @@-from pydantic import BaseModel, Fieldfrom typing import Any, Optional++from pydantic import BaseModel, Field+from crewai.utilities import I18Ndiff --git a/src/crewai/utilities/pydantic_schema_parser.py b/src/crewai/utilities/pydantic_schema_parser.pyindex 073280dd2..f4c8c720f 100644--- a/src/crewai/utilities/pydantic_schema_parser.py+++ b/src/crewai/utilities/pydantic_schema_parser.py@@ -1,4 +1,4 @@-from typing import Type, get_args, get_origin, Union+from typing import Type, Union, get_args, get_originfrom pydantic import BaseModeldiff --git a/src/crewai/utilities/task_output_storage_handler.py b/src/crewai/utilities/task_output_storage_handler.pyindex 9970f64b4..34cdaccbb 100644--- a/src/crewai/utilities/task_output_storage_handler.py+++ b/src/crewai/utilities/task_output_storage_handler.py@@ -1,6 +1,8 @@-from pydantic import BaseModel, Fieldfrom datetime import datetime-from typing import Dict, Any, Optional, List+from typing import Any, Dict, List, Optional++from pydantic import BaseModel, Field+from crewai.memory.storage.kickoff_task_outputs_storage import (KickoffTaskOutputsSQLiteStorage,)diff --git a/src/crewai/utilities/token_counter_callback.py b/src/crewai/utilities/token_counter_callback.pyindex feaaa4c22..06ad15022 100644--- a/src/crewai/utilities/token_counter_callback.py+++ b/src/crewai/utilities/token_counter_callback.py@@ -1,5 +1,6 @@from litellm.integrations.custom_logger import CustomLoggerfrom litellm.types.utils import Usage+from crewai.agents.agent_builder.utilities.base_token_process import TokenProcess@@ -11,7 +12,7 @@ class TokenCalcHandler(CustomLogger):if self.token_cost_process is None:return- usage : Usage = response_obj["usage"]+ usage: Usage = response_obj["usage"]self.token_cost_process.sum_successful_requests(1)self.token_cost_process.sum_prompt_tokens(usage.prompt_tokens)self.token_cost_process.sum_completion_tokens(usage.completion_tokens)diff --git a/tests/agents/agent_builder/base_agent_test.py b/tests/agents/agent_builder/base_agent_test.pyindex fcd5d58b6..7c0c2f472 100644--- a/tests/agents/agent_builder/base_agent_test.py+++ b/tests/agents/agent_builder/base_agent_test.py@@ -1,9 +1,10 @@import hashlibfrom typing import Any, List, Optional+from pydantic import BaseModel+from crewai.agents.agent_builder.base_agent import BaseAgentfrom crewai.tools.base_tool import BaseTool-from pydantic import BaseModelclass TestAgent(BaseAgent):diff --git a/tests/agents/test_crew_agent_parser.py b/tests/agents/test_crew_agent_parser.pyindex 6496f7193..4b48e1552 100644--- a/tests/agents/test_crew_agent_parser.py+++ b/tests/agents/test_crew_agent_parser.py@@ -1,10 +1,11 @@import pytest-from crewai.agents.parser import CrewAgentParser+from crewai.agents.crew_agent_executor import (AgentAction,AgentFinish,OutputParserException,)+from crewai.agents.parser import CrewAgentParser@pytest.fixturediff --git a/tests/cli/authentication/test_auth_main.py b/tests/cli/authentication/test_auth_main.pyindex 4466cc999..a0b4fa0d9 100644--- a/tests/cli/authentication/test_auth_main.py+++ b/tests/cli/authentication/test_auth_main.py@@ -2,6 +2,7 @@ import unittestfrom unittest.mock import MagicMock, patchimport requests+from crewai.cli.authentication.main import AuthenticationCommand@@ -47,7 +48,9 @@ class TestAuthenticationCommand(unittest.TestCase):@patch("crewai.cli.authentication.main.requests.post")@patch("crewai.cli.authentication.main.validate_token")@patch("crewai.cli.authentication.main.console.print")- def test_poll_for_token_success(self, mock_print, mock_validate_token, mock_post, mock_tool):+ def test_poll_for_token_success(+ self, mock_print, mock_validate_token, mock_post, mock_tool+ ):mock_response = MagicMock()mock_response.status_code = 200mock_response.json.return_value = {@@ -62,7 +65,9 @@ class TestAuthenticationCommand(unittest.TestCase):self.auth_command._poll_for_token({"device_code": "123456"})mock_validate_token.assert_called_once_with("TOKEN")- mock_print.assert_called_once_with("\n[bold green]Welcome to CrewAI Enterprise![/bold green]\n")+ mock_print.assert_called_once_with(+ "\n[bold green]Welcome to CrewAI Enterprise![/bold green]\n"+ )@patch("crewai.cli.authentication.main.requests.post")@patch("crewai.cli.authentication.main.console.print")diff --git a/tests/cli/authentication/test_utils.py b/tests/cli/authentication/test_utils.pyindex d634780a8..6da48dcd0 100644--- a/tests/cli/authentication/test_utils.py+++ b/tests/cli/authentication/test_utils.py@@ -3,9 +3,10 @@ import unittestfrom datetime import datetime, timedeltafrom unittest.mock import MagicMock, patch-from crewai.cli.authentication.utils import TokenManager, validate_tokenfrom cryptography.fernet import Fernet+from crewai.cli.authentication.utils import TokenManager, validate_token+class TestValidateToken(unittest.TestCase):@patch("crewai.cli.authentication.utils.AsymmetricSignatureVerifier")diff --git a/tests/cli/config_test.py b/tests/cli/config_test.pyindex 1065d4730..95a38c06b 100644--- a/tests/cli/config_test.py+++ b/tests/cli/config_test.py@@ -1,10 +1,12 @@-import unittestimport json-import tempfileimport shutil+import tempfile+import unittestfrom pathlib import Path+from crewai.cli.config import Settings+class TestSettings(unittest.TestCase):def setUp(self):self.test_dir = Path(tempfile.mkdtemp())@@ -20,8 +22,7 @@ class TestSettings(unittest.TestCase):def test_initialization_with_data(self):settings = Settings(- config_path=self.config_path,- tool_repository_username="user1"+ config_path=self.config_path, tool_repository_username="user1")self.assertEqual(settings.tool_repository_username, "user1")self.assertIsNone(settings.tool_repository_password)@@ -37,22 +38,23 @@ class TestSettings(unittest.TestCase):def test_merge_file_and_input_data(self):self.config_path.parent.mkdir(parents=True, exist_ok=True)with self.config_path.open("w") as f:- json.dump({- "tool_repository_username": "file_user",- "tool_repository_password": "file_pass"- }, f)+ json.dump(+ {+ "tool_repository_username": "file_user",+ "tool_repository_password": "file_pass",+ },+ f,+ )settings = Settings(- config_path=self.config_path,- tool_repository_username="new_user"+ config_path=self.config_path, tool_repository_username="new_user")self.assertEqual(settings.tool_repository_username, "new_user")self.assertEqual(settings.tool_repository_password, "file_pass")def test_dump_new_settings(self):settings = Settings(- config_path=self.config_path,- tool_repository_username="user1"+ config_path=self.config_path, tool_repository_username="user1")settings.dump()@@ -67,8 +69,7 @@ class TestSettings(unittest.TestCase):json.dump({"existing_setting": "value"}, f)settings = Settings(- config_path=self.config_path,- tool_repository_username="user1"+ config_path=self.config_path, tool_repository_username="user1")settings.dump()@@ -79,10 +80,7 @@ class TestSettings(unittest.TestCase):self.assertEqual(saved_data["tool_repository_username"], "user1")def test_none_values(self):- settings = Settings(- config_path=self.config_path,- tool_repository_username=None- )+ settings = Settings(config_path=self.config_path, tool_repository_username=None)settings.dump()with self.config_path.open("r") as f:diff --git a/tests/cli/test_git.py b/tests/cli/test_git.pyindex 1fb1296cd..ccf8f0539 100644--- a/tests/cli/test_git.py+++ b/tests/cli/test_git.py@@ -1,6 +1,7 @@-from crewai.cli.git import Repositoryimport pytest+from crewai.cli.git import Repository+@pytest.fixture()def repository(fp):diff --git a/tests/cli/test_plus_api.py b/tests/cli/test_plus_api.pyindex e0acf22e3..daefeee42 100644--- a/tests/cli/test_plus_api.py+++ b/tests/cli/test_plus_api.py@@ -1,6 +1,7 @@import osimport unittestfrom unittest.mock import MagicMock, patch+from crewai.cli.plus_api import PlusAPIdiff --git a/tests/cli/test_utils.py b/tests/cli/test_utils.pyindex 616fb3d2f..0270b12fc 100644--- a/tests/cli/test_utils.py+++ b/tests/cli/test_utils.py@@ -1,7 +1,9 @@-import pytest+import osimport shutilimport tempfile-import os++import pytest+from crewai.cli import utilsdiff --git a/tests/flow_test.py b/tests/flow_test.pyindex ffd82367c..2e2020361 100644--- a/tests/flow_test.py+++ b/tests/flow_test.py@@ -3,6 +3,7 @@import asyncioimport pytest+from crewai.flow.flow import Flow, and_, listen, or_, router, startdiff --git a/tests/knowledge/knowledge_test.py b/tests/knowledge/knowledge_test.pyindex 4f506ff16..201ddea12 100644--- a/tests/knowledge/knowledge_test.py+++ b/tests/knowledge/knowledge_test.py@@ -3,6 +3,8 @@from pathlib import Pathfrom unittest.mock import patch+import pytest+from crewai.knowledge.source.csv_knowledge_source import CSVKnowledgeSourcefrom crewai.knowledge.source.excel_knowledge_source import ExcelKnowledgeSourcefrom crewai.knowledge.source.json_knowledge_source import JSONKnowledgeSource@@ -10,8 +12,6 @@ from crewai.knowledge.source.pdf_knowledge_source import PDFKnowledgeSourcefrom crewai.knowledge.source.string_knowledge_source import StringKnowledgeSourcefrom crewai.knowledge.source.text_file_knowledge_source import TextFileKnowledgeSource-import pytest-@pytest.fixture(autouse=True)def mock_vector_db():diff --git a/tests/memory/short_term_memory_test.py b/tests/memory/short_term_memory_test.pyindex c09b22691..6cde2a044 100644--- a/tests/memory/short_term_memory_test.py+++ b/tests/memory/short_term_memory_test.py@@ -1,5 +1,7 @@-import pytestfrom unittest.mock import patch++import pytest+from crewai.agent import Agentfrom crewai.crew import Crewfrom crewai.memory.short_term.short_term_memory import ShortTermMemorydiff --git a/tests/task_test.py b/tests/task_test.pyindex 3b3de0bed..b38b95996 100644--- a/tests/task_test.py+++ b/tests/task_test.py@@ -6,12 +6,13 @@ import osfrom unittest.mock import MagicMock, patchimport pytest+from pydantic import BaseModel+from pydantic_core import ValidationError+from crewai import Agent, Crew, Process, Taskfrom crewai.tasks.conditional_task import ConditionalTaskfrom crewai.tasks.task_output import TaskOutputfrom crewai.utilities.converter import Converter-from pydantic import BaseModel-from pydantic_core import ValidationErrordef test_task_tool_reflect_agent_tools():diff --git a/tests/tools/test_tool_usage.py b/tests/tools/test_tool_usage.pyindex fbe93a628..05b9b23af 100644--- a/tests/tools/test_tool_usage.py+++ b/tests/tools/test_tool_usage.py@@ -6,8 +6,8 @@ import pytestfrom pydantic import BaseModel, Fieldfrom crewai import Agent, Task-from crewai.tools.tool_usage import ToolUsagefrom crewai.tools import BaseTool+from crewai.tools.tool_usage import ToolUsageclass RandomNumberToolInput(BaseModel):diff --git a/tests/utilities/evaluators/test_crew_evaluator_handler.py b/tests/utilities/evaluators/test_crew_evaluator_handler.pyindex 6c92ffdbc..649c25998 100644--- a/tests/utilities/evaluators/test_crew_evaluator_handler.py+++ b/tests/utilities/evaluators/test_crew_evaluator_handler.py@@ -1,6 +1,7 @@from unittest import mockimport pytest+from crewai.agent import Agentfrom crewai.crew import Crewfrom crewai.task import Taskdiff --git a/uv.lock b/uv.lockindex 9fa1a274c..915111e8c 100644--- a/uv.lock+++ b/uv.lock@@ -692,7 +692,7 @@ dev = [{ name = "pytest-subprocess", specifier = ">=1.5.2" },{ name = "pytest-vcr", specifier = ">=1.0.2" },{ name = "python-dotenv", specifier = ">=1.0.0" },- { name = "ruff", specifier = ">=0.4.10" },+ { name = "ruff", specifier = ">=0.8.2" },][[package]]@@ -3876,27 +3876,27 @@ wheels = [[[package]]name = "ruff"-version = "0.7.0"-source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/2c/c7/f3367d1da5d568192968c5c9e7f3d51fb317b9ac04828493b23d8fce8ce6/ruff-0.7.0.tar.gz", hash = "sha256:47a86360cf62d9cd53ebfb0b5eb0e882193fc191c6d717e8bef4462bc3b9ea2b", size = 3146645 }-wheels = [- { url = "https://files.pythonhosted.org/packages/48/59/a0275a0913f3539498d116046dd679cd657fe3b7caf5afe1733319414932/ruff-0.7.0-py3-none-linux_armv6l.whl", hash = "sha256:0cdf20c2b6ff98e37df47b2b0bd3a34aaa155f59a11182c1303cce79be715628", size = 10434007 },- { url = "https://files.pythonhosted.org/packages/cd/94/da0ba5f956d04c90dd899209904210600009dcda039ce840d83eb4298c7d/ruff-0.7.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:496494d350c7fdeb36ca4ef1c9f21d80d182423718782222c29b3e72b3512737", size = 10048066 },- { url = "https://files.pythonhosted.org/packages/57/1d/e5cc149ecc46e4f203403a79ccd170fad52d316f98b87d0f63b1945567db/ruff-0.7.0-py3-none-macosx_11_0_arm64.whl", hash = "sha256:214b88498684e20b6b2b8852c01d50f0651f3cc6118dfa113b4def9f14faaf06", size = 9711389 },- { url = "https://files.pythonhosted.org/packages/05/67/fb7ea2c869c539725a16c5bc294e9aa34f8b1b6fe702f1d173a5da517c2b/ruff-0.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:630fce3fefe9844e91ea5bbf7ceadab4f9981f42b704fae011bb8efcaf5d84be", size = 10755174 },- { url = "https://files.pythonhosted.org/packages/5f/f0/13703bc50536a0613ea3dce991116e5f0917a1f05528c6ab738b33c08d3f/ruff-0.7.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:211d877674e9373d4bb0f1c80f97a0201c61bcd1e9d045b6e9726adc42c156aa", size = 10196040 },- { url = "https://files.pythonhosted.org/packages/99/c1/77b04ab20324ab03d333522ee55fb0f1c38e3ca0d326b4905f82ce6b6c70/ruff-0.7.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:194d6c46c98c73949a106425ed40a576f52291c12bc21399eb8f13a0f7073495", size = 11033684 },- { url = "https://files.pythonhosted.org/packages/f2/97/f463334dc4efeea3551cd109163df15561c18a1c3ec13d51643740fd36ba/ruff-0.7.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:82c2579b82b9973a110fab281860403b397c08c403de92de19568f32f7178598", size = 11803700 },- { url = "https://files.pythonhosted.org/packages/b4/f8/a31d40c4bb92933d376a53e7c5d0245d9b27841357e4820e96d38f54b480/ruff-0.7.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9af971fe85dcd5eaed8f585ddbc6bdbe8c217fb8fcf510ea6bca5bdfff56040e", size = 11347848 },- { url = "https://files.pythonhosted.org/packages/83/62/0c133b35ddaf91c65c30a56718b80bdef36bfffc35684d29e3a4878e0ea3/ruff-0.7.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b641c7f16939b7d24b7bfc0be4102c56562a18281f84f635604e8a6989948914", size = 12480632 },- { url = "https://files.pythonhosted.org/packages/46/96/464058dd1d980014fb5aa0a1254e78799efb3096fc7a4823cd66a1621276/ruff-0.7.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d71672336e46b34e0c90a790afeac8a31954fd42872c1f6adaea1dff76fd44f9", size = 10941919 },- { url = "https://files.pythonhosted.org/packages/a0/f7/bda37ec77986a435dde44e1f59374aebf4282a5fa9cf17735315b847141f/ruff-0.7.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ab7d98c7eed355166f367597e513a6c82408df4181a937628dbec79abb2a1fe4", size = 10745519 },- { url = "https://files.pythonhosted.org/packages/c2/33/5f77fc317027c057b61a848020a47442a1cbf12e592df0e41e21f4d0f3bd/ruff-0.7.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1eb54986f770f49edb14f71d33312d79e00e629a57387382200b1ef12d6a4ef9", size = 10284872 },- { url = "https://files.pythonhosted.org/packages/ff/50/98aec292bc9537f640b8d031c55f3414bf15b6ed13b3e943fed75ac927b9/ruff-0.7.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:dc452ba6f2bb9cf8726a84aa877061a2462afe9ae0ea1d411c53d226661c601d", size = 10600334 },- { url = "https://files.pythonhosted.org/packages/f2/85/12607ae3201423a179b8cfadc7cb1e57d02cd0135e45bd0445acb4cef327/ruff-0.7.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:4b406c2dce5be9bad59f2de26139a86017a517e6bcd2688da515481c05a2cb11", size = 11017333 },- { url = "https://files.pythonhosted.org/packages/d4/7f/3b85a56879e705d5f46ec14daf8a439fca05c3081720fe3dc3209100922d/ruff-0.7.0-py3-none-win32.whl", hash = "sha256:f6c968509f767776f524a8430426539587d5ec5c662f6addb6aa25bc2e8195ec", size = 8570962 },- { url = "https://files.pythonhosted.org/packages/39/9f/c5ee2b40d377354dabcc23cff47eb299de4b4d06d345068f8f8cc1eadac8/ruff-0.7.0-py3-none-win_amd64.whl", hash = "sha256:ff4aabfbaaba880e85d394603b9e75d32b0693152e16fa659a3064a85df7fce2", size = 9365544 },- { url = "https://files.pythonhosted.org/packages/89/8b/ee1509f60148cecba644aa718f6633216784302458340311898aaf0b1bed/ruff-0.7.0-py3-none-win_arm64.whl", hash = "sha256:10842f69c245e78d6adec7e1db0a7d9ddc2fff0621d730e61657b64fa36f207e", size = 8695763 },+version = "0.8.2"+source = { registry = "https://pypi.org/simple" }+sdist = { url = "https://files.pythonhosted.org/packages/5e/2b/01245f4f3a727d60bebeacd7ee6d22586c7f62380a2597ddb22c2f45d018/ruff-0.8.2.tar.gz", hash = "sha256:b84f4f414dda8ac7f75075c1fa0b905ac0ff25361f42e6d5da681a465e0f78e5", size = 3349020 }+wheels = [+ { url = "https://files.pythonhosted.org/packages/91/29/366be70216dba1731a00a41f2f030822b0c96c7c4f3b2c0cdce15cbace74/ruff-0.8.2-py3-none-linux_armv6l.whl", hash = "sha256:c49ab4da37e7c457105aadfd2725e24305ff9bc908487a9bf8d548c6dad8bb3d", size = 10530649 },+ { url = "https://files.pythonhosted.org/packages/63/82/a733956540bb388f00df5a3e6a02467b16c0e529132625fe44ce4c5fb9c7/ruff-0.8.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:ec016beb69ac16be416c435828be702ee694c0d722505f9c1f35e1b9c0cc1bf5", size = 10274069 },+ { url = "https://files.pythonhosted.org/packages/3d/12/0b3aa14d1d71546c988a28e1b412981c1b80c8a1072e977a2f30c595cc4a/ruff-0.8.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:f05cdf8d050b30e2ba55c9b09330b51f9f97d36d4673213679b965d25a785f3c", size = 9909400 },+ { url = "https://files.pythonhosted.org/packages/23/08/f9f08cefb7921784c891c4151cce6ed357ff49e84b84978440cffbc87408/ruff-0.8.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:60f578c11feb1d3d257b2fb043ddb47501ab4816e7e221fbb0077f0d5d4e7b6f", size = 10766782 },+ { url = "https://files.pythonhosted.org/packages/e4/71/bf50c321ec179aa420c8ec40adac5ae9cc408d4d37283a485b19a2331ceb/ruff-0.8.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cbd5cf9b0ae8f30eebc7b360171bd50f59ab29d39f06a670b3e4501a36ba5897", size = 10286316 },+ { url = "https://files.pythonhosted.org/packages/f2/83/c82688a2a6117539aea0ce63fdf6c08e60fe0202779361223bcd7f40bd74/ruff-0.8.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b402ddee3d777683de60ff76da801fa7e5e8a71038f57ee53e903afbcefdaa58", size = 11338270 },+ { url = "https://files.pythonhosted.org/packages/7f/d7/bc6a45e5a22e627640388e703160afb1d77c572b1d0fda8b4349f334fc66/ruff-0.8.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:705832cd7d85605cb7858d8a13d75993c8f3ef1397b0831289109e953d833d29", size = 12058579 },+ { url = "https://files.pythonhosted.org/packages/da/3b/64150c93946ec851e6f1707ff586bb460ca671581380c919698d6a9267dc/ruff-0.8.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:32096b41aaf7a5cc095fa45b4167b890e4c8d3fd217603f3634c92a541de7248", size = 11615172 },+ { url = "https://files.pythonhosted.org/packages/e4/9e/cf12b697ea83cfe92ec4509ae414dc4c9b38179cc681a497031f0d0d9a8e/ruff-0.8.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e769083da9439508833cfc7c23e351e1809e67f47c50248250ce1ac52c21fb93", size = 12882398 },+ { url = "https://files.pythonhosted.org/packages/a9/27/96d10863accf76a9c97baceac30b0a52d917eb985a8ac058bd4636aeede0/ruff-0.8.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5fe716592ae8a376c2673fdfc1f5c0c193a6d0411f90a496863c99cd9e2ae25d", size = 11176094 },+ { url = "https://files.pythonhosted.org/packages/eb/10/cd2fd77d4a4e7f03c29351be0f53278a393186b540b99df68beb5304fddd/ruff-0.8.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:81c148825277e737493242b44c5388a300584d73d5774defa9245aaef55448b0", size = 10771884 },+ { url = "https://files.pythonhosted.org/packages/71/5d/beabb2ff18870fc4add05fa3a69a4cb1b1d2d6f83f3cf3ae5ab0d52f455d/ruff-0.8.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d261d7850c8367704874847d95febc698a950bf061c9475d4a8b7689adc4f7fa", size = 10382535 },+ { url = "https://files.pythonhosted.org/packages/ae/29/6b3fdf3ad3e35b28d87c25a9ff4c8222ad72485ab783936b2b267250d7a7/ruff-0.8.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1ca4e3a87496dc07d2427b7dd7ffa88a1e597c28dad65ae6433ecb9f2e4f022f", size = 10886995 },+ { url = "https://files.pythonhosted.org/packages/e9/dc/859d889b4d9356a1a2cdbc1e4a0dda94052bc5b5300098647e51a58c430b/ruff-0.8.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:729850feed82ef2440aa27946ab39c18cb4a8889c1128a6d589ffa028ddcfc22", size = 11220750 },+ { url = "https://files.pythonhosted.org/packages/0b/08/e8f519f61f1d624264bfd6b8829e4c5f31c3c61193bc3cff1f19dbe7626a/ruff-0.8.2-py3-none-win32.whl", hash = "sha256:ac42caaa0411d6a7d9594363294416e0e48fc1279e1b0e948391695db2b3d5b1", size = 8729396 },+ { url = "https://files.pythonhosted.org/packages/f8/d4/ba1c7ab72aba37a2b71fe48ab95b80546dbad7a7f35ea28cf66fc5cea5f6/ruff-0.8.2-py3-none-win_amd64.whl", hash = "sha256:2aae99ec70abf43372612a838d97bfe77d45146254568d94926e8ed5bbb409ea", size = 9594729 },+ { url = "https://files.pythonhosted.org/packages/23/34/db20e12d3db11b8a2a8874258f0f6d96a9a4d631659d54575840557164c8/ruff-0.8.2-py3-none-win_arm64.whl", hash = "sha256:fb88e2a506b70cfbc2de6fae6681c4f944f7dd5f2fe87233a7233d888bad73e8", size = 9035131 },][[package]]