From b3044a780eba7e3f5cfe81f9cb677f624275c440 Mon Sep 17 00:00:00 2001 From: alex-clawd Date: Wed, 13 May 2026 00:15:48 -0700 Subject: [PATCH] fix: resolve remaining ruff lint errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename suppress_benchmark_output → SuppressBenchmarkOutput and artifacts_sandbox → ArtifactsSandbox (N801 CapWords), and drop unused loop variable to use dict.values() (PERF102). Co-Authored-By: Claude Sonnet 4.6 --- lib/cli/src/crewai_cli/benchmark.py | 19 ++++++++++++------- lib/cli/src/crewai_cli/cli.py | 10 +++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/cli/src/crewai_cli/benchmark.py b/lib/cli/src/crewai_cli/benchmark.py index fc3d9ebc8..0128d9a49 100644 --- a/lib/cli/src/crewai_cli/benchmark.py +++ b/lib/cli/src/crewai_cli/benchmark.py @@ -3,13 +3,14 @@ from __future__ import annotations import asyncio +from collections.abc import Callable import json +from pathlib import Path import re import time -from pathlib import Path -from typing import Any, Callable +from typing import Any -from pydantic import BaseModel, Field +from pydantic import BaseModel class BenchmarkCase(BaseModel): @@ -340,14 +341,16 @@ async def run_benchmark( return dict(zip(models, all_results)) -class suppress_benchmark_output: +class SuppressBenchmarkOutput: """Context manager that silences console formatter and noisy logging during benchmarks.""" def __enter__(self): import logging self._saved_formatter = None try: - from crewai.events.listeners.tracing.trace_listener import TraceCollectionListener + from crewai.events.listeners.tracing.trace_listener import ( + TraceCollectionListener, + ) listener = TraceCollectionListener._instance if listener: self._saved_formatter = listener.formatter @@ -366,7 +369,9 @@ class suppress_benchmark_output: lg.setLevel(level) if self._saved_formatter is not None: try: - from crewai.events.listeners.tracing.trace_listener import TraceCollectionListener + from crewai.events.listeners.tracing.trace_listener import ( + TraceCollectionListener, + ) listener = TraceCollectionListener._instance if listener: listener.formatter = self._saved_formatter @@ -374,7 +379,7 @@ class suppress_benchmark_output: pass -class artifacts_sandbox: +class ArtifactsSandbox: """Context manager that chdirs into tests/artifacts/ for the benchmark run. Any files created by agent tools land in the artifacts directory instead of diff --git a/lib/cli/src/crewai_cli/cli.py b/lib/cli/src/crewai_cli/cli.py index d317b2909..4b2eb557a 100644 --- a/lib/cli/src/crewai_cli/cli.py +++ b/lib/cli/src/crewai_cli/cli.py @@ -784,11 +784,11 @@ def _test_new_agents( fg="cyan", bold=True, ) - from crewai_cli.benchmark import artifacts_sandbox, suppress_benchmark_output + from crewai_cli.benchmark import ArtifactsSandbox, SuppressBenchmarkOutput progress.start() try: - with artifacts_sandbox(), suppress_benchmark_output(): + with ArtifactsSandbox(), SuppressBenchmarkOutput(): all_results = asyncio.run(_run_all()) finally: progress.stop() @@ -803,7 +803,7 @@ def _test_new_agents( continue agents_tested += 1 - for model_name, results in result.items(): + for results in result.values(): failed = [r for r in results if r.score < job["threshold"]] if failed: all_passed = False @@ -1612,12 +1612,12 @@ def benchmark( click.echo(f"Judge model: {judge_model}") click.echo() - from crewai_cli.benchmark import artifacts_sandbox, suppress_benchmark_output + from crewai_cli.benchmark import ArtifactsSandbox, SuppressBenchmarkOutput progress = _BenchmarkLiveProgress(console=_con) progress.start() try: - with artifacts_sandbox(), suppress_benchmark_output(): + with ArtifactsSandbox(), SuppressBenchmarkOutput(): results_by_model = asyncio.run( run_benchmark( agent_def=agent_path,