-
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
operate on files with certain hashbang #2192
Comments
Rather than looking for a specific shebang, maybe a configuration could be added to include certain files based on paths? |
Yeah, I'm extremely hesitant to check every file for a shebang. If you pass a file to Ruff directly, it will check it, even if it's not a |
I wouldn't use a configurable list of files as files are too often just changing by too many people. The files are tracked in git and all of them might be relevant. What's wrong with checking hashbangs? I am using it currently and it is not really making a performance issue. |
I assume it will come at a performance cost. I'd need to benchmark it. Is there a common extension on those files? (Or even: do they all have no extension?) |
I guess they all have no extension. simple scripts. |
We could consider checking non-extension files for hashbangs. |
That would be great. we have 462 python files without file extensions and 4 python files with (accidental) file extensions ( |
Another simple workaround would be to find the files separately and pass those explicitly to ruff, e.g. (with ripgrep):
|
yes, this is kind of my current workaround. |
This workaround would also be needed in a pre-commit hook, where I did not yet find out how to achieve it. |
ok, |
This could also be solved by #3410, sort of, though you'd have to enumerate them explicitly. |
For me, it would suffice to include them explicitly and I agree that performance could suffer if ruff would read every file to search for the bang. (Using the term "include" here, because the include option is how you can do it with Black.) |
hm, #3914 closed it but this allows only files with a specific extension. our files/scripts don't have any file extension. |
Ah yeah, the reasoning was that this now provides a manual workaround, analogous to Black's own configuration (whereby you can specify the script names in the |
ruff seems only to search for files with
.py
(maybe also `.pyi) file extensions?!it would be good to detect some certain hashbangs like:
!#/usr/bin/python
!#/usr/bin/python3
!#/usr/bin/python -b
!#/usr/bin/env python3
and it would be nice to be able to put further definitions in the config files, we e.g. have definitions like:
#!/usr/share/test/runner python3
#!/usr/share/test/runner py.test-3
The text was updated successfully, but these errors were encountered: