Skip to content

Commit 70b3d22

Browse files
author
dori
committed
fix: lint
1 parent b3b89dd commit 70b3d22

File tree

9 files changed

+56
-44
lines changed

9 files changed

+56
-44
lines changed

src/mcp_as_a_judge/constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,3 @@
1616
MAX_CONTEXT_RECORDS = 20
1717
CONTEXT_ENRICHMENT_COUNT = 10
1818
RECORD_RETENTION_DAYS = 1
19-
20-
21-

src/mcp_as_a_judge/db/conversation_history_service.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ async def save_tool_interaction(
8787
logger.info(f"✅ Saved conversation record with ID: {record_id}")
8888
return record_id
8989

90-
91-
92-
async def get_conversation_history(self, session_id: str) -> list[ConversationRecord]:
90+
async def get_conversation_history(
91+
self, session_id: str
92+
) -> list[ConversationRecord]:
9393
"""
9494
Get conversation history for a session to be injected into user prompts.
9595
@@ -103,11 +103,15 @@ async def get_conversation_history(self, session_id: str) -> list[ConversationRe
103103

104104
context_records = await self.load_context_for_enrichment(session_id)
105105

106-
logger.info(f"📝 Retrieved {len(context_records)} conversation records for session {session_id}")
106+
logger.info(
107+
f"📝 Retrieved {len(context_records)} conversation records for session {session_id}"
108+
)
107109

108110
return context_records
109111

110-
def format_conversation_history_as_context(self, conversation_history: list[ConversationRecord]) -> str:
112+
def format_conversation_history_as_context(
113+
self, conversation_history: list[ConversationRecord]
114+
) -> str:
111115
"""
112116
Convert conversation history list to formatted string for context field.
113117
@@ -120,7 +124,9 @@ def format_conversation_history_as_context(self, conversation_history: list[Conv
120124
if not conversation_history:
121125
return ""
122126

123-
logger.info(f"📝 Formatting {len(conversation_history)} conversation records as context string")
127+
logger.info(
128+
f"📝 Formatting {len(conversation_history)} conversation records as context string"
129+
)
124130

125131
context_parts = []
126132
for record in conversation_history:
@@ -133,5 +139,3 @@ def format_conversation_history_as_context(self, conversation_history: list[Conv
133139
logger.info(f"📝 Generated context string: {len(formatted_context)} characters")
134140

135141
return formatted_context
136-
137-

src/mcp_as_a_judge/db/interface.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,3 @@ async def get_session_conversations(
7676
List of ConversationRecord objects
7777
"""
7878
pass
79-
80-

src/mcp_as_a_judge/db/providers/sqlite_provider.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ class SQLiteProvider(ConversationHistoryDB):
3434
- Session-based conversation retrieval
3535
"""
3636

37-
def __init__(
38-
self, max_context_records: int = 20, url: str = ""
39-
) -> None:
37+
def __init__(self, max_context_records: int = 20, url: str = "") -> None:
4038
"""Initialize the SQLModel SQLite database with LRU and time-based cleanup."""
4139
# Parse URL to get SQLite connection string
4240
connection_string = self._parse_sqlite_url(url)
@@ -190,5 +188,3 @@ async def get_session_conversations(
190188

191189
records = session.exec(stmt).all()
192190
return list(records)
193-
194-

src/mcp_as_a_judge/models.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ class JudgeCodingPlanUserVars(BaseModel):
118118
user_requirements: str = Field(
119119
description="The user's requirements for the coding task"
120120
)
121-
context: str = Field(
122-
description="Context including conversation history"
123-
)
121+
context: str = Field(description="Context including conversation history")
124122
plan: str = Field(description="The coding plan to be evaluated")
125123
design: str = Field(description="The design documentation")
126124
research: str = Field(description="Research findings and analysis")
@@ -147,9 +145,7 @@ class JudgeCodeChangeUserVars(BaseModel):
147145
file_path: str = Field(description="Path to the file being changed")
148146
change_description: str = Field(description="Description of what the change does")
149147
code_change: str = Field(description="The actual code content being reviewed")
150-
context: str = Field(
151-
description="Context including conversation history"
152-
)
148+
context: str = Field(description="Context including conversation history")
153149

154150

155151
class ResearchValidationSystemVars(BaseModel):
@@ -171,9 +167,7 @@ class ResearchValidationUserVars(BaseModel):
171167
default_factory=list,
172168
description="URLs from MANDATORY online research - minimum 3 URLs required",
173169
)
174-
context: str = Field(
175-
description="Context including conversation history"
176-
)
170+
context: str = Field(description="Context including conversation history")
177171

178172

179173
class WorkflowGuidanceSystemVars(BaseModel):
@@ -226,7 +220,6 @@ class DynamicSchemaUserVars(BaseModel):
226220
)
227221

228222

229-
230223
class ElicitationFallbackUserVars(BaseModel):
231224
"""Variables for elicitation fallback user prompt template."""
232225

src/mcp_as_a_judge/server.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,17 @@ async def build_workflow(
8888

8989
try:
9090
# STEP 1: Load conversation history and format as context string
91-
conversation_history = await conversation_service.get_conversation_history(session_id)
92-
history_context = conversation_service.format_conversation_history_as_context(conversation_history)
91+
conversation_history = await conversation_service.get_conversation_history(
92+
session_id
93+
)
94+
history_context = conversation_service.format_conversation_history_as_context(
95+
conversation_history
96+
)
9397

9498
# Combine user-provided context with conversation history
95-
combined_context = f"{context}\n\n{history_context}".strip() if context else history_context
99+
combined_context = (
100+
f"{context}\n\n{history_context}".strip() if context else history_context
101+
)
96102

97103
# STEP 2: Create system and user messages with formatted context
98104
system_vars = WorkflowGuidanceSystemVars(
@@ -515,7 +521,7 @@ async def judge_coding_plan(
515521
log_tool_execution(
516522
"judge_coding_plan",
517523
session_id,
518-
f"Plan: {plan}\nUser Requirements: {user_requirements}"
524+
f"Plan: {plan}\nUser Requirements: {user_requirements}",
519525
)
520526

521527
# Handle default value for research_urls
@@ -554,8 +560,12 @@ async def judge_coding_plan(
554560

555561
try:
556562
# STEP 1: Load conversation history and format as context string
557-
conversation_history = await conversation_service.get_conversation_history(session_id)
558-
history_context = conversation_service.format_conversation_history_as_context(conversation_history)
563+
conversation_history = await conversation_service.get_conversation_history(
564+
session_id
565+
)
566+
history_context = conversation_service.format_conversation_history_as_context(
567+
conversation_history
568+
)
559569

560570
# STEP 2: Use helper function for main evaluation with formatted conversation history
561571
evaluation_result = await _evaluate_coding_plan(
@@ -633,8 +643,12 @@ async def judge_code_change(
633643

634644
try:
635645
# STEP 1: Load conversation history and format as context string
636-
conversation_history = await conversation_service.get_conversation_history(session_id)
637-
history_context = conversation_service.format_conversation_history_as_context(conversation_history)
646+
conversation_history = await conversation_service.get_conversation_history(
647+
session_id
648+
)
649+
history_context = conversation_service.format_conversation_history_as_context(
650+
conversation_history
651+
)
638652

639653
# STEP 2: Create system and user messages with formatted context
640654
system_vars = JudgeCodeChangeSystemVars(

tests/test_db_implementation.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ async def test_database_operations():
5454
assert len(all_records) == 2, f"Expected 2 records, got {len(all_records)}"
5555

5656
# Verify record content
57-
assert all_records[0].source == "judge_code_change", "Most recent record should be judge_code_change"
58-
assert all_records[1].source == "judge_coding_plan", "Older record should be judge_coding_plan"
59-
assert all_records[0].input == "Review this code change", "Record content should match"
57+
assert all_records[0].source == "judge_code_change", (
58+
"Most recent record should be judge_code_change"
59+
)
60+
assert all_records[1].source == "judge_coding_plan", (
61+
"Older record should be judge_coding_plan"
62+
)
63+
assert all_records[0].input == "Review this code change", (
64+
"Record content should match"
65+
)
6066
print("✅ CRUD operations verified successfully")
6167

6268
# Test deletion
@@ -76,7 +82,9 @@ async def test_database_operations():
7682
# Final verification - ensure cleanup worked
7783
final_records = await db.get_session_conversations("session_123")
7884
print(f"Final verification: {len(final_records)} records remaining")
79-
assert len(final_records) == 0, f"Expected 0 records after cleanup, got {len(final_records)}"
85+
assert len(final_records) == 0, (
86+
f"Expected 0 records after cleanup, got {len(final_records)}"
87+
)
8088
print("✅ Cleanup verification successful")
8189

8290
print("\n✅ All tests completed successfully!")

tests/test_sqlite_comprehensive.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,15 @@ async def test_large_dataset_performance(self):
115115
# Test performance verification - ensure LRU cleanup worked correctly
116116
# Verify that we have exactly the max_context_records (100) and they are the most recent
117117
all_records = await db.get_session_conversations("perf_test")
118-
assert len(all_records) == 100, f"Expected exactly 100 records after LRU cleanup, got {len(all_records)}"
118+
assert len(all_records) == 100, (
119+
f"Expected exactly 100 records after LRU cleanup, got {len(all_records)}"
120+
)
119121

120122
# Verify records are in correct order (most recent first)
121123
for i in range(len(all_records) - 1):
122-
assert all_records[i].timestamp >= all_records[i + 1].timestamp, "Records should be ordered by timestamp desc"
124+
assert all_records[i].timestamp >= all_records[i + 1].timestamp, (
125+
"Records should be ordered by timestamp desc"
126+
)
123127

124128
print("✅ Performance and LRU cleanup verification successful")
125129

tests/test_utils/db_test_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,3 @@ async def clear_session(db: ConversationHistoryDB, session_id: str) -> int:
4040
return len(records)
4141
else:
4242
raise NotImplementedError(f"clear_session not implemented for {type(db)}")
43-
44-

0 commit comments

Comments
 (0)