Skip to content

ci: add Ruff lint rules, pre-commit hooks, and lint job to CI#403

Open
korbonits wants to merge 1 commit intogoogle-research:masterfrom
korbonits:ci/ruff-lint-and-precommit
Open

ci: add Ruff lint rules, pre-commit hooks, and lint job to CI#403
korbonits wants to merge 1 commit intogoogle-research:masterfrom
korbonits:ci/ruff-lint-and-precommit

Conversation

@korbonits
Copy link
Copy Markdown

Summary

  • Add [tool.ruff.lint] to pyproject.toml — the [tool.ruff] section existed with formatting config only (line length, indent width); this PR adds actual lint rules
  • Ignore F722/F821 globally: these are false positives from jaxtyping annotations (Float[Array, "b n h d"] etc.) throughout the flax/ modules
  • Add .pre-commit-config.yaml with Ruff lint + format hooks
  • Add a lint job to .github/workflows/main.yml using astral-sh/setup-uv (uv is already used in the build job)
  • Auto-fix 64 violations (unsorted imports, unused imports, f-string placeholders)

Motivation

The project already uses Ruff for formatting but has no lint rules enforced, no pre-commit hooks, and no lint step in CI. This PR completes that setup with a minimal, non-intrusive ruleset (E/F/I) that won't disrupt the existing Google 2-space indent style.

What's not included

  • No type checking — out of scope
  • No changes to existing build or manual_publish workflows
  • No new rules beyond the initial E/F/I selection

Testing

Ran ruff check . and ruff format --check . locally — all checks pass.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 12, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@korbonits korbonits force-pushed the ci/ruff-lint-and-precommit branch from 55d703b to 742f0f8 Compare April 12, 2026 20:59
The [tool.ruff] section existed with formatting config only. This PR
completes it by adding lint rules and wiring up enforcement:

- Add [tool.ruff.lint] with E/F/I rules to pyproject.toml
- Ignore F722/F821 globally (false positives from jaxtyping annotations
  such as Float[Array, "b n h d"] throughout the flax/ modules)
- Add .pre-commit-config.yaml with ruff lint + format hooks
- Add a lint job to .github/workflows/main.yml using astral-sh/setup-uv
- Auto-fix 64 violations (unsorted imports, unused imports, f-strings)
@korbonits korbonits force-pushed the ci/ruff-lint-and-precommit branch from 742f0f8 to f66960d Compare April 12, 2026 21:00
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