Skip to content

chore: add ruff lint gate (bless one-liner house style, fix imports) - #11

Merged
yakimoto merged 1 commit into
mainfrom
chore/add-ruff-gate
Jun 6, 2026
Merged

chore: add ruff lint gate (bless one-liner house style, fix imports)#11
yakimoto merged 1 commit into
mainfrom
chore/add-ruff-gate

Conversation

@yakimoto

@yakimoto yakimoto commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

What

Adds a green ruff lint gate to the published Python SDK, over the existing
E/F/I/N/W/UP/B/C4/SIM rule set. Goes from 662 findings → 0 without neutering
the ruleset.

How

pyproject.toml (migrated to the modern [tool.ruff.lint] table):

  • Ignore E701/E702 (584 findings) — the SDK deliberately uses a compressed
    one-liner / multiple-statements-per-line house style. Blessed, not "fixed".
  • [tool.ruff.lint.per-file-ignores] F401 for:
    • 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):

  • I001 import sorting across the package + 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
    (never referenced).
  • UP045 (X | None), SIM103 (return condition directly), SIM105
    (contextlib.suppress) — trivially-correct mechanical rewrites. The
    realtime.close() # pragma: no cover comment was preserved.

.github/workflows/python-lint.yml: pinned actions/checkout +
actions/setup-python (commit SHAs), permissions: contents: read,
concurrency-cancel, 10m timeout, pip install ruffruff check.

ruff check exits 0 with the full meaningful rule set intact.

Do not merge — opened for review.

🤖 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 runs ruff check on push/PR to main, with pinned actions, read-only permissions, and concurrency cancel.

Updates pyproject.toml to use [tool.ruff.lint], keeps the existing rule set, and documents intentional ignores: E701/E702 for the SDK’s one-liner style, F401 on wave/__init__.py and tests/test_sdk_exports.py for re-exports and export tests.

Across the wave package and tests, applies safe autofix-style changes only: import sorting (stdlib / third-party / local), removal of an unused import in wave/client.py, Optional[X]X | None, minor SIM simplifications (e.g. retryable check, contextlib.suppress in realtime.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 ruff lint 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 ignoring E701/E702 without weakening other checks.

  • New Features

    • Add .github/workflows/python-lint.yml to run ruff check on push/PR.
    • Pin actions/checkout and actions/setup-python, enable concurrency cancel, 10m timeout.
    • Install ruff in the job and run the linter.
  • Refactors

    • Migrate pyproject.toml to the modern [tool.ruff.lint] table and keep the existing E/F/I/N/W/UP/B/C4/SIM rule set.
    • Add per-file F401 ignores for wave/__init__.py and tests/test_sdk_exports.py.
    • Apply safe fixes: sort imports, remove an unused urllib.parse.urlencode in wave/client.py, and trivial rewrites (UP045, SIM103, SIM105), preserving # pragma: no cover in realtime.
    • Result: ruff check exits 0.

Written for commit 0b56618. Summary will update on new commits.

Review in cubic

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>
@changeset-bot

changeset-bot Bot commented Jun 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0b56618

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@yakimoto, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: da16bfb6-057e-4c17-b759-f5b8a0963f03

📥 Commits

Reviewing files that changed from the base of the PR and between 39709cc and 0b56618.

📒 Files selected for processing (42)
  • .github/workflows/python-lint.yml
  • pyproject.toml
  • tests/test_sdk_exports.py
  • wave/__init__.py
  • wave/agents.py
  • wave/audience.py
  • wave/captions.py
  • wave/chapters.py
  • wave/client.py
  • wave/clips.py
  • wave/collab.py
  • wave/connect.py
  • wave/creator.py
  • wave/desktop.py
  • wave/distribution.py
  • wave/drm.py
  • wave/edge.py
  • wave/editor.py
  • wave/fleet.py
  • wave/ghost.py
  • wave/marketplace.py
  • wave/mesh.py
  • wave/notifications.py
  • wave/phone.py
  • wave/pipeline.py
  • wave/podcast.py
  • wave/prism.py
  • wave/pulse.py
  • wave/qr.py
  • wave/realtime.py
  • wave/scene.py
  • wave/search.py
  • wave/sentiment.py
  • wave/signage.py
  • wave/slides.py
  • wave/studio.py
  • wave/studio_ai.py
  • wave/transcribe.py
  • wave/usb.py
  • wave/vault.py
  • wave/voice.py
  • wave/zoom.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/add-ruff-gate
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch chore/add-ruff-gate

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml installs Ruff without pinning a version, which can make the required lint gate non-deterministic and cause unrelated future CI failures.
  • wave/search.py and wave/sentiment.py both have import-order violations (I001), so CI may fail until the pydantic/wave.client ordering is corrected.
  • Pay close attention to .github/workflows/python-lint.yml, wave/search.py, and wave/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
Loading

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

@cubic-dev-ai cubic-dev-ai Bot Jun 6, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with cubic

Comment thread wave/search.py
from pydantic import BaseModel
from wave.client import WaveClient

from pydantic import BaseModel

@cubic-dev-ai cubic-dev-ai Bot Jun 6, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with cubic

Comment thread wave/sentiment.py
from pydantic import BaseModel
from wave.client import WaveClient

from pydantic import BaseModel

@cubic-dev-ai cubic-dev-ai Bot Jun 6, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with cubic

@yakimoto
yakimoto merged commit 2b6a6ee into main Jun 6, 2026
15 checks passed
@yakimoto
yakimoto deleted the chore/add-ruff-gate branch June 6, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant