chore: add ruff lint gate (bless one-liner house style, fix imports) - #11
Conversation
Adds a green ruff lint gate over the existing E/F/I/N/W/UP/B/C4/SIM rule set. Config (pyproject.toml, migrated to the modern [tool.ruff.lint] table): - Bless the SDK's intentional compressed one-liner house style by ignoring E701/E702 (584 findings) — multiple statements per line is deliberate here. - per-file-ignores F401 for wave/__init__.py (public re-export barrel) and tests/test_sdk_exports.py (imports every public symbol to assert it exists). Safe autofixes applied via `ruff check --fix`: - I001 import sorting across the package and the export test (no symbols added or removed; re-export order is cosmetic, __all__ is the contract). - Removed a genuinely-dead `urllib.parse.urlencode` import in wave/client.py. - UP045 (X | None), SIM103 (return condition directly), SIM105 (contextlib.suppress) — trivially-correct mechanical rewrites; the realtime.close() pragma:no-cover comment was preserved. Workflow (.github/workflows/python-lint.yml): pinned checkout + setup-python, permissions contents:read, concurrency cancel, 10m timeout, runs ruff check. ruff check now exits 0 with the full meaningful rule set intact. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
Warning Review limit reached
More reviews will be available in 2 minutes and 30 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (42)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
3 issues found across 42 files
Confidence score: 4/5
- This PR looks safe to merge overall: the reported issues are mainly CI/lint stability concerns rather than runtime behavior regressions in application logic.
- Most severe:
.github/workflows/python-lint.ymlinstalls Ruff without pinning a version, which can make the required lint gate non-deterministic and cause unrelated future CI failures. wave/search.pyandwave/sentiment.pyboth have import-order violations (I001), so CI may fail until thepydantic/wave.clientordering is corrected.- Pay close attention to
.github/workflows/python-lint.yml,wave/search.py, andwave/sentiment.py- pin Ruff for reproducible CI and fix import ordering to avoid lint gate failures.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="wave/search.py">
<violation number="1" location="wave/search.py:8">
P3: Import groups are ordered incorrectly (`wave.client` before `pydantic`), which violates Ruff `I001` and can fail CI linting.</violation>
</file>
<file name="wave/sentiment.py">
<violation number="1" location="wave/sentiment.py:8">
P3: Import ordering is reversed (`wave.client` before `pydantic`), causing a Ruff `I001` lint violation.</violation>
</file>
<file name=".github/workflows/python-lint.yml">
<violation number="1" location=".github/workflows/python-lint.yml:30">
P2: The lint workflow installs Ruff without a pinned version, making the required CI gate non-deterministic and prone to unrelated future breakages.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Dev as Developer
participant GH as GitHub Actions
participant Ruff as ruff
participant SDK as wave package
participant Tests as test suite
Note over Dev,Tests: PR: Add ruff lint gate (lint-only, no runtime change)
Dev->>GH: push/PR to main
GH->>GH: concurrency cancel (same ref)
GH->>GH: permissions: contents: read
GH-->>GH: timeout: 10 minutes
GH->>Ruff: pip install ruff
alt All files checked
Ruff->>Ruff: Parse pyproject.toml
Note over Ruff: [tool.ruff.lint] select = [E,F,I,N,W,UP,B,C4,SIM]
Note over Ruff: ignore = [E501, E701, E702]
Note over Ruff: per-file-ignores: wave/__init__.py, tests/test_sdk_exports.py → F401
else Rule E701/E702 hit
Note over Ruff: SDK one-liner style → BLESSED (ignored)
Ruff-->>Ruff: skip finding
else Rule F401 hit in barrel/exports
Note over Ruff: Public re-exports + export validation → BLESSED (ignored)
Ruff-->>Ruff: skip finding
else All other rules
Ruff->>SDK: check wave/__init__.py (import sorting only)
Ruff->>SDK: check wave/agents.py (Optional[X] → X | None)
Ruff->>SDK: check wave/client.py (remove unused urlencode, retry simplification)
Ruff->>SDK: check wave/realtime.py (SIM105: contextlib.suppress)
Ruff->>SDK: check all module files (import sorting)
Ruff->>Tests: check test_sdk_exports.py (import sorting)
end
alt All checks pass
Ruff-->>GH: exit 0
GH-->>GH: success
Note over Dev,Tests: No runtime boundary crossed
Note over SDK: Only import ordering, type annotation, & dead-code changes
Note over Tests: No behavioral test change
else Any check fails
Ruff-->>GH: exit non-zero
GH-->>GH: failure (block PR merge)
end
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| with: | ||
| python-version: "3.12" | ||
| - name: Install ruff | ||
| run: pip install ruff |
There was a problem hiding this comment.
P2: The lint workflow installs Ruff without a pinned version, making the required CI gate non-deterministic and prone to unrelated future breakages.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/python-lint.yml, line 30:
<comment>The lint workflow installs Ruff without a pinned version, making the required CI gate non-deterministic and prone to unrelated future breakages.</comment>
<file context>
@@ -0,0 +1,32 @@
+ with:
+ python-version: "3.12"
+ - name: Install ruff
+ run: pip install ruff
+ - name: Ruff check
+ run: ruff check
</file context>
| from pydantic import BaseModel | ||
| from wave.client import WaveClient | ||
|
|
||
| from pydantic import BaseModel |
There was a problem hiding this comment.
P3: Import groups are ordered incorrectly (wave.client before pydantic), which violates Ruff I001 and can fail CI linting.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wave/search.py, line 8:
<comment>Import groups are ordered incorrectly (`wave.client` before `pydantic`), which violates Ruff `I001` and can fail CI linting.</comment>
<file context>
@@ -1,10 +1,13 @@
-from pydantic import BaseModel
from wave.client import WaveClient
+from pydantic import BaseModel
+
+
</file context>
| from pydantic import BaseModel | ||
| from wave.client import WaveClient | ||
|
|
||
| from pydantic import BaseModel |
There was a problem hiding this comment.
P3: Import ordering is reversed (wave.client before pydantic), causing a Ruff I001 lint violation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At wave/sentiment.py, line 8:
<comment>Import ordering is reversed (`wave.client` before `pydantic`), causing a Ruff `I001` lint violation.</comment>
<file context>
@@ -1,10 +1,13 @@
-from pydantic import BaseModel
from wave.client import WaveClient
+from pydantic import BaseModel
+
+
</file context>
What
Adds a green ruff lint gate to the published Python SDK, over the existing
E/F/I/N/W/UP/B/C4/SIMrule set. Goes from 662 findings → 0 without neuteringthe ruleset.
How
pyproject.toml(migrated to the modern[tool.ruff.lint]table):E701/E702(584 findings) — the SDK deliberately uses a compressedone-liner / multiple-statements-per-line house style. Blessed, not "fixed".
[tool.ruff.lint.per-file-ignores]F401for:wave/__init__.py— public re-export barrel.tests/test_sdk_exports.py— imports every public symbol to assert it exists(verified via
__all__/hasattr), so the names are intentionally "unused".Safe autofixes (
ruff check --fix):I001import sorting across the package + the export test. No symbols added orremoved; re-export order is cosmetic (
__all__is the contract).urllib.parse.urlencodeimport inwave/client.py(never referenced).
UP045(X | None),SIM103(return condition directly),SIM105(
contextlib.suppress) — trivially-correct mechanical rewrites. Therealtime.close()# pragma: no covercomment was preserved..github/workflows/python-lint.yml: pinnedactions/checkout+actions/setup-python(commit SHAs),permissions: contents: read,concurrency-cancel, 10m timeout,
pip install ruff→ruff check.ruff checkexits 0 with the full meaningful rule set intact.🤖 Generated with Claude Code
Note
Low Risk
Changes are lint config, CI, and stylistic/mechanical code edits with no intended behavior changes to the HTTP client or API surface.
Overview
Adds a GitHub Actions workflow (
.github/workflows/python-lint.yml) that runsruff checkon push/PR tomain, with pinned actions, read-only permissions, and concurrency cancel.Updates
pyproject.tomlto use[tool.ruff.lint], keeps the existing rule set, and documents intentional ignores:E701/E702for the SDK’s one-liner style,F401onwave/__init__.pyandtests/test_sdk_exports.pyfor re-exports and export tests.Across the
wavepackage and tests, applies safe autofix-style changes only: import sorting (stdlib / third-party / local), removal of an unused import inwave/client.py,Optional[X]→X | None, minor SIM simplifications (e.g. retryable check,contextlib.suppressinrealtime.close()), and alphabetized imports in the export test. No API or runtime behavior changes are intended beyond those mechanical edits.Reviewed by Cursor Bugbot for commit 0b56618. Configure here.
Summary by cubic
Add a
rufflint gate to CI and clean up imports and minor nits so the SDK passes the selected rules. Bless the SDK’s one-liner style by ignoringE701/E702without weakening other checks.New Features
.github/workflows/python-lint.ymlto runruff checkon push/PR.actions/checkoutandactions/setup-python, enable concurrency cancel, 10m timeout.ruffin the job and run the linter.Refactors
pyproject.tomlto the modern[tool.ruff.lint]table and keep the existingE/F/I/N/W/UP/B/C4/SIMrule set.F401ignores forwave/__init__.pyandtests/test_sdk_exports.py.urllib.parse.urlencodeinwave/client.py, and trivial rewrites (UP045,SIM103,SIM105), preserving# pragma: no coverin realtime.ruff checkexits 0.Written for commit 0b56618. Summary will update on new commits.