[pre-commit] switch from black to ruff-format#1538
[pre-commit] switch from black to ruff-format#1538tdavidcl merged 3 commits intoShamrock-code:mainfrom
Conversation
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| - id: ruff-format | ||
| args: | ||
| - --line-length=100 | ||
| log_file: log_precommit_ruff_format |
There was a problem hiding this comment.
This setup has two issues:
-
Redundant Formatting: The
ruffhook runs both the linter and formatter. Theruff-formathook then runs the formatter again. This is inefficient. It's better to useid: ruff-lintfor the first hook to only run the linter. -
Inconsistent Configuration: The
ruffhook usespyproject.toml, butruff-formathas a hardcoded--line-length=100. This can lead to conflicting formatting rules ifpyproject.tomlspecifies 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|
Thanks @tdavidcl for opening this PR! You can do multiple things directly here: Once the workflow completes a message will appear displaying informations related to the run. Also the PR gets automatically reviewed by gemini, you can: |
Workflow reportworkflow report corresponding to commit eb619e4 Pre-commit check reportPre-commit check: ✅ Test pipeline can run. Clang-tidy diff reportNo relevant changes found. You should now go back to your normal life and enjoy a hopefully sunny day while waiting for the review. Doxygen diff with
|
No description provided.