Skip to content

Fix ruff formatting in CI and replace isort in CI with ruff#477

Merged
fishcrap merged 5 commits intomainfrom
fw/fix-ruff
Oct 23, 2025
Merged

Fix ruff formatting in CI and replace isort in CI with ruff#477
fishcrap merged 5 commits intomainfrom
fw/fix-ruff

Conversation

@garrett4wade
Copy link
Collaborator

Description

ruff and isort have annoying conflicts. We'd like to transit to the modern ruff package anyways, so we decide to totally remove the usage of isort and use ruff instead.

We will also remove black and autoflake gradually in the future.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not
    work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with
    jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

Breaking Change Details (if applicable):

N/A

Additional Context

N/A

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @garrett4wade, 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 code formatting and linting by fully embracing ruff and phasing out isort. The change addresses existing conflicts between the two tools, configures ruff to handle import sorting, and applies its checks to relevant code sections. This move aims to simplify the development workflow and pave the way for further consolidation of formatting utilities in the future.

Highlights

  • Transition to Ruff for Import Sorting: The project is transitioning from isort to ruff for managing import order, resolving conflicts between the two tools and modernizing the formatting stack.
  • Ruff Configuration Updates: The pyproject.toml file has been updated to configure ruff's isort functionality, including defining areal as a first-party section and setting a custom import section order. Additionally, the E501 (line too long) rule has been added to ruff's ignore list.
  • Pre-commit Hook Scope Adjustment: The ruff linting and formatting pre-commit hooks have been updated to specifically target files within the areal/ and examples/ directories, ensuring focused application of these checks.
  • Code Refactoring for Formatting Compliance: Minor refactoring has been applied to Python files, primarily involving import reordering and type hint adjustments, to align with the new ruff formatting rules.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/format-check.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.

Copy link
Contributor

@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 transitions from isort to ruff for import sorting and formatting, which is a great move towards modern tooling. However, the scope of this PR seems larger than described. It also includes a significant refactoring to decouple the areal package from realhf, which has led to some code duplication (e.g., logging.py, name_resolve.py). It would be beneficial to update the PR description to reflect these architectural changes for better clarity and to facilitate a more focused review. My review includes feedback on both the tooling changes and the refactoring. Additionally, since isort is being replaced by ruff, consider removing the legacy [tool.isort] configuration from pyproject.toml to avoid confusion.

@fishcrap fishcrap merged commit 4a4abc6 into main Oct 23, 2025
1 of 4 checks passed
@fishcrap fishcrap deleted the fw/fix-ruff branch October 23, 2025 05:28
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.

2 participants