forked from HAL9000/cleveragents-core
fix: fix rest of the mypy --strict and pylint errors
This commit is contained in:
@@ -275,6 +275,10 @@ class CompositeAgent(Agent): # pylint: disable=too-many-instance-attributes
|
||||
else:
|
||||
graph = self.graphs[graph_name]
|
||||
|
||||
# Type guard to satisfy mypy --strict
|
||||
if graph is None:
|
||||
raise ExecutionError(f"Graph '{graph_name}' could not be loaded")
|
||||
|
||||
# Execute graph
|
||||
result = await graph.execute(
|
||||
{"messages": [{"role": "user", "content": message}], "metadata": context}
|
||||
|
||||
@@ -475,6 +475,9 @@ class ReactiveCleverAgentsApp: # pylint: disable=too-many-instance-attributes
|
||||
)
|
||||
else:
|
||||
# Use regular registration
|
||||
# Type guard to satisfy mypy --strict
|
||||
if self.template_registry is None:
|
||||
raise CleverAgentsException("Template registry not initialized")
|
||||
self.template_registry.register_all_templates(self.config.templates)
|
||||
|
||||
templates = self.config.templates or {}
|
||||
|
||||
@@ -8,7 +8,6 @@ from typing import TYPE_CHECKING
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
from typing import cast
|
||||
|
||||
from cleveragents.templates.base import BaseTemplate
|
||||
from cleveragents.templates.base import ComponentReference
|
||||
@@ -33,7 +32,7 @@ class GraphTemplate(BaseTemplate):
|
||||
filled_params = self.validate_params(params)
|
||||
|
||||
# Deep copy the definition
|
||||
graph_def = copy.deepcopy(self.definition)
|
||||
graph_def: Dict[str, Any] = copy.deepcopy(self.definition)
|
||||
|
||||
# Remove parameters section
|
||||
if "parameters" in graph_def:
|
||||
@@ -56,7 +55,7 @@ class GraphTemplate(BaseTemplate):
|
||||
if "name" not in graph_def:
|
||||
graph_def["name"] = self.name
|
||||
|
||||
return cast(Dict[str, Any], graph_def)
|
||||
return graph_def
|
||||
|
||||
def _process_nodes(
|
||||
self,
|
||||
|
||||
@@ -277,9 +277,11 @@ class InlineJinjaHandler:
|
||||
result = {k: v for k, v in config.items() if k != "__templates__"}
|
||||
|
||||
# Apply templates recursively
|
||||
result = self._apply_templates_recursive(result, templates, context)
|
||||
result_with_templates: Dict[str, Any] = self._apply_templates_recursive(
|
||||
result, templates, context
|
||||
)
|
||||
|
||||
return cast(Dict[str, Any], result)
|
||||
return result_with_templates
|
||||
|
||||
def _apply_templates_recursive( # pylint: disable=too-many-nested-blocks
|
||||
self, data: Any, templates: Dict[str, Any], context: Dict[str, Any]
|
||||
|
||||
@@ -8,7 +8,6 @@ from typing import TYPE_CHECKING
|
||||
from typing import Any
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
from typing import cast
|
||||
|
||||
from cleveragents.templates.base import BaseTemplate
|
||||
from cleveragents.templates.base import ComponentReference
|
||||
@@ -33,7 +32,7 @@ class StreamTemplate(BaseTemplate):
|
||||
filled_params = self.validate_params(params)
|
||||
|
||||
# Deep copy the definition
|
||||
stream_def = copy.deepcopy(self.definition)
|
||||
stream_def: Dict[str, Any] = copy.deepcopy(self.definition)
|
||||
|
||||
# Remove parameters section
|
||||
if "parameters" in stream_def:
|
||||
@@ -52,7 +51,7 @@ class StreamTemplate(BaseTemplate):
|
||||
if "name" not in stream_def:
|
||||
stream_def["name"] = self.name
|
||||
|
||||
return cast(Dict[str, Any], stream_def)
|
||||
return stream_def
|
||||
|
||||
def _process_operators( # pylint: disable=too-many-branches
|
||||
self, operators: List[Any], params: Dict[str, Any], context: InstantiationContext
|
||||
|
||||
Reference in New Issue
Block a user