mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
fix: Refactor try-except loop to resolve PERF203 lint issue
Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from crewai.agents import parser
|
||||||
from crewai.agents.crew_agent_executor import (
|
from crewai.agents.crew_agent_executor import (
|
||||||
AgentAction,
|
AgentAction,
|
||||||
AgentFinish,
|
AgentFinish,
|
||||||
OutputParserException,
|
OutputParserException,
|
||||||
)
|
)
|
||||||
from crewai.agents import parser
|
|
||||||
|
|
||||||
|
|
||||||
def test_valid_action_parsing_special_characters():
|
def test_valid_action_parsing_special_characters():
|
||||||
@@ -345,12 +345,16 @@ def test_integration_valid_and_invalid():
|
|||||||
"""
|
"""
|
||||||
parts = text.strip().split("\n\n")
|
parts = text.strip().split("\n\n")
|
||||||
results = []
|
results = []
|
||||||
for part in parts:
|
|
||||||
|
def parse_part(part_text):
|
||||||
try:
|
try:
|
||||||
result = parser.parse(part.strip())
|
return parser.parse(part_text.strip())
|
||||||
results.append(result)
|
|
||||||
except OutputParserException as e:
|
except OutputParserException as e:
|
||||||
results.append(e)
|
return e
|
||||||
|
|
||||||
|
for part in parts:
|
||||||
|
result = parse_part(part)
|
||||||
|
results.append(result)
|
||||||
|
|
||||||
assert isinstance(results[0], AgentAction)
|
assert isinstance(results[0], AgentAction)
|
||||||
assert isinstance(results[1], AgentFinish)
|
assert isinstance(results[1], AgentFinish)
|
||||||
@@ -452,4 +456,3 @@ def test_format_registry():
|
|||||||
|
|
||||||
def test_backward_compatibility():
|
def test_backward_compatibility():
|
||||||
"""Test that all existing ReAct format tests still pass."""
|
"""Test that all existing ReAct format tests still pass."""
|
||||||
pass
|
|
||||||
|
|||||||
Reference in New Issue
Block a user