Skip to content

try enabling ruff in pre-commit #2142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

crcrpar
Copy link
Collaborator

@crcrpar crcrpar commented May 27, 2025

What does this PR do?

Enabling ruff in pre-commit.
Currently only black is used but

def format_python_file(file_path: str) -> str:
uses ruff if it's available.

@t-vi
Copy link
Collaborator

t-vi commented May 27, 2025

No, let's stay with black please.

@IvanYashchuk
Copy link
Collaborator

No, let's stay with black please.

Why do you prefer to use black? Ruff is a drop-in replacement but faster.

@t-vi
Copy link
Collaborator

t-vi commented May 28, 2025

Why do you prefer to use black? Ruff is a drop-in replacement but faster.

I'm all for material performance gains. But black vs. ruff saves a fraction of the 35 seconds all tests in precommit take, usually run in parallel to other stuff. It's just not worth changing. Things like #2077 and #1874 and if we can disable tests #2144 will be much more impactful. I'm sure there is no shortage of other opportunities.

Copy link
Collaborator

@t-vi t-vi left a comment

Choose a reason for hiding this comment

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

Let's do it for the better good.

@crcrpar crcrpar marked this pull request as ready for review May 28, 2025 17:36
@crcrpar crcrpar requested review from mruberry and lantiga as code owners May 28, 2025 17:36
crcrpar and others added 16 commits May 30, 2025 01:17
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
@crcrpar crcrpar force-pushed the try-enable-runn-in-pre-commit branch from 55deff1 to 8c08883 Compare May 30, 2025 08:20
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
@crcrpar crcrpar force-pushed the try-enable-runn-in-pre-commit branch from f8e06fc to aba23a7 Compare May 30, 2025 08:40
Comment on lines +41 to +47
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.11
hooks:
- id: black
name: Black code
exclude: "examples"
- id: ruff-check
args: ["--fix"]
- id: ruff-format
types_or: [python, pyi]
Copy link
Member

Choose a reason for hiding this comment

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

'Let''s split the PR to adding Ruff as flake8 and formatting, so the change is easier to trace/review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants