Skip to content
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

Include ruff format in pre-commit #2598

Open
andresliszt opened this issue Oct 24, 2024 · 2 comments
Open

Include ruff format in pre-commit #2598

andresliszt opened this issue Oct 24, 2024 · 2 comments

Comments

@andresliszt
Copy link
Contributor

andresliszt commented Oct 24, 2024

I noticed that ruff formatting is not being done on commits. The pre-commit.yaml file is

repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    # Ruff version.
    rev: 'v0.1.11'
    hooks:
      - id: ruff
        args: [--fix, --exit-non-zero-on-fix]

According to ruff official docs they do not support (yet: A unified command for both linting and formatting is planned) formatting and linting in a single command. Running ruff format in the source code shows several files that must be formatted.

It makes it a bit difficult to create a PR if the code formatting is out of sync with the master

@Transurgeon
Copy link
Collaborator

I am not too familiar with Ruff format, does it make changes on all the files or only those that have changes in the pre-commit? Also, feel free to open a PR for this, we would probably be happy to add this feature.

@andresliszt
Copy link
Contributor Author

andresliszt commented Oct 24, 2024

I am not too familiar with Ruff format, does it make changes on all the files or only those that have changes in the pre-commit? Also, feel free to open a PR for this, we would probably be happy to add this feature.

Happy to help with. The steps are:

  1. Add the format rule in the pre-commit
  2. The very first commit with this rule will format all the files that ruff finds that need formatting according to the rules defined in the pyproject.toml. I ran it locally and there are several python files.
  3. New commits will make formatting mandatory, done automatically by pre-commit

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

No branches or pull requests

2 participants