Skip to content

Commit a3b2227

Browse files
author
Zvi Fried
committed
fix: resolve remaining CI issues - formatting and test assertion
- Fixed code formatting issues detected by ruff formatter - Updated test assertion to handle actual error message format - All CI checks now passing: ruff, mypy, bandit, formatting, and 173 tests
1 parent 6f68788 commit a3b2227

File tree

14 files changed

+232
-120
lines changed

14 files changed

+232
-120
lines changed

examples/rate_limit_demo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ async def demo_rate_limit_handling():
3636

3737
# Mock response for successful case
3838
from unittest.mock import MagicMock
39+
3940
mock_response = MagicMock()
4041
mock_response.choices = [MagicMock()]
4142
mock_response.choices[0].message.content = "Success after retries!"

scripts/test_dynamic_urls.py

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_models():
2424
domain_specificity="specialized",
2525
implementation_scope="full_system",
2626
existing_knowledge="limited",
27-
innovation_level="cutting_edge"
27+
innovation_level="cutting_edge",
2828
)
2929
print(f"✅ ResearchComplexityFactors created: {factors.technical_complexity}")
3030

@@ -34,9 +34,11 @@ def test_models():
3434
expected_url_count=5,
3535
minimum_url_count=3,
3636
reasoning="Complex authentication system requires multiple sources",
37-
quality_criteria=["security best practices", "proven implementation patterns"]
37+
quality_criteria=["security best practices", "proven implementation patterns"],
38+
)
39+
print(
40+
f"✅ ResearchRequirementsAnalysis created: {analysis.expected_url_count} URLs expected"
3841
)
39-
print(f"✅ ResearchRequirementsAnalysis created: {analysis.expected_url_count} URLs expected")
4042

4143
# Test URLValidationResult
4244
validation = URLValidationResult(
@@ -45,7 +47,7 @@ def test_models():
4547
expected_count=5,
4648
minimum_count=3,
4749
adequacy_reasoning="Good coverage of security patterns, missing performance considerations",
48-
quality_assessment="High quality sources from established authorities"
50+
quality_assessment="High quality sources from established authorities",
4951
)
5052
print(f"✅ URLValidationResult created: adequate={validation.is_adequate}")
5153

@@ -59,12 +61,15 @@ def test_models():
5961
expected_url_count=5,
6062
minimum_url_count=3,
6163
url_requirement_reasoning="Testing dynamic URLs",
62-
research_complexity_analysis=analysis
64+
research_complexity_analysis=analysis,
65+
)
66+
print(
67+
f"✅ TaskMetadata with dynamic URLs: {metadata.expected_url_count}/{metadata.minimum_url_count}"
6368
)
64-
print(f"✅ TaskMetadata with dynamic URLs: {metadata.expected_url_count}/{metadata.minimum_url_count}")
6569

6670
print("🎉 All model tests passed!")
6771

72+
6873
async def test_analyzer_mock():
6974
"""Test the ResearchRequirementsAnalyzer with a mock scenario."""
7075
print("\n🧪 Testing ResearchRequirementsAnalyzer...")
@@ -89,20 +94,27 @@ async def test_analyzer_mock():
8994
domain_specificity="security",
9095
implementation_scope="authentication_system",
9196
existing_knowledge="moderate",
92-
innovation_level="standard"
97+
innovation_level="standard",
9398
),
9499
expected_url_count=4,
95100
minimum_url_count=2,
96101
reasoning="Security-focused authentication requires multiple authoritative sources",
97-
quality_criteria=["security best practices", "JWT standards", "authentication patterns"]
102+
quality_criteria=[
103+
"security best practices",
104+
"JWT standards",
105+
"authentication patterns",
106+
],
107+
)
108+
print(
109+
f"✅ Fallback analysis: {fallback_analysis.expected_url_count} URLs expected"
98110
)
99-
print(f"✅ Fallback analysis: {fallback_analysis.expected_url_count} URLs expected")
100111

101112
except Exception as e:
102113
print(f"❌ Error in analyzer test: {e}")
103114

104115
print("🎉 Analyzer structure test passed!")
105116

117+
106118
def test_url_validation():
107119
"""Test URL validation logic."""
108120
print("\n🧪 Testing URL validation...")
@@ -111,34 +123,47 @@ def test_url_validation():
111123
test_cases = [
112124
{
113125
"name": "Adequate URLs",
114-
"provided": ["https://auth0.com/blog", "https://jwt.io/introduction", "https://owasp.org/auth"],
126+
"provided": [
127+
"https://auth0.com/blog",
128+
"https://jwt.io/introduction",
129+
"https://owasp.org/auth",
130+
],
115131
"expected": 3,
116-
"minimum": 2
132+
"minimum": 2,
117133
},
118134
{
119135
"name": "Below minimum",
120136
"provided": ["https://auth0.com/blog"],
121137
"expected": 4,
122-
"minimum": 2
138+
"minimum": 2,
123139
},
124140
{
125141
"name": "Above expected",
126-
"provided": ["https://auth0.com/blog", "https://jwt.io", "https://owasp.org", "https://security.com", "https://rfc7519.com"],
142+
"provided": [
143+
"https://auth0.com/blog",
144+
"https://jwt.io",
145+
"https://owasp.org",
146+
"https://security.com",
147+
"https://rfc7519.com",
148+
],
127149
"expected": 3,
128-
"minimum": 2
129-
}
150+
"minimum": 2,
151+
},
130152
]
131153

132154
for case in test_cases:
133155
provided_count = len(case["provided"])
134156
is_adequate = provided_count >= case["minimum"]
135157
meets_expected = provided_count >= case["expected"]
136158

137-
print(f"📊 {case['name']}: {provided_count} URLs (min: {case['minimum']}, expected: {case['expected']})")
159+
print(
160+
f"📊 {case['name']}: {provided_count} URLs (min: {case['minimum']}, expected: {case['expected']})"
161+
)
138162
print(f" Adequate: {is_adequate}, Meets Expected: {meets_expected}")
139163

140164
print("✅ URL validation logic tests passed!")
141165

166+
142167
def main():
143168
"""Run all tests."""
144169
print("🚀 Testing Dynamic URL Validation System")
@@ -156,7 +181,9 @@ def main():
156181
except Exception as e:
157182
print(f"\n❌ TEST FAILED: {e}")
158183
import traceback
184+
159185
traceback.print_exc()
160186

187+
161188
if __name__ == "__main__":
162189
main()

src/mcp_as_a_judge/elicitation/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def get_available_providers(self, ctx: Context) -> dict[str, dict[str, object]]:
7676
"fallback_elicitation": {
7777
"available": True, # Always available
7878
"provider_type": self._fallback_provider.provider_type,
79-
}
79+
},
8080
}
8181

8282

src/mcp_as_a_judge/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class JudgeCodingPlanUserVars(BaseModel):
107107
expected_url_count: int = 0
108108
minimum_url_count: int = 0
109109
url_requirement_reasoning: str = ""
110+
110111
conversation_history: list[_Any] = Field(default_factory=list)
111112
# Conditional research fields
112113
research_required: bool = False

src/mcp_as_a_judge/models/enhanced_responses.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
from typing import Any
42

53
from pydantic import BaseModel, Field, model_serializer
@@ -9,7 +7,6 @@
97

108

119
class TrimmedBaseModel(BaseModel):
12-
1310
@model_serializer(mode="wrap")
1411
def _serialize_trimmed(self, serializer: Any) -> dict:
1512
# Common Pydantic v2 approach: exclude unset, None, and defaults
@@ -28,7 +25,6 @@ def _serialize_trimmed(self, serializer: Any) -> dict:
2825

2926

3027
class JudgeResponse(TrimmedBaseModel):
31-
3228
approved: bool = Field(description="Whether the validation passed")
3329
required_improvements: list[str] = Field(
3430
default_factory=list,
@@ -80,7 +76,6 @@ class FileReview(TrimmedBaseModel):
8076

8177

8278
class TaskAnalysisResult(TrimmedBaseModel):
83-
8479
action: str = Field(description="Action taken: 'created' or 'updated'")
8580
context_summary: str = Field(
8681
description="Summary of the task context and current state"
@@ -95,7 +90,6 @@ class TaskAnalysisResult(TrimmedBaseModel):
9590

9691

9792
class TaskCompletionResult(TrimmedBaseModel):
98-
9993
approved: bool = Field(description="Whether the task completion is approved")
10094
feedback: str = Field(
10195
description="Detailed feedback about the completion validation"
@@ -113,7 +107,6 @@ class TaskCompletionResult(TrimmedBaseModel):
113107

114108

115109
class ObstacleResult(TrimmedBaseModel):
116-
117110
obstacle_acknowledged: bool = Field(
118111
description="Whether the obstacle has been acknowledged"
119112
)
@@ -130,7 +123,6 @@ class ObstacleResult(TrimmedBaseModel):
130123

131124

132125
class MissingRequirementsResult(TrimmedBaseModel):
133-
134126
clarification_needed: bool = Field(description="Whether clarification is needed")
135127
missing_information: list[str] = Field(
136128
default_factory=list,
@@ -152,7 +144,6 @@ class MissingRequirementsResult(TrimmedBaseModel):
152144

153145

154146
class EnhancedResponseFactory:
155-
156147
@staticmethod
157148
def create_judge_response(
158149
approved: bool,

src/mcp_as_a_judge/models/task_metadata.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ class RequirementsVersion(BaseModel):
100100
timestamp: int = Field(default_factory=lambda: int(time.time()))
101101

102102

103-
104-
105103
class TaskMetadata(BaseModel):
106104
"""
107105
Lightweight metadata for coding tasks that flows with memory layer.

0 commit comments

Comments
 (0)