Skip to content

chore: introduce ruff linting - #170

Draft
pnewsam wants to merge 1 commit into
stagingfrom
chore/introduce-ruff
Draft

chore: introduce ruff linting#170
pnewsam wants to merge 1 commit into
stagingfrom
chore/introduce-ruff

Conversation

@pnewsam

@pnewsam pnewsam commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What

Introduces ruff as the linter for cowork-server. The repo had no linter — this is the split-out, long-term counterpart to the hotfix in #169, which removed 3.12-only f-string syntax that crashed the server on stranded venvs. (That hotfix is now purely the source fix; the CI/lint concern lives here instead.)

Config (intentionally lean for a first adoption PR)

  • line-length = 120, target-version = "py312"
  • Ruleset: E, F, W, I, UP, C4 — high-signal and overwhelmingly auto-fixable.
  • ruff added to the dev dependency group (+ uv.lock).
  • CI: uv run ruff check cowork added to the unit-tests workflow.

Deliberately deferred to follow-ups to keep this diff reviewable:

  • The ruff formatter (would reformat ~107/156 files) and the E501 line-length that rides with it.
  • B / SIM (bugbear / simplify) — need case-by-case judgement (e.g. 87 raise ... from).
  • UP042 (str, EnumStrEnum) — a behavior-adjacent migration worth its own review.

Fixes applied

  • 219 auto-fixed: unused imports (F401), import sorting (I001), pyupgrade modernizations (datetime.UTC, PEP 604 unions/optionals, deprecated imports).
  • 10 fixed by hand: dict() → literal, ambiguous lln, aligned if x: return split, trailing whitespace, an unused local + its now-dead import.
  • One .where(ScheduleRun.is_manual == False) was a SQLModel filter — rewritten to .is_(False) (the SQL-correct form) rather than ruff's not ... suggestion, which would have evaluated in Python and broken the query.

Verification

  • ruff check coworkAll checks passed
  • make test/unit318 passed

🤖 Generated with Claude Code

Establishes ruff as the linter for cowork-server (the repo had no linter).

- pyproject: line-length 120, target py312, starter ruleset E/F/W/I/UP/C4.
  Deferred to follow-ups (kept out of this PR to bound the diff): the ruff
  formatter + E501 line-length, B/SIM rules needing manual judgement, and
  UP042 (str+Enum → StrEnum).
- Add ruff to the dev dependency group + uv.lock.
- CI: run `ruff check` in the unit-tests workflow.
- Apply the resulting fixes: 219 auto-fixed (unused imports, import sorting,
  pyupgrade modernizations) + 10 fixed by hand. Notably the one `== False`
  was a SQLModel filter, rewritten to `.is_(False)` rather than ruff's `not`
  suggestion (which would break the SQL).

All 318 unit tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@entelligence-ai-pr-reviews

Copy link
Copy Markdown

Automatic Review Skipped

Too many files for automatic review.

If you would still like a review, you can trigger one manually by commenting:

@entelligence review

@pnewsam

pnewsam commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@Entelligence review

@pnewsam
pnewsam marked this pull request as draft July 7, 2026 23:45
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