Skip to content

[pre-commit] switch from black to ruff-format#1538

Merged
tdavidcl merged 3 commits intoShamrock-code:mainfrom
tdavidcl:patch-2026-01-11-11-37
Jan 11, 2026
Merged

[pre-commit] switch from black to ruff-format#1538
tdavidcl merged 3 commits intoShamrock-code:mainfrom
tdavidcl:patch-2026-01-11-11-37

Conversation

@tdavidcl
Copy link
Copy Markdown
Member

No description provided.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @tdavidcl, 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 setup by migrating from Black to Ruff's integrated formatter within the pre-commit configuration. The change aims to consolidate tooling, potentially improving performance and ensuring consistent code style enforcement across the codebase.

Highlights

  • Formatter Switch: The black pre-commit hook has been removed from the configuration.
  • New Formatter: A new ruff-format pre-commit hook has been introduced to handle code formatting, configured with a line length of 100 characters.
  • Ruff Hook Renaming: The log file for the existing ruff linter hook has been updated from log_precommit_ruff to log_precommit_ruff_check for better clarity and distinction from the new formatter.
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
Copy Markdown
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 switches the Python code formatter from black to ruff-format. The changes in .pre-commit-config.yaml correctly remove the black hook and add one for ruff-format. However, the current setup of the ruff and ruff-format hooks is inefficient and can lead to inconsistent formatting. I've left a detailed comment with a suggestion to improve the configuration.

Comment thread .pre-commit-config.yaml
Comment on lines +92 to +95
- id: ruff-format
args:
- --line-length=100
log_file: log_precommit_ruff_format
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

This setup has two issues:

  1. Redundant Formatting: The ruff hook runs both the linter and formatter. The ruff-format hook then runs the formatter again. This is inefficient. It's better to use id: ruff-lint for the first hook to only run the linter.

  2. Inconsistent Configuration: The ruff hook uses pyproject.toml, but ruff-format has a hardcoded --line-length=100. This can lead to conflicting formatting rules if pyproject.toml specifies a different line length.

A better approach is to use id: ruff-lint for the first hook (you will need to change this manually as it is outside the diff) and configure the ruff-format hook to use pyproject.toml for consistent settings. You should move line-length = 100 into pyproject.toml.

Here is a suggestion for the ruff-format part:

    - id: ruff-format
      args:
        - --config=pyproject.toml
      log_file: log_precommit_ruff_format

@github-actions
Copy link
Copy Markdown
Contributor

Thanks @tdavidcl for opening this PR!

You can do multiple things directly here:
1 - Comment pre-commit.ci run to run pre-commit checks.
2 - Comment pre-commit.ci autofix to apply fixes.
3 - Add label autofix.ci to fix authorship & pre-commit for every commit made.
4 - Add label light-ci to only trigger a reduced & faster version of the CI (need the full one before merge).
5 - Add label trigger-ci to create an empty commit to trigger the CI.

Once the workflow completes a message will appear displaying informations related to the run.

Also the PR gets automatically reviewed by gemini, you can:
1 - Comment /gemini review to trigger a review
2 - Comment /gemini summary for a summary
3 - Tag it using @gemini-code-assist either in the PR or in review comments on files

@github-actions
Copy link
Copy Markdown
Contributor

Workflow report

workflow report corresponding to commit eb619e4
Commiter email is 114827586+autofix-ci[bot]@users.noreply.github.com
You are using github private e-mail. This prevent proper tracing of who contributed what, please disable it (see Keep my email addresses private).
GitHub page artifact URL GitHub page artifact link (can expire)

Pre-commit check report

Pre-commit check: ✅

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for merge conflicts................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for broken symlinks................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
No-tabs checker..........................................................Passed
Tabs remover.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
ruff check...............................................................Passed
ruff format..............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed
No UTF-8 in files (except for authors)...................................Passed

Test pipeline can run.

Clang-tidy diff report

No relevant changes found.
Well done!

You should now go back to your normal life and enjoy a hopefully sunny day while waiting for the review.

Doxygen diff with main

Removed warnings : 0
New warnings : 0
Warnings count : 7662 → 7662 (0.0%)

Detailed changes :

@tdavidcl tdavidcl merged commit f80cbc4 into Shamrock-code:main Jan 11, 2026
63 of 64 checks passed
@tdavidcl tdavidcl deleted the patch-2026-01-11-11-37 branch January 11, 2026 17:35
aserhani pushed a commit to aserhani/Shamrock that referenced this pull request Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant