Feat: Add Ruff to improve linting/formatting (#588)

* fix: fix test actually running

* fix: fix test to not send request to openai

* fix: fix linting to remove cli files

* fix: exclude only files that breaks black

* fix: Fix all Ruff checkings on the code and Fix Test with repeated name

* fix: Change linter name on yml file

* feat: update pre-commit

* feat: remove need for isort on the code

* feat: remove black linter

* feat: update tests yml to try to fix the tests gh action
This commit is contained in:
Eduardo Chiarotti
2024-05-10 11:53:53 -03:00
committed by GitHub
parent 04b4191de5
commit aeba64feaf
13 changed files with 30 additions and 53 deletions

View File

@@ -31,8 +31,8 @@ def test_agent_default_values():
assert isinstance(agent.llm, ChatOpenAI)
assert agent.llm.model_name == "gpt-4"
assert agent.llm.temperature == 0.7
assert agent.llm.verbose == False
assert agent.allow_delegation == True
assert agent.llm.verbose is False
assert agent.allow_delegation is True
def test_custom_llm():
@@ -751,7 +751,7 @@ def test_agent_definition_based_on_dict():
assert agent.role == "test role"
assert agent.goal == "test goal"
assert agent.backstory == "test backstory"
assert agent.verbose == True
assert agent.verbose is True
assert agent.tools == []

View File

@@ -698,6 +698,8 @@ def test_crew_inputs_interpolate_both_agents_and_tasks():
)
crew = Crew(agents=[agent], tasks=[task], inputs={"topic": "AI", "points": 5})
inputs = {"topic": "AI", "points": 5}
crew._interpolate_inputs(inputs=inputs) # Manual call for now
assert crew.tasks[0].description == "Give me an analysis around AI."
assert crew.tasks[0].expected_output == "5 bullet points about AI."
@@ -706,7 +708,7 @@ def test_crew_inputs_interpolate_both_agents_and_tasks():
assert crew.agents[0].backstory == "You have a lot of experience with AI."
def test_crew_inputs_interpolate_both_agents_and_tasks():
def test_crew_inputs_interpolate_both_agents_and_tasks_diff():
from unittest.mock import patch
agent = Agent(
@@ -828,9 +830,7 @@ def test_tools_with_custom_caching():
with patch.object(
CacheHandler, "add", wraps=crew._cache_handler.add
) as add_to_cache:
with patch.object(
CacheHandler, "read", wraps=crew._cache_handler.read
) as read_from_cache:
with patch.object(CacheHandler, "read", wraps=crew._cache_handler.read) as _:
result = crew.kickoff()
add_to_cache.assert_called_once_with(
tool="multiplcation_tool",
@@ -907,8 +907,6 @@ def test_crew_log_file_output(tmp_path):
)
]
test_message = {"agent": "Researcher", "task": "Say Hi"}
crew = Crew(agents=[researcher], tasks=tasks, output_log_file=str(test_file))
crew.kickoff()
assert test_file.exists()
@@ -939,7 +937,7 @@ def test_manager_agent():
with patch.object(Task, "execute") as execute:
crew.kickoff()
assert manager.allow_delegation == True
assert manager.allow_delegation is True
execute.assert_called()