Skip to content

Commit bf5122b

Browse files
author
Andrew Brookins
committed
Lint
1 parent b469188 commit bf5122b

9 files changed

+156
-156
lines changed

agent-memory-client/tests/test_tool_schemas.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ def test_creation_and_editing_tools_exclude_message_type(self):
198198
memory_type_prop = params["properties"]["memory_type"]
199199
if "enum" in memory_type_prop:
200200
if function_name in restricted_tools:
201-
assert "message" not in memory_type_prop["enum"], (
202-
f"Creation/editing tool '{function_name}' should not expose 'message' memory type"
203-
)
201+
assert (
202+
"message" not in memory_type_prop["enum"]
203+
), f"Creation/editing tool '{function_name}' should not expose 'message' memory type"
204204
elif function_name in allowed_tools:
205205
# These tools are allowed to have message in enum for filtering
206206
pass
@@ -215,9 +215,9 @@ def test_creation_and_editing_tools_exclude_message_type(self):
215215
and function_name in restricted_tools
216216
):
217217
memory_type_prop = items["properties"]["memory_type"]
218-
assert "message" not in memory_type_prop["enum"], (
219-
f"Creation/editing tool '{function_name}' should not expose 'message' memory type in nested properties"
220-
)
218+
assert (
219+
"message" not in memory_type_prop["enum"]
220+
), f"Creation/editing tool '{function_name}' should not expose 'message' memory type in nested properties"
221221

222222

223223
class TestAnthropicSchemas:
@@ -290,9 +290,9 @@ def test_anthropic_schemas_exclude_message_type_for_creation(self):
290290
memory_type_prop = params["properties"]["memory_type"]
291291
if "enum" in memory_type_prop:
292292
if function_name in restricted_tools:
293-
assert "message" not in memory_type_prop["enum"], (
294-
f"Anthropic creation/editing tool '{function_name}' should not expose 'message' memory type"
295-
)
293+
assert (
294+
"message" not in memory_type_prop["enum"]
295+
), f"Anthropic creation/editing tool '{function_name}' should not expose 'message' memory type"
296296
elif function_name in allowed_tools:
297297
# These tools are allowed to have message in enum for filtering
298298
pass
@@ -307,6 +307,6 @@ def test_anthropic_schemas_exclude_message_type_for_creation(self):
307307
and function_name in restricted_tools
308308
):
309309
memory_type_prop = items["properties"]["memory_type"]
310-
assert "message" not in memory_type_prop["enum"], (
311-
f"Anthropic creation/editing tool '{function_name}' should not expose 'message' memory type in nested properties"
312-
)
310+
assert (
311+
"message" not in memory_type_prop["enum"]
312+
), f"Anthropic creation/editing tool '{function_name}' should not expose 'message' memory type in nested properties"

