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

How to configure include for pre-commit #71

Open
raianul opened this issue Feb 22, 2024 · 3 comments
Open

How to configure include for pre-commit #71

raianul opened this issue Feb 22, 2024 · 3 comments

Comments

@raianul
Copy link

raianul commented Feb 22, 2024

When I use ruff with include from my shell, its work and ignore all directory and only apply ruff to the include directory.

 ruff check --config 'include = ["core/others/"]'

But when I'm going to use include with pre-commit its not working

-   repo: https://github.com/astral-sh/ruff-pre-commit
    # Ruff version.
    rev: 'v0.2.2'
    hooks:
      - id: ruff
        include: "[core/drones/api_extern/**/*.py]"

But exclude works -

-   repo: https://github.com/astral-sh/ruff-pre-commit
    # Ruff version.
    rev: 'v0.2.2'
    hooks:
      - id: ruff
        exclude: "(core/others/)"

I'm using a ruff.toml also where exclude=[...] basing excluding list.

@peterbygrave
Copy link

I have related issue in that I think include is also ignored when it is defined in pyproject.toml or ruff.toml too.

I can confirm exclude works in .toml files.

@dhruvmanila
Copy link
Member

The include and exclude as mentioned in the PR description are part of pre-commit configuration and not Ruff. But pre-commit doesn't have any include key in that position (https://pre-commit.com/#pre-commit-configyaml---hooks), but it does have files (https://pre-commit.com/#config-files) which might be what you're looking for.

@peterbygrave
Copy link

The include and exclude as mentioned in the PR description are part of pre-commit configuration and not Ruff. But pre-commit doesn't have any include key in that position (https://pre-commit.com/#pre-commit-configyaml---hooks), but it does have files (https://pre-commit.com/#config-files) which might be what you're looking for.

Ah okay, I'll check that out. Thanks for the post 👍

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

3 participants