#1063

Python lint debt: 67 ruff@0.16 findings invisible to CI (unpinned nx lint command + no pre-commit ruff + CI pinned to 0.14.13)

Openaryanranderiyaopened 3mo ago

Python lint debt: 67 ruff@0.16 findings on master that CI cannot see

Measured at origin/master (dd6b19d07), cd apps/api && uvx ruff@0.16.4 check . → 67 errors. The exact same tree under the CI-pinned ruff@0.14.13 → 0 errors. Nothing is wrong with the code at 0.14.13; every finding is a rule that was added or promoted out of preview between 0.14 and 0.16 inside rule families this repo already selects (PL, FURB, ASYNC, ISC). Because the surfaces below disagree on which ruff runs, master stays green while anyone running a current ruff sees 67 failures.

Why CI never caught this

SurfaceRuff versionResult
CI: .github/workflows/code-quality.yml:352-358pinned uvx --no-build ruff@0.14.130 errors → green
nx lint api / mise run lint: apps/api/project.json:62unpinned uvx ruff check . → floats to 0.16.467 errors
Pre-commit (.pre-commit-config.yaml)no ruff hook at allcommits never gate Python lint

Four compounding gaps:

  1. CI pins an old ruff; local commands float to the newest. The pin in code-quality.yml even carries a warning comment ("Unpinned, a ruff release can flip this lane red") and notes "0.16.0 shipped ISC004" — but only CI got the pin.
  2. Nobody invokes the repo's own lint target in CI. main.yml deliberately doesn't duplicate static checks ("they live in code-quality.yml"), and code-quality.yml scans with its own pinned invocation — so the unpinned nx lint api command can rot forever without any signal.
  3. Pre-commit has no ruff hook, so nothing gates individual commits either; debt accumulates invisibly until a rule promotion flips everything at once.
  4. The version is not pinned anywhere as a single source of truth: ruff>=0.4.4 in both Python projects' dev groups (root uv.lock resolves 0.14.13), no entry in mise.toml [tools], and four separate files invoke uvx ruff bare (apps/api/project.json ×4 targets, apps/voice-agent/project.json ×2, apps/voice-agent/mise.toml ×2, root package.json quality:py:ruff).

Version-boundary proof (same tree, same config):

rufffindings
0.14.13 (= uv.lock, = CI)0
0.15.055
0.16.0+ (current uvx)67

The 67 findings

All paths relative to apps/api/.

PLR0917 too-many-positional-arguments (23)

Stabilized out of preview in 0.16. Note: its keyword twin PLR0913 is already deliberately ignored in root pyproject.toml (# too many arguments) — decide whether PLR0917 should be fixed or ignored alongside it.

app/agents/core/messages.py:31, app/agents/core/subagents/base_subagent.py:143, app/agents/middleware/subagent.py:92, app/agents/skills/registry.py:38, app/agents/tools/coding/edit_tool.py:106, app/agents/tools/coding/query_json_tool.py:72, app/agents/tools/core/registry.py:208, app/agents/tools/reminder_tool.py:36, app/agents/tools/todo_tool.py:330, app/agents/tools/tracked_todo_tools.py:416, app/agents/tools/tracked_todo_tools.py:683, app/core/lazy_loader.py:56, app/core/lazy_loader.py:466, app/decorators/caching.py:112, app/services/chat/persistence.py:105, app/services/integrations/integration_connection_service.py:178, app/services/mail/mail_service.py:91, app/services/onboarding/intelligence_service.py:386, app/services/onboarding/intelligence_service.py:1009, app/services/onboarding/intelligence_service.py:1828, app/services/onboarding/post_onboarding_service.py:10, scripts/sync_composio_tools.py:370, tests/integration/mcp/test_mcp_oauth_flow.py:81

FURB110 if-exp-instead-of-or-operator (13)

app/agents/memory/profile_crawler.py:88, app/agents/tools/integrations/linear_tool.py:764, app/agents/tools/integrations/linear_tool.py:766, app/agents/tools/integrations/linear_tool.py:768, app/agents/tools/integrations/twitter_tool.py:265, app/models/composio_schemas/linear_tools.py:56, app/services/provider_metadata_service.py:163, app/services/triggers/handlers/google_sheets.py:265, app/services/upload_service.py:56, app/utils/weather_utils.py:56, app/utils/workflow_utils.py:213, scripts/populate_gaia_knowledge.py:144, scripts/populate_gaia_knowledge.py:170

ASYNC240 blocking-path-method-in-async-function (8)

scripts/memory_benchmark/longmemeval.py:340, scripts/populate_gaia_knowledge.py:214, scripts/populate_gaia_knowledge.py:218, tests/unit/storage/test_juicefs.py:255, tests/unit/storage/test_system_workspace.py:327, tests/unit/storage/test_system_workspace.py:331, tests/unit/storage/test_system_workspace.py:572, tests/unit/storage/test_system_workspace.py:577

PLW0108 unnecessary-lambda (14)

tests/integration/db/test_redis_cache.py:105, tests/integration/mcp/test_mcp_oauth_flow.py:1201, tests/unit/config/test_rate_limits.py:365, tests/unit/config/test_rate_limits.py:377, tests/unit/config/test_rate_limits.py:389, tests/unit/config/test_rate_limits.py:402, tests/unit/config/test_rate_limits.py:414, tests/unit/config/test_rate_limits.py:426, tests/unit/evals/test_run_lifecycle_status.py:77, tests/unit/helpers/test_namespace_utils.py:75, tests/unit/memory/test_ingestion.py:1152, tests/unit/tools/coding/test_atomic_write.py:120, tests/unit/workers/test_checkpoint_retention_tasks.py:143, tests/unit/workers/test_tracked_todo_tasks.py:402

ISC004 implicit-string-concatenation-in-collection-literal (5)

scripts/evals/core/flaky.py:135, scripts/evals/core/ingest_check.py:452, tests/unit/evals/test_refusal_judge.py:19, tests/unit/evals/test_refusal_judge.py:21, tests/unit/evals/test_refusal_judge.py:23

ASYNC250 blocking-input-in-async-function (3)

scripts/cleanup_workflows.py:81, scripts/fix_subscription_data.py:188, scripts/fix_subscription_data.py:192

FURB171 single-item-membership-test (1)

app/agents/tools/integrations/clickup_tool.py:43

Resolution plan

  1. Pin the command everywhere (done in PR referencing this issue): per-project nx/mise targets use uv run --group dev ruff … so they resolve the lockfile-pinned version; root package.json and pre-commit carry explicit pins kept in lockstep with CI.
  2. Add ruff + ruff-format hooks to pre-commit, pinned, so future drift is caught at commit time on changed files.
  3. Burn down these 67 on a dedicated branch: ~9 are safe-autofixable (--fix), ~24 more have unsafe fixes, the rest are mechanical (keyword-ify args for PLR0917 or add it to the ignore list next to PLR0913 if judged consistent with existing intent; wrap ambiguous string concats; move blocking pathlib calls off the event loop).
  4. Then bump the pin deliberately: upgrade ruff in uv.lock + CI's code-quality.yml pin + pre-commit rev in the same commit, so no surface can silently diverge again. New-rule promotions then show up as a reviewable diff, not a mystery wall of red.

Activity

0

No activity yet.