tests/test_api.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -378,54 +378,54 @@ async def test_put_memory_context_percentages_with_summarization_regression(
378378
# Verify summarization occurred (message count should be reduced)
379379
original_message_count = len(payload["messages"])
380380
final_message_count = len(data["messages"])
381-
assert final_message_count < original_message_count, (
382-
f"Expected summarization to reduce messages from {original_message_count} to less, but got {final_message_count}"
383-
)
381+
assert (
382+
final_message_count < original_message_count
383+
), f"Expected summarization to reduce messages from {original_message_count} to less, but got {final_message_count}"
384384

385385
# Verify context summary was created
386-
assert data["context"] is not None, (
387-
"Context should not be None after summarization"
388-
)
389-
assert data["context"].strip() != "", (
390-
"Context should not be empty after summarization"
391-
)
386+
assert (
387+
data["context"] is not None
388+
), "Context should not be None after summarization"
389+
assert (
390+
data["context"].strip() != ""
391+
), "Context should not be empty after summarization"
392392

393393
# REGRESSION TEST: Context percentages should NOT be null even after summarization
394394
# They should reflect the current state (post-summarization) with small percentages
395395
assert "context_percentage_total_used" in data
396396
assert "context_percentage_until_summarization" in data
397-
assert data["context_percentage_total_used"] is not None, (
398-
"BUG REGRESSION: context_percentage_total_used should not be null when context_window_max is provided"
399-
)
400-
assert data["context_percentage_until_summarization"] is not None, (
401-
"BUG REGRESSION: context_percentage_until_summarization should not be null when context_window_max is provided"
402-
)
397+
assert (
398+
data["context_percentage_total_used"] is not None
399+
), "BUG REGRESSION: context_percentage_total_used should not be null when context_window_max is provided"
400+
assert (
401+
data["context_percentage_until_summarization"] is not None
402+
), "BUG REGRESSION: context_percentage_until_summarization should not be null when context_window_max is provided"
403403

404404
# Verify the percentages are valid numbers
405405
total_used = data["context_percentage_total_used"]
406406
until_summarization = data["context_percentage_until_summarization"]
407407

408-
assert isinstance(total_used, int | float), (
409-
f"context_percentage_total_used should be a number, got {type(total_used)}"
410-
)
411-
assert isinstance(until_summarization, int | float), (
412-
f"context_percentage_until_summarization should be a number, got {type(until_summarization)}"
413-
)
414-
assert 0 <= total_used <= 100, (
415-
f"context_percentage_total_used should be 0-100, got {total_used}"
416-
)
417-
assert 0 <= until_summarization <= 100, (
418-
f"context_percentage_until_summarization should be 0-100, got {until_summarization}"
419-
)
408+
assert isinstance(
409+
total_used, int | float
410+
), f"context_percentage_total_used should be a number, got {type(total_used)}"
411+
assert isinstance(
412+
until_summarization, int | float
413+
), f"context_percentage_until_summarization should be a number, got {type(until_summarization)}"
414+
assert (
415+
0 <= total_used <= 100
416+
), f"context_percentage_total_used should be 0-100, got {total_used}"
417+
assert (
418+
0 <= until_summarization <= 100
419+
), f"context_percentage_until_summarization should be 0-100, got {until_summarization}"
420420

421421
# After summarization, percentages should be reasonable (not necessarily high)
422422
# They represent the current state of the session post-summarization
423-
assert total_used >= 0, (
424-
f"Expected non-negative total usage percentage, got {total_used}"
425-
)
426-
assert until_summarization >= 0, (
427-
f"Expected non-negative until_summarization percentage, got {until_summarization}"
428-
)
423+
assert (
424+
total_used >= 0
425+
), f"Expected non-negative total usage percentage, got {total_used}"
426+
assert (
427+
until_summarization >= 0
428+
), f"Expected non-negative until_summarization percentage, got {until_summarization}"
429429

430430
@pytest.mark.requires_api_keys
431431
@pytest.mark.asyncio

tests/test_client_tool_calls.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,19 +587,19 @@ def test_all_tool_schemas_exclude_message_type(self):
587587
if "memory_type" in params["properties"]:
588588
memory_type_prop = params["properties"]["memory_type"]
589589
if function_name in restricted_tools:
590-
assert "message" not in memory_type_prop.get("enum", []), (
591-
f"Creation/editing tool {function_name} should not expose 'message' memory type"
592-
)
590+
assert (
591+
"message" not in memory_type_prop.get("enum", [])
592+
), f"Creation/editing tool {function_name} should not expose 'message' memory type"
593593

594594
# Check nested properties (like in create_long_term_memory)
595595
if "memories" in params["properties"]:
596596
items = params["properties"]["memories"].get("items", {})
597597
if "properties" in items and "memory_type" in items["properties"]:
598598
memory_type_prop = items["properties"]["memory_type"]
599599
if function_name in restricted_tools:
600-
assert "message" not in memory_type_prop.get("enum", []), (
601-
f"Creation/editing tool {function_name} should not expose 'message' memory type in nested properties"
602-
)
600+
assert (
601+
"message" not in memory_type_prop.get("enum", [])
602+
), f"Creation/editing tool {function_name} should not expose 'message' memory type in nested properties"
603603

604604

605605
class TestToolCallErrorHandling:

tests/test_context_percentage_calculation.py

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ def test_context_percentages_with_context_window_max(self):
2929
)
3030
)
3131

32-
assert total_percentage is not None, (
33-
"total_percentage should not be None when context_window_max is provided"
34-
)
35-
assert until_summarization_percentage is not None, (
36-
"until_summarization_percentage should not be None when context_window_max is provided"
37-
)
32+
assert (
33+
total_percentage is not None
34+
), "total_percentage should not be None when context_window_max is provided"
35+
assert (
36+
until_summarization_percentage is not None
37+
), "until_summarization_percentage should not be None when context_window_max is provided"
3838
assert isinstance(total_percentage, float), "total_percentage should be a float"
39-
assert isinstance(until_summarization_percentage, float), (
40-
"until_summarization_percentage should be a float"
41-
)
42-
assert 0 <= total_percentage <= 100, (
43-
"total_percentage should be between 0 and 100"
44-
)
45-
assert 0 <= until_summarization_percentage <= 100, (
46-
"until_summarization_percentage should be between 0 and 100"
47-
)
39+
assert isinstance(
40+
until_summarization_percentage, float
41+
), "until_summarization_percentage should be a float"
42+
assert (
43+
0 <= total_percentage <= 100
44+
), "total_percentage should be between 0 and 100"
45+
assert (
46+
0 <= until_summarization_percentage <= 100
47+
), "until_summarization_percentage should be between 0 and 100"
4848

4949
def test_context_percentages_with_model_name(self):
5050
"""Test that context percentages are calculated when model_name is provided"""
@@ -59,16 +59,16 @@ def test_context_percentages_with_model_name(self):
5959
)
6060
)
6161

62-
assert total_percentage is not None, (
63-
"total_percentage should not be None when model_name is provided"
64-
)
65-
assert until_summarization_percentage is not None, (
66-
"until_summarization_percentage should not be None when model_name is provided"
67-
)
62+
assert (
63+
total_percentage is not None
64+
), "total_percentage should not be None when model_name is provided"
65+
assert (
66+
until_summarization_percentage is not None
67+
), "until_summarization_percentage should not be None when model_name is provided"
6868
assert isinstance(total_percentage, float), "total_percentage should be a float"
69-
assert isinstance(until_summarization_percentage, float), (
70-
"until_summarization_percentage should be a float"
71-
)
69+
assert isinstance(
70+
until_summarization_percentage, float
71+
), "until_summarization_percentage should be a float"
7272

7373
def test_context_percentages_without_model_info(self):
7474
"""Test that context percentages return None when no model info is provided"""
@@ -83,12 +83,12 @@ def test_context_percentages_without_model_info(self):
8383
)
8484
)
8585

86-
assert total_percentage is None, (
87-
"total_percentage should be None when no model info is provided"
88-
)
89-
assert until_summarization_percentage is None, (
90-
"until_summarization_percentage should be None when no model info is provided"
91-
)
86+
assert (
87+
total_percentage is None
88+
), "total_percentage should be None when no model info is provided"
89+
assert (
90+
until_summarization_percentage is None
91+
), "until_summarization_percentage should be None when no model info is provided"
9292

9393
def test_context_percentages_with_empty_messages(self):
9494
"""Test context percentages with empty messages list but model info provided"""
@@ -101,12 +101,12 @@ def test_context_percentages_with_empty_messages(self):
101101
)
102102

103103
# CORRECTED: Should return 0.0 when model info is provided, even with empty messages
104-
assert total_percentage == 0.0, (
105-
"total_percentage should be 0.0 for empty messages when model info provided"
106-
)
107-
assert until_summarization_percentage == 0.0, (
108-
"until_summarization_percentage should be 0.0 for empty messages when model info provided"
109-
)
104+
assert (
105+
total_percentage == 0.0
106+
), "total_percentage should be 0.0 for empty messages when model info provided"
107+
assert (
108+
until_summarization_percentage == 0.0
109+
), "until_summarization_percentage should be 0.0 for empty messages when model info provided"
110110

111111
def test_context_percentages_precedence(self):
112112
"""Test that context_window_max takes precedence over model_name"""
@@ -131,9 +131,9 @@ def test_context_percentages_precedence(self):
131131
)
132132

133133
# Results should be the same, proving context_window_max takes precedence
134-
assert total_percentage_both == total_percentage_max_only, (
135-
"context_window_max should take precedence over model_name"
136-
)
134+
assert (
135+
total_percentage_both == total_percentage_max_only
136+
), "context_window_max should take precedence over model_name"
137137
assert (
138138
until_summarization_percentage_both
139139
== until_summarization_percentage_max_only
@@ -163,9 +163,9 @@ def test_context_percentages_high_token_usage(self):
163163
assert until_summarization_percentage is not None
164164
# Should be capped at 100%
165165
assert total_percentage <= 100.0, "total_percentage should be capped at 100%"
166-
assert until_summarization_percentage <= 100.0, (
167-
"until_summarization_percentage should be capped at 100%"
168-
)
166+
assert (
167+
until_summarization_percentage <= 100.0
168+
), "until_summarization_percentage should be capped at 100%"
169169

170170
def test_context_percentages_zero_context_window_regression(self):
171171
"""
@@ -185,9 +185,9 @@ def test_context_percentages_zero_context_window_regression(self):
185185

186186
# Should return None for invalid context window
187187
assert total_percentage is None, "Should return None for zero context window"
188-
assert until_summarization_percentage is None, (
189-
"Should return None for zero context window"
190-
)
188+
assert (
189+
until_summarization_percentage is None
190+
), "Should return None for zero context window"
191191

192192
# Test with negative context window
193193
total_percentage, until_summarization_percentage = (
@@ -197,12 +197,12 @@ def test_context_percentages_zero_context_window_regression(self):
197197
)
198198

199199
# Should return None for invalid context window
200-
assert total_percentage is None, (
201-
"Should return None for negative context window"
202-
)
203-
assert until_summarization_percentage is None, (
204-
"Should return None for negative context window"
205-
)
200+
assert (
201+
total_percentage is None
202+
), "Should return None for negative context window"
203+
assert (
204+
until_summarization_percentage is None
205+
), "Should return None for negative context window"
206206

207207
def test_context_percentages_very_small_context_window_regression(self):
208208
"""
@@ -224,17 +224,17 @@ def test_context_percentages_very_small_context_window_regression(self):
224224
)
225225

226226
# Should handle this gracefully without division by zero
227-
assert total_percentage is not None, (
228-
"Should handle small context window without error"
229-
)
230-
assert until_summarization_percentage is not None, (
231-
"Should handle small context window without error"
232-
)
227+
assert (
228+
total_percentage is not None
229+
), "Should handle small context window without error"
230+
assert (
231+
until_summarization_percentage is not None
232+
), "Should handle small context window without error"
233233
assert isinstance(total_percentage, float), "Should return valid float"
234-
assert isinstance(until_summarization_percentage, float), (
235-
"Should return valid float"
236-
)
234+
assert isinstance(
235+
until_summarization_percentage, float
236+
), "Should return valid float"
237237
# until_summarization_percentage should be 100% when threshold is 0
238-
assert until_summarization_percentage == 100.0, (
239-
"Should return 100% when token threshold is 0"
240-
)
238+
assert (
239+
until_summarization_percentage == 100.0
240+
), "Should return 100% when token threshold is 0"

tests/test_contextual_grounding_integration.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,9 @@ async def test_comprehensive_grounding_evaluation_with_judge(self):
449449

450450
# CI Stability: Accept any valid score (>= 0.0) while grounding system is being improved
451451
# This allows us to track grounding quality without blocking CI on implementation details
452-
assert result.overall_score >= 0.0, (
453-
f"Invalid score for {example['category']}: {result.overall_score}"
454-
)
452+
assert (
453+
result.overall_score >= 0.0
454+
), f"Invalid score for {example['category']}: {result.overall_score}"
455455

456456
# Log performance for monitoring
457457
if result.overall_score < 0.05:
@@ -530,6 +530,6 @@ async def test_model_comparison_grounding_quality(self):
530530
print(f"{model}: {status}")
531531

532532
# At least one model should succeed
533-
assert any(r["success"] for r in results_by_model.values()), (
534-
"No model successfully completed grounding"
535-
)
533+
assert any(
534+
r["success"] for r in results_by_model.values()
535+
), "No model successfully completed grounding"

0 commit comments

Comments
 (0)