From 42ac64596de336de2bf87e40289be447f75a657f Mon Sep 17 00:00:00 2001 From: Aditya Chhabra Date: Thu, 30 Oct 2025 22:31:36 +0530 Subject: [PATCH] merge: add mypy-pylint-fixed changes --- .../templates/jinja_yaml_preprocessor.py | 4 ++++ tests/unit/agents/test_tool.py | 11 ++++++----- tests/unit/core/test_tool_command_processing.py | 15 +++++++++++++++ tests/unit/templates/test_inline_jinja_handler.py | 8 ++++---- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/cleveragents/templates/jinja_yaml_preprocessor.py b/src/cleveragents/templates/jinja_yaml_preprocessor.py index ac16e904..0b6f5dfb 100644 --- a/src/cleveragents/templates/jinja_yaml_preprocessor.py +++ b/src/cleveragents/templates/jinja_yaml_preprocessor.py @@ -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 """ diff --git a/tests/unit/agents/test_tool.py b/tests/unit/agents/test_tool.py index 8729ce2f..fecc5ba5 100644 --- a/tests/unit/agents/test_tool.py +++ b/tests/unit/agents/test_tool.py @@ -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): diff --git a/tests/unit/core/test_tool_command_processing.py b/tests/unit/core/test_tool_command_processing.py index 758edce6..402ffa91 100644 --- a/tests/unit/core/test_tool_command_processing.py +++ b/tests/unit/core/test_tool_command_processing.py @@ -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)) diff --git a/tests/unit/templates/test_inline_jinja_handler.py b/tests/unit/templates/test_inline_jinja_handler.py index 8b167cbf..2b1bf495 100644 --- a/tests/unit/templates/test_inline_jinja_handler.py +++ b/tests/unit/templates/test_inline_jinja_handler.py @@ -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."""