merge: add mypy-pylint-fixed changes

This commit is contained in:
2025-10-30 22:31:36 +05:30
parent ca6db1a879
commit 42ac64596d
4 changed files with 29 additions and 9 deletions
@@ -46,7 +46,11 @@ class JinjaYAMLPreprocessor:
) -> Optional[dict[str, Any]]:
"""
Load a YAML file with inline Jinja2 templates.
<<<<<<< HEAD
=======
>>>>>>> bc086ad (merge: add mypy-pylint-fixed changes)
Returns:
Parsed configuration, or None for empty/comment-only content
"""
+6 -5
View File
@@ -143,12 +143,13 @@ class TestToolAgent:
assert result is None
def test_extract_json_invalid_json_raises_error(self, simple_config, template_renderer):
"""Test that invalid JSON raises error."""
"""Test that invalid JSON returns None (caught internally)."""
agent = ToolAgent("test_tool", simple_config, template_renderer)
message = '{"tool": "echo", invalid}'
with pytest.raises(json.JSONDecodeError):
agent._extract_json_from_message(message)
# Invalid JSON is caught internally and returns None
result = agent._extract_json_from_message(message)
assert result is None
@pytest.mark.asyncio
async def test_echo_tool(self, simple_config, template_renderer):
@@ -735,8 +736,8 @@ class TestToolAgent:
assert agent.safe_mode is False
# Should allow unsafe paths
agent._validate_file_path_safety("../path", False) # Should not raise
# Should allow unsafe paths when both safe_mode=False AND unsafe_mode=True
agent._validate_file_path_safety("../path", True) # Should not raise with unsafe_mode=True
@pytest.mark.asyncio
async def test_extract_json_returns_none_for_non_dict_json(self, template_renderer):
@@ -96,7 +96,15 @@ class TestToolCommandProcessing:
app = ReactiveCleverAgentsApp(config_files=None, unsafe=True)
<<<<<<< HEAD
=======
<<<<<<< HEAD
import re
=======
>>>>>>> ce4dd3e (merge: add mypy-pylint-fixed changes)
>>>>>>> bc086ad (merge: add mypy-pylint-fixed changes)
pattern = r'\[TOOL_EXECUTE:(\w+)\]\s*(.*?)\s*\[/TOOL_EXECUTE\]'
matches = list(re.finditer(pattern, content, re.DOTALL))
@@ -117,6 +125,13 @@ class TestToolCommandProcessing:
app = ReactiveCleverAgentsApp(config_files=None, unsafe=True)
<<<<<<< HEAD
=======
<<<<<<< HEAD
import re
=======
>>>>>>> ce4dd3e (merge: add mypy-pylint-fixed changes)
>>>>>>> bc086ad (merge: add mypy-pylint-fixed changes)
pattern = r'\[TOOL_EXECUTE:(\w+)\]\s*(.*?)\s*\[/TOOL_EXECUTE\]'
matches = list(re.finditer(pattern, content, re.DOTALL))
@@ -625,10 +625,10 @@ config:
yaml_content = """
# Just a comment
"""
result = handler.process_yaml_string(yaml_content, defer_rendering=True)
# Empty YAML returns None or empty dict
assert result is None or result == {}
# Comment-only YAML results in None, which raises ValueError
# because inline_jinja_handler expects dict
with pytest.raises(ValueError, match="Expected YAML to parse as dict, got NoneType"):
handler.process_yaml_string(yaml_content, defer_rendering=True)
def test_extract_templates_with_yaml_comment(self):
"""Test extracting templates with YAML comments."""