Skip to content

Commit f64bf5f

Browse files
committed
fix: resolve all ruff lint errors
- Fix E402 in cli/app.py: move lazy imports into function bodies - Fix E501 in data_analysis.py: break long lines in template code - Auto-fix 16 errors: unused imports, unsorted imports in test files
1 parent cfe3dc4 commit f64bf5f

9 files changed

Lines changed: 37 additions & 28 deletions

File tree

retrai/agent/nodes/plan.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from retrai.agent.state import AgentState, ToolCall
1313
from retrai.events.types import AgentEvent
1414
from retrai.llm.factory import get_llm
15-
1615
from retrai.tools.builtins import create_default_registry
1716

1817
logger = logging.getLogger(__name__)

retrai/cli/app.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,12 @@ def run(
351351
)
352352
)
353353

354+
from retrai.cli.runners import run_cli as _run_cli
355+
354356
exit_code = asyncio.run(_run_cli(cfg))
355357
raise typer.Exit(code=exit_code)
356358

357359

358-
from retrai.cli.runners import (
359-
run_cli as _run_cli,
360-
run_solve as _run_solve,
361-
run_swarm as _run_swarm,
362-
)
363-
364360

365361
@app.command()
366362
def serve(
@@ -753,6 +749,8 @@ def solve(
753749
hitl_enabled=False,
754750
)
755751

752+
from retrai.cli.runners import run_solve as _run_solve
753+
756754
exit_code = asyncio.run(_run_solve(cfg, description))
757755
raise typer.Exit(code=exit_code)
758756

@@ -814,6 +812,8 @@ def swarm(
814812
)
815813
)
816814

815+
from retrai.cli.runners import run_swarm as _run_swarm
816+
817817
exit_code = asyncio.run(_run_swarm(
818818
description=description,
819819
cwd=resolved_cwd,

retrai/tools/builtins.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from retrai.tools.base import BaseTool, ToolRegistry, ToolSchema
1616

17-
1817
# ──────────────────────────────────────────────────────────────────
1918
# Shell / Execution
2019
# ──────────────────────────────────────────────────────────────────

retrai/tools/data_analysis.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import json
66
import logging
77
import textwrap
8-
from typing import Any
98

109
from retrai.tools.python_exec import python_exec
1110

@@ -93,7 +92,10 @@ def _build_summary_code(file_path: str) -> str:
9392
"columns": list(df.columns),
9493
"dtypes": {{col: str(dtype) for col, dtype in df.dtypes.items()}},
9594
"missing": {{col: int(v) for col, v in df.isnull().sum().items() if v > 0}},
96-
"missing_pct": {{col: round(v / len(df) * 100, 1) for col, v in df.isnull().sum().items() if v > 0}},
95+
"missing_pct": {{
96+
col: round(v / len(df) * 100, 1)
97+
for col, v in df.isnull().sum().items() if v > 0
98+
}},
9799
}}
98100
99101
# Numeric summary
@@ -181,7 +183,10 @@ def _build_quality_code(file_path: str) -> str:
181183
"memory_mb": round(df.memory_usage(deep=True).sum() / 1024 / 1024, 2),
182184
"duplicate_rows": int(df.duplicated().sum()),
183185
"complete_rows": int(df.dropna().shape[0]),
184-
"completeness_pct": round(df.dropna().shape[0] / len(df) * 100, 1) if len(df) > 0 else 0,
186+
"completeness_pct": (
187+
round(df.dropna().shape[0] / len(df) * 100, 1)
188+
if len(df) > 0 else 0
189+
),
185190
}}
186191
187192
# Per-column quality
@@ -190,9 +195,15 @@ def _build_quality_code(file_path: str) -> str:
190195
info = {{
191196
"dtype": str(df[col].dtype),
192197
"missing": int(df[col].isnull().sum()),
193-
"missing_pct": round(df[col].isnull().sum() / len(df) * 100, 1) if len(df) > 0 else 0,
198+
"missing_pct": (
199+
round(df[col].isnull().sum() / len(df) * 100, 1)
200+
if len(df) > 0 else 0
201+
),
194202
"unique": int(df[col].nunique()),
195-
"unique_pct": round(df[col].nunique() / len(df) * 100, 1) if len(df) > 0 else 0,
203+
"unique_pct": (
204+
round(df[col].nunique() / len(df) * 100, 1)
205+
if len(df) > 0 else 0
206+
),
196207
}}
197208
if df[col].dtype in ["float64", "int64"]:
198209
info["zeros"] = int((df[col] == 0).sum())
@@ -240,12 +251,21 @@ def _build_distribution_code(file_path: str) -> str:
240251
col_info = {{"dtype": str(df[col].dtype)}}
241252
242253
if df[col].dtype in ["float64", "int64"]:
243-
col_info["min"] = float(df[col].min()) if not df[col].isnull().all() else None
244-
col_info["max"] = float(df[col].max()) if not df[col].isnull().all() else None
245-
col_info["mean"] = round(float(df[col].mean()), 4) if not df[col].isnull().all() else None
246-
col_info["median"] = float(df[col].median()) if not df[col].isnull().all() else None
247-
col_info["std"] = round(float(df[col].std()), 4) if not df[col].isnull().all() else None
248-
col_info["skewness"] = round(float(df[col].skew()), 4) if not df[col].isnull().all() else None
254+
not_null = not df[col].isnull().all()
255+
col_info["min"] = float(df[col].min()) if not_null else None
256+
col_info["max"] = float(df[col].max()) if not_null else None
257+
col_info["mean"] = (
258+
round(float(df[col].mean()), 4) if not_null else None
259+
)
260+
col_info["median"] = (
261+
float(df[col].median()) if not_null else None
262+
)
263+
col_info["std"] = (
264+
round(float(df[col].std()), 4) if not_null else None
265+
)
266+
col_info["skewness"] = (
267+
round(float(df[col].skew()), 4) if not_null else None
268+
)
249269
250270
# Histogram bins
251271
try:

tests/unit/test_js_exec.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
js_exec,
1616
)
1717

18-
1918
# ── js_sandbox_dir ────────────────────────────────────────────────────────────
2019

2120

tests/unit/test_ml_train.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import json
66
from pathlib import Path
7-
from unittest.mock import AsyncMock, patch
87

98
import pytest
109

@@ -16,7 +15,6 @@
1615
ml_train,
1716
)
1817

19-
2018
# ── ml_train validation ──────────────────────────────────────────────────────
2119

2220

tests/unit/test_research_goal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import json
66
from pathlib import Path
7-
from unittest.mock import patch
87

98
import pytest
109

tests/unit/test_swarm_integration.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
from __future__ import annotations
44

55
import json
6-
from unittest.mock import AsyncMock, MagicMock, patch
7-
8-
import pytest
96

107
from retrai.swarm.decomposer import _parse_subtasks
118
from retrai.swarm.roles import get_role

tests/unit/test_visualize.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
from __future__ import annotations
44

55
import json
6-
import textwrap
76
from unittest.mock import AsyncMock, MagicMock, patch
87

98
import pytest
109

1110
from retrai.tools.visualize import VALID_CHART_TYPES, _build_chart_code, visualize
1211

13-
1412
# ---------------------------------------------------------------------------
1513
# _build_chart_code tests
1614
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)