Fix: ruff format

This commit is contained in:
Tiago Freire
2026-03-25 10:10:52 -03:00
parent c686f78214
commit 433d19d8bb
3 changed files with 17 additions and 8 deletions

View File

@@ -105,7 +105,9 @@ class FirstTimeTraceHandler:
)
if not self.batch_manager.trace_batch_id:
self._gracefully_fail("Backend batch creation failed, cannot send events.")
self._gracefully_fail(
"Backend batch creation failed, cannot send events."
)
self._reset_batch_state()
return
@@ -234,7 +236,9 @@ To enable tracing later, do any one of these:
logger.debug(f"First-time trace error: {error_message}")
def _show_local_trace_message(self, events_count: int = 0, duration_ms: int = 0, batch_id: str | None = None) -> None:
def _show_local_trace_message(
self, events_count: int = 0, duration_ms: int = 0, batch_id: str | None = None
) -> None:
"""Show message when traces were collected locally but couldn't be uploaded."""
if self.batch_manager is None:
return

View File

@@ -212,7 +212,9 @@ class TraceBatchManager:
def _mark_batch_as_failed(self, trace_batch_id: str, error_message: str) -> None:
"""Mark a trace batch as failed, routing to the correct endpoint."""
if self.is_current_batch_ephemeral:
self.plus_api.mark_ephemeral_trace_batch_as_failed(trace_batch_id, error_message)
self.plus_api.mark_ephemeral_trace_batch_as_failed(
trace_batch_id, error_message
)
else:
self.plus_api.mark_trace_batch_as_failed(trace_batch_id, error_message)
@@ -409,16 +411,16 @@ class TraceBatchManager:
logger.error(
f"❌ Failed to finalize trace batch: {response.status_code} - {response.text}"
)
self._mark_batch_as_failed(
self.trace_batch_id, response.text
)
self._mark_batch_as_failed(self.trace_batch_id, response.text)
except Exception as e:
logger.error(f"❌ Error finalizing trace batch: {e}")
try:
self._mark_batch_as_failed(self.trace_batch_id, str(e))
except Exception:
logger.debug("Could not mark trace batch as failed (network unavailable)")
logger.debug(
"Could not mark trace batch as failed (network unavailable)"
)
def _cleanup_batch_data(self) -> None:
"""Clean up batch data after successful finalization to free memory"""

View File

@@ -141,7 +141,10 @@ To update, run: uv sync --upgrade-package crewai"""
# Don't show "disabled" message when the first-time handler will show
# the trace prompt after execution completes (avoids confusing mid-flow messages)
if TraceCollectionListener._instance and TraceCollectionListener._instance.first_time_handler.is_first_time:
if (
TraceCollectionListener._instance
and TraceCollectionListener._instance.first_time_handler.is_first_time
):
return
if not is_tracing_enabled_in_context():