VibecoderMcSwaggins commited on
Commit
f32a2ca
·
1 Parent(s): 5e7604a

fix: address CodeRabbit review feedback for Phase 13

Browse files

- Use .get() to prevent KeyError when execution dict lacks 'error' key
- Use context manager for file read to prevent resource leak in test

src/services/statistical_analyzer.py CHANGED
@@ -145,7 +145,9 @@ Generate executable Python code to analyze this evidence."""
145
  return AnalysisResult(
146
  verdict="INCONCLUSIVE",
147
  confidence=0.0,
148
- statistical_evidence=f"Execution failed: {execution['error']}",
 
 
149
  code_generated=generated_code,
150
  execution_output=execution.get("stderr", ""),
151
  key_findings=[],
 
145
  return AnalysisResult(
146
  verdict="INCONCLUSIVE",
147
  confidence=0.0,
148
+ statistical_evidence=(
149
+ f"Execution failed: {execution.get('error', 'Unknown error')}"
150
+ ),
151
  code_generated=generated_code,
152
  execution_output=execution.get("stderr", ""),
153
  key_findings=[],
tests/unit/services/test_statistical_analyzer.py CHANGED
@@ -38,7 +38,8 @@ class TestStatisticalAnalyzer:
38
  import src.services.statistical_analyzer as module
39
 
40
  # Check module doesn't import agent_framework
41
- source = open(module.__file__).read()
 
42
  assert "from agent_framework" not in source
43
  assert "import agent_framework" not in source
44
  assert "BaseAgent" not in source
 
38
  import src.services.statistical_analyzer as module
39
 
40
  # Check module doesn't import agent_framework
41
+ with open(module.__file__) as f:
42
+ source = f.read()
43
  assert "from agent_framework" not in source
44
  assert "import agent_framework" not in source
45
  assert "BaseAgent" not in source