-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add a include
parameter to allow expanding scope of included files
#3410
Comments
We typically require that those files are passed-in explicitly -- e.g., if you do I think this is consistent with Black's behavior (running |
I see! I absolutely agree that the default behavior is good. However, Black can be configured to include these extra files:
Something like that I would wish for :) (Black will check |
Oh interesting, so that's the file list that's used if you execute |
Ruff is a great tool, by the way! Need to remind myself to also give positive feedback, not only report bugs/wish for features 😇 |
Or does |
Oh heh thank you! |
I can also just look at the Black docs to answer those questions. I agree it could make sense to support something like that. |
|
Ahhh I see, ok. Lemme think on that. (So our |
Black's default seems to be |
include
parameter to allow expanding scope of included files
(We also ignore files in |
Ah, I just noticed your example was a glob pattern, mine was a regex (because Black uses a regex here). Probably something to think about a bit. |
This feature would be appreciated! We have some custom file extensions (which are a subset of Python) in a large monorepo. In order to pass them into |
😅 😅 😅 Will try to get to this soon. |
Yeah, I just wanted to mention it, because Black's behavior seems to be:
|
In view of #2192, would it be useful for this feature to distinguish between, "I want you to check all files matching this pattern" and "I'm throwing the kitchen sink at you here, and I only want you to check all files matching this pattern which also have a #! python"? Then (assuming a regex-y syntax) someone might say:
Which means, "check all .py files, all .pyi files, and all files that contain shebangs" Or:
which means, "check all .py files, all .pyi files, and all files with no file extension that contain shebangs". |
The first version of this will go out in the next release -- e.g., you can do: [tool.ruff]
extend-include = ["*.pyw"] ...to include |
Oh, this is incredible! By the way, my usecase is that I only want to run Ruff on manual Django migrations, not auto-generated ones. We have a convention that they are always named EDIT: Hmm, it doesn't seem to work the way I expected EDIT2: I made it work with just |
Nice! I think it probably didn't work as you'd expected because we do exclusions first, then inclusions, similar to Black (#3914 (comment)). |
Update: It... sometimes works? I can't actually figure out what the logic is. EDIT: Okay, I figured it out. |
Shouldn't that actually make it behave the way I want? I want to first exclude the entire directory, then selectively include a few files from that directory. |
@tylerlaprade - The way to think of it is: first, we iterate over all directories and files, removing any that match |
Ruff 0.0.254 seems to ignore Python scripts that do not end in
.py
. Is there an option to include them in the configuration?The text was updated successfully, but these errors were encountered: