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

Attempting to use ruff check with includes, but without specifying a directory, picks up nested projects #9019

Open
eli-schwartz opened this issue Dec 6, 2023 · 3 comments

Comments

@eli-schwartz
Copy link
Contributor

... such as git worktree clones.

Given a .ruff.toml with the contents:

include = ["mesonbuild/**/*.py"]
$ git worktree add -d bisect/
$ ruff check

Every possible error is listed twice, once for the mesonbuild/ directory and once for the bisect/mesonbuild/ directory.

This only seems to happen if the worktree has a .ruff.toml as well (which it will if it is tracked in git).

Using ruff check mesonbuild/ the traditional way continues to work fine.

@MichaReiser
Copy link
Member

Can you try using include = ["/mesonbuild/**/*.py"] to make it explicit, that the pattern should only match mesonbuild` directories at the root?

@charliermarsh
Copy link
Member

This sort of makes sense given that include is only applied at the file level... So we visit each file within bisect/mesonbuild, and each of those files will resolve to the configuration at bisect/mesonbuild/.ruff.toml, which says that they should be included. (I'm not saying it's the right behavior, but I can at least understand why it's happening.)

@eli-schwartz
Copy link
Contributor Author

That's actually the first thing I tried as a wild guess.

warning: No Python files found under the given path(s)

Afterwards I realized that it was conditional on the subdirectory also having a .ruff.toml, which made me rethink whether that was related at all.

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