Skip to content

Commit ec34f2d

Browse files
committed
Fix linting and type errors in benchmark tool
- Add type annotations for adapters dictionaries - Add type: ignore comments for optional dependencies (typer, rich) - Split long line to comply with line length limit (E501) - Suppress untyped-decorator warning for typer command decorator All linters now pass: ruff format, ruff check, and mypy strict mode.
1 parent 2364165 commit ec34f2d

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

tools/benchmark_storage.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from pathlib import Path
3131
from time import perf_counter
3232

33-
import typer
33+
import typer # type: ignore[import-not-found]
3434

3535
# Import jqueue components from the local package
3636
# Add parent directory to path to import jqueue
@@ -41,9 +41,9 @@
4141
from jqueue.adapters.storage.memory import InMemoryStorage
4242

4343
try:
44-
from rich.console import Console
45-
from rich.panel import Panel
46-
from rich.table import Table
44+
from rich.console import Console # type: ignore[import-not-found]
45+
from rich.panel import Panel # type: ignore[import-not-found]
46+
from rich.table import Table # type: ignore[import-not-found]
4747

4848
RICH_AVAILABLE = True
4949
except ImportError:
@@ -549,7 +549,7 @@ def format_results_rich(results: list[BenchmarkResult]) -> None:
549549
console = Console()
550550

551551
# Group results by adapter
552-
adapters = {}
552+
adapters: dict[str, list[BenchmarkResult]] = {}
553553
for result in results:
554554
if result.adapter_name not in adapters:
555555
adapters[result.adapter_name] = []
@@ -602,7 +602,7 @@ def format_results_plain(results: list[BenchmarkResult]) -> None:
602602
results : list of benchmark results
603603
"""
604604
# Group results by adapter
605-
adapters = {}
605+
adapters: dict[str, list[BenchmarkResult]] = {}
606606
for result in results:
607607
if result.adapter_name not in adapters:
608608
adapters[result.adapter_name] = []
@@ -616,7 +616,8 @@ def format_results_plain(results: list[BenchmarkResult]) -> None:
616616
print(f"\nAdapter: {adapter_name}")
617617
print("-" * 80)
618618
print(
619-
f"{'Operation':<15} | {'Ops/sec':>9} | {'P50':>8} | {'P95':>8} | {'P99':>8} | {'Max':>8}"
619+
f"{'Operation':<15} | {'Ops/sec':>9} | {'P50':>8} | "
620+
f"{'P95':>8} | {'P99':>8} | {'Max':>8}"
620621
)
621622
print("-" * 80)
622623

@@ -654,7 +655,7 @@ def format_results(results: list[BenchmarkResult]) -> None:
654655
# ---------------------------------------------------------------------------
655656

656657

657-
@app.command()
658+
@app.command() # type: ignore[untyped-decorator]
658659
def main(
659660
operations: int = typer.Option(
660661
1000,

uv.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)