Skip to content

Conversation

@zhiyuan1i
Copy link
Collaborator

@zhiyuan1i zhiyuan1i commented Oct 15, 2025

  • Replace flake8 and isort with ruff in pre-commit configuration
  • Configure comprehensive ruff rule set including pycodestyle, Pyflakes, pyupgrade, flake8-bugbear, flake8-simplify, isort, flake8-comprehensions, flake8-type-checking, and flake8-commas
  • Enable automatic fixing with --fix and --unsafe-fixes flags
  • Update pre-commit-hooks to v6.0.0 and tj-actions/changed-files to v47.0.0
  • Configure per-file ignores for init.py and evals/harness.py
  • Set line length to 127 characters and target Python 3.10+

This change significantly improves linting performance while maintaining code quality standards.

Summary by CodeRabbit

  • Chores
    • Upgraded CI and pre-commit tooling to newer releases and streamlined hook set.
  • Tests
    • Updated CI workflow steps to use newer action versions with no behavioral changes.
  • Style
    • Switched linting/formatting to a Ruff-based configuration, adjusted rules and per-file ignores.

No user-facing changes or functional impact.

- Replace flake8 and isort with ruff in pre-commit configuration
- Configure comprehensive ruff rule set including pycodestyle, Pyflakes, pyupgrade, flake8-bugbear, flake8-simplify, isort, flake8-comprehensions, flake8-type-checking, and flake8-commas
- Enable automatic fixing with --fix and --unsafe-fixes flags
- Update pre-commit-hooks to v6.0.0 and tj-actions/changed-files to v47.0.0
- Configure per-file ignores for __init__.py and evals/harness.py
- Set line length to 127 characters and target Python 3.10+

This change significantly improves linting performance while maintaining
code quality standards.
@gemini-code-assist
Copy link

Summary of Changes

Hello @zhiyuan1i, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request streamlines the project's linting process by migrating from a multi-tool setup of flake8 and isort to the single, high-performance ruff linter. The change involves updating pre-commit configurations and pyproject.toml to leverage ruff's capabilities, including a broad range of linting rules, automatic code fixing, and specific file-based ignore settings, ultimately aiming to enhance code quality checks and developer efficiency.

Highlights

  • Linting Tool Migration: Replaced flake8 and isort with ruff in the pre-commit configuration for improved linting performance.
  • Ruff Configuration: Configured ruff with a comprehensive set of rules including pycodestyle, Pyflakes, pyupgrade, flake8-bugbear, flake8-simplify, isort, flake8-comprehensions, flake8-type-checking, and flake8-commas.
  • Automatic Fixing: Enabled automatic fixing capabilities for ruff using the --fix and --unsafe-fixes flags in the pre-commit hook.
  • Pre-commit Hooks Update: Updated the pre-commit-hooks repository revision from v5.0.0 to v6.0.0 and removed check-ast and debug-statements hooks.
  • Linting Rules and Ignores: Set the global line length to 127 characters, targeted Python 3.10+, and configured per-file ignores for __init__.py and evals/harness.py within ruff.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/lint.yaml
    • .github/workflows/reusable-ci-tests.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Bump tj-actions/changed-files to v47.0.0 in two GitHub workflows; migrate pre-commit from Flake8/isort to Ruff and update hooks in .pre-commit-config.yaml; add Ruff configuration and per-file ignores to pyproject.toml, set Python target to 3.10.

Changes

Cohort / File(s) Summary of changes
Workflows: changed-files action bump
\.github/workflows/lint.yaml, \.github/workflows/reusable-ci-tests.yml
Update tj-actions/changed-files from v46.0.5 to v47.0.0 in "Get changed files" steps; no other behavioral changes.
Pre-commit: migrate to Ruff
\.pre-commit-config.yaml
Bump pre-commit-hooks from v5.0.0 to v6.0.0; remove check-ast and debug-statements hooks; remove Flake8/isort hooks and add astral-sh/[email protected] with ruff-check args --fix, --exit-non-zero-on-fix.
Ruff configuration
pyproject.toml
Add [tool.ruff] sections (format/lint), set selects/excludes and per-file-ignores (e.g., __init__.py, evals/harness.py), set target-version = "py310", keep line-length, and remove prior isort config.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • yzhangcs

Poem

Hop-hop, I tweak the linting breeze,
Flake8 hops out, Ruff hops in with ease.
Actions bumped, the pipeline sings,
Pre-commit tidy, brighter springs.
Carrots crunchy, code neat as can be. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely summarizes the main change by indicating the migration from flake8/isort to ruff for faster linting, making it immediately obvious to reviewers what the pull request accomplishes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ruff

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the project's linting setup from flake8 and isort to ruff, which is a great move for performance. The configuration in pyproject.toml is comprehensive. However, I've found a critical issue in the .pre-commit-config.yaml that will prevent the ruff hook from running correctly. I've also suggested an improvement to maintain coverage for debug statements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
pyproject.toml (2)

56-67: Optional: broaden rule coverage (W, N, ISC, RUF).

Current set is solid. Consider adding:

  • "W" (pycodestyle warnings)
  • "N" (pep8-naming)
  • "ISC" (implicit‑str‑concat)
  • "RUF" (Ruff‑specific rules)

These catch naming issues, implicit concatenations, and Ruff best‑practices.

 select = [
     "E",    # pycodestyle
+    "W",    # pycodestyle warnings
     "F",    # Pyflakes
     "UP",   # pyupgrade
     "B",    # flake8-bugbear
     "SIM",  # flake8-simplify
     "I",    # isort
     "C4",   # flake8-comprehensions
     "TCH",  # flake8-type-checking
     "COM",  # flake8-commas
     "T",    # flake8-debugger
+    "N",    # pep8-naming
+    "ISC",  # flake8-implicit-str-concat
+    "RUF",  # Ruff-specific rules
 ]

68-74: Reassess global ignores; prefer targeted per‑file ignores.

Project‑wide "E741" and "B023" can hide real issues. Consider limiting them to files that truly need them via per‑file‑ignores.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b7609a and de8089c.

📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check-pt-python-compatibility
🔇 Additional comments (4)
pyproject.toml (4)

48-51: Ruff target and line length look consistent.

py310 aligns with requires‑python; 127 is set explicitly.


52-54: Formatter config looks good.

docstring code formatting enabled; no issues.


76-78: Per-file ignore path verified. evals/harness.py exists, so the ignore will apply.


37-39: Verify isort’s known-first-party configuration
Ensure “fla” covers all your actual top-level Python packages (e.g., modules under src/ or dirs with init.py). Add any missing entries to [tool.ruff.lint.isort].known-first-party.

@zhiyuan1i
Copy link
Collaborator Author

Merge this before proceeding to the next version. After merging this PR, nearly every file will need to be reformatted.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
.pre-commit-config.yaml (1)

14-18: Fix Ruff hook config: invalid rev and hook id; add ruff-format

Use a valid ruff-pre-commit tag and the correct hook IDs; add ruff-format. Optionally include --unsafe-fixes to match PR description.

Apply this diff:

- - repo: https://github.com/astral-sh/ruff-pre-commit
-   rev: v0.14.0
-   hooks:
-   - id: ruff-check
-     args: [--fix, --exit-non-zero-on-fix]
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+   rev: v0.5.0
+   hooks:
+   - id: ruff
+     args: [--fix, --unsafe-fixes, --exit-non-zero-on-fix]
+   - id: ruff-format
What is the latest valid tag for https://github.com/astral-sh/ruff-pre-commit and the correct hook IDs?
🧹 Nitpick comments (1)
pyproject.toml (1)

68-74: Consider revisiting E741 ignore (optional)

Ignoring ambiguous variable names (E741) can reduce code clarity. If possible, enable E741 and fix offenders over time.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de8089c and 740af87.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml (1 hunks)
  • pyproject.toml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check-pt-python-compatibility
🔇 Additional comments (5)
pyproject.toml (4)

37-39: isort integration via Ruff: good setup

known-first-party and force-sort-within-sections are reasonable defaults.


48-51: Core Ruff config LGTM

Targeting py310 and line-length 127 align with PR goals.


52-54: Docstring code formatting enabled

Nice. Be aware this can reflow fenced code in docstrings; ensure doctests/docs still pass.


55-67: Rule set selection looks solid (includes debugger rules)

Covers pycodestyle, Pyflakes, pyupgrade, bugbear, simplify, isort, comprehensions, type-checking, commas, and debugger (T). Addresses prior feedback about missing debugger checks.

.pre-commit-config.yaml (1)

3-3: pre-commit-hooks v6.0.0: OK

Comment on lines +76 to +79
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
"fla/utils.py" = ["TC004"]
"evals/harness.py" = ["I", "TCH"]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Typo in per-file ignore code: use TCH004 (not TC004)

Ruff’s flake8-type-checking codes use the TCH prefix; TC004 won’t match and the ignore won’t apply.

Apply this diff:

 [tool.ruff.lint.per-file-ignores]
 "__init__.py" = ["F401"]
-"fla/utils.py" = ["TC004"]
+"fla/utils.py" = ["TCH004"]
 "evals/harness.py" = ["I", "TCH"]
🤖 Prompt for AI Agents
In pyproject.toml around lines 76 to 79, the per-file ignore for "fla/utils.py"
uses the incorrect code "TC004"; change it to the correct Ruff
flake8-type-checking code "TCH004" so the ignore actually applies, i.e., replace
"TC004" with "TCH004" in that entry.

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