mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-28 09:38:17 +00:00
Address code review suggestions for PR #2264
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Callable, Dict, TypeVar, cast
|
from typing import Any, Callable, Dict, List, TypeVar, cast
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@@ -29,11 +29,6 @@ def CrewBase(cls: T) -> T:
|
|||||||
)
|
)
|
||||||
original_tasks_config_path = getattr(cls, "tasks_config", "config/tasks.yaml")
|
original_tasks_config_path = getattr(cls, "tasks_config", "config/tasks.yaml")
|
||||||
|
|
||||||
# Initialize empty agents and tasks lists for linting purposes
|
|
||||||
# These will be populated by the @crew decorator when the crew method is called
|
|
||||||
_agents = []
|
|
||||||
_tasks = []
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# Initialize agents and tasks before anything else
|
# Initialize agents and tasks before anything else
|
||||||
self._agents = []
|
self._agents = []
|
||||||
@@ -260,7 +255,7 @@ def CrewBase(cls: T) -> T:
|
|||||||
]
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def agents(self):
|
def agents(self) -> List["Agent"]:
|
||||||
"""
|
"""
|
||||||
Returns the list of agents for this crew.
|
Returns the list of agents for this crew.
|
||||||
This property is populated by the @crew decorator when the crew method is called.
|
This property is populated by the @crew decorator when the crew method is called.
|
||||||
@@ -268,12 +263,14 @@ def CrewBase(cls: T) -> T:
|
|||||||
return self._agents
|
return self._agents
|
||||||
|
|
||||||
@agents.setter
|
@agents.setter
|
||||||
def agents(self, value):
|
def agents(self, value: List["Agent"]) -> None:
|
||||||
"""Sets the list of agents for this crew."""
|
"""Sets the list of agents for this crew."""
|
||||||
|
if not isinstance(value, list):
|
||||||
|
raise TypeError("Agents must be provided as a list")
|
||||||
self._agents = value
|
self._agents = value
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tasks(self):
|
def tasks(self) -> List["Task"]:
|
||||||
"""
|
"""
|
||||||
Returns the list of tasks for this crew.
|
Returns the list of tasks for this crew.
|
||||||
This property is populated by the @crew decorator when the crew method is called.
|
This property is populated by the @crew decorator when the crew method is called.
|
||||||
@@ -281,8 +278,10 @@ def CrewBase(cls: T) -> T:
|
|||||||
return self._tasks
|
return self._tasks
|
||||||
|
|
||||||
@tasks.setter
|
@tasks.setter
|
||||||
def tasks(self, value):
|
def tasks(self, value: List["Task"]) -> None:
|
||||||
"""Sets the list of tasks for this crew."""
|
"""Sets the list of tasks for this crew."""
|
||||||
|
if not isinstance(value, list):
|
||||||
|
raise TypeError("Tasks must be provided as a list")
|
||||||
self._tasks = value
|
self._tasks = value
|
||||||
|
|
||||||
# Include base class (qual)name in the wrapper class (qual)name.
|
# Include base class (qual)name in the wrapper class (qual)name.
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ class TestCrewBaseLinting:
|
|||||||
|
|
||||||
@agent
|
@agent
|
||||||
def agent_one(self) -> Agent:
|
def agent_one(self) -> Agent:
|
||||||
|
"""
|
||||||
|
Creates a test agent for validation purposes.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Agent: A configured test agent instance
|
||||||
|
"""
|
||||||
return Agent(
|
return Agent(
|
||||||
role="Test Agent",
|
role="Test Agent",
|
||||||
goal="Test Goal",
|
goal="Test Goal",
|
||||||
@@ -22,7 +28,12 @@ class TestCrewBaseLinting:
|
|||||||
|
|
||||||
@task
|
@task
|
||||||
def task_one(self) -> Task:
|
def task_one(self) -> Task:
|
||||||
# Create a task with an agent assigned to it
|
"""
|
||||||
|
Creates a test task with an agent assigned to it.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Task: A configured test task instance with an agent assigned
|
||||||
|
"""
|
||||||
return Task(
|
return Task(
|
||||||
description="Test Description",
|
description="Test Description",
|
||||||
expected_output="Test Output",
|
expected_output="Test Output",
|
||||||
@@ -31,7 +42,13 @@ class TestCrewBaseLinting:
|
|||||||
|
|
||||||
@crew
|
@crew
|
||||||
def crew(self) -> Crew:
|
def crew(self) -> Crew:
|
||||||
# Access self.agents and self.tasks to verify no linting errors
|
"""
|
||||||
|
Creates a test crew with agents and tasks.
|
||||||
|
This method accesses self.agents and self.tasks to verify no linting errors.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Crew: A configured test crew instance
|
||||||
|
"""
|
||||||
return Crew(
|
return Crew(
|
||||||
agents=self.agents, # Should not cause linting errors
|
agents=self.agents, # Should not cause linting errors
|
||||||
tasks=self.tasks, # Should not cause linting errors
|
tasks=self.tasks, # Should not cause linting errors
|
||||||
|
|||||||
Reference in New Issue
Block a user