mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-14 02:28:30 +00:00
Fix CI issues: type-checker, lint errors (S101, RET504, B904)
- Add type ignore for create_model call to fix type-checker error - Fix exception chaining (B904) by using 'from e' syntax - Fix unnecessary assignment (RET504) by returning directly - Add noqa comments for S101 assert detection in test file Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -164,7 +164,7 @@ class CrewStructuredTool:
|
||||
|
||||
# Create model
|
||||
schema_name = f"{name.title()}Schema"
|
||||
return create_model(schema_name, **fields)
|
||||
return create_model(schema_name, **fields) # type: ignore[call-overload]
|
||||
|
||||
def _validate_function_signature(self) -> None:
|
||||
"""Validate that the function signature matches the args schema."""
|
||||
@@ -207,13 +207,13 @@ class CrewStructuredTool:
|
||||
|
||||
raw_args = json.loads(raw_args)
|
||||
except json.JSONDecodeError as e:
|
||||
raise ValueError(f"Failed to parse arguments as JSON: {e}")
|
||||
raise ValueError(f"Failed to parse arguments as JSON: {e}") from e
|
||||
|
||||
try:
|
||||
validated_args = self.args_schema.model_validate(raw_args)
|
||||
return validated_args.model_dump()
|
||||
except Exception as e:
|
||||
raise ValueError(f"Arguments validation failed: {e}")
|
||||
raise ValueError(f"Arguments validation failed: {e}") from e
|
||||
|
||||
async def ainvoke(
|
||||
self,
|
||||
@@ -274,8 +274,7 @@ class CrewStructuredTool:
|
||||
self._increment_usage_count()
|
||||
|
||||
if inspect.iscoroutinefunction(self.func):
|
||||
result = asyncio.run(self.func(**parsed_args, **kwargs))
|
||||
return result
|
||||
return asyncio.run(self.func(**parsed_args, **kwargs))
|
||||
|
||||
try:
|
||||
result = self.func(**parsed_args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user