Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit 2315012

Browse files
committed
Fixes
1 parent cbd7f72 commit 2315012

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

src/utils/live_display.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import atexit
6+
import contextlib
67
import os
78
import signal
89
import sys
@@ -127,27 +128,21 @@ def _cleanup_display(self) -> None:
127128

128129
# Clean up Rich live context if it exists
129130
if self._live_context:
130-
try:
131+
with contextlib.suppress(Exception):
131132
self._live_context.stop()
132133
self._live_context = None
133-
except Exception:
134-
pass
135134

136135
# Restore cursor and clear any remaining output
137136
if self.console and self.is_interactive:
138-
try:
137+
with contextlib.suppress(Exception):
139138
# Show cursor and reset terminal state
140139
self.console.show_cursor(True)
141140
self.console.print("", end="") # Ensure clean state
142-
except Exception:
143-
pass
144141
elif self.is_interactive:
145142
# Fallback: show cursor and clear line
146-
try:
143+
with contextlib.suppress(Exception):
147144
sys.stdout.write("\r\033[K\033[?25h") # Clear line and show cursor
148145
sys.stdout.flush()
149-
except Exception:
150-
pass
151146
except Exception:
152147
# Ignore any errors during cleanup to avoid masking original exceptions
153148
pass
@@ -281,17 +276,13 @@ def stop_thinking_timer(self) -> None:
281276

282277
# Ensure any remaining display is cleared
283278
if self._live_context:
284-
try:
279+
with contextlib.suppress(Exception):
285280
self._live_context.stop()
286281
self._live_context = None
287-
except Exception:
288-
pass
289282
elif not self.quiet_mode:
290283
# Clear line for non-Rich fallback
291-
try:
284+
with contextlib.suppress(Exception):
292285
print("\r" + " " * 60 + "\r", end="", flush=True)
293-
except Exception:
294-
pass
295286

296287
self._timer_thread = None
297288
self._timer_progress = None
@@ -307,7 +298,9 @@ def _timer_update_loop(self) -> None:
307298
from rich.text import Text
308299

309300
try:
310-
self._live_context = Live(refresh_per_second=10, console=self.console, transient=True)
301+
self._live_context = Live(
302+
refresh_per_second=10, console=self.console, transient=True
303+
)
311304
self._live_context.start()
312305

313306
while not self._stop_timer.is_set():
@@ -339,11 +332,9 @@ def _timer_update_loop(self) -> None:
339332
finally:
340333
# Clear the display and clean up the live context
341334
if self._live_context:
342-
try:
335+
with contextlib.suppress(Exception):
343336
self._live_context.stop()
344337
self._live_context = None
345-
except Exception:
346-
pass
347338
else:
348339
# Fallback for non-Rich terminals
349340
try:
@@ -396,7 +387,7 @@ def show_response(self, progress: TestProgress, response: ModelResponse) -> None
396387
timing_parts = [f"took: {response.response_time:.2f}s"]
397388
if response.total_tokens > 0:
398389
timing_parts.append(f"tokens: {response.total_tokens}")
399-
390+
400391
if timing_parts:
401392
title += f" ({' | '.join(timing_parts)})"
402393

@@ -415,10 +406,10 @@ def show_response(self, progress: TestProgress, response: ModelResponse) -> None
415406
timing_parts = [f"took: {response.response_time:.2f}s"]
416407
if response.total_tokens > 0:
417408
timing_parts.append(f"tokens: {response.total_tokens}")
418-
409+
419410
if timing_parts:
420411
title += f" ({' | '.join(timing_parts)})"
421-
412+
422413
print(f"\n{title}:")
423414
print(f" {response_content}")
424415

tests/test_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class TestTester(BaseTester):
252252

253253
# Verify it called the generic runner with correct arguments
254254
mock_generic_runner.assert_called_once_with(
255-
TestTester, mock_client, "test", "001"
255+
TestTester, mock_client, "test", "001", 1
256256
)
257257
assert result == {"result": "success"}
258258

0 commit comments

Comments
 (0)