-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[flake8-executable] Allow uvx in shebang line (EXE003)
#18967
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
Conversation
|
| if shebang.contains("python") | ||
| || shebang.contains("pytest") | ||
| || shebang.contains("uv run") | ||
| || shebang.contains("uvx run") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run is not a command available in uvx. This should be
|| shebang.contains("uvx")and/or
|| shebang.contains("uv tool run")I'd vote for allowing both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, let's include both while we're here.
flake0-executables] Allow uvx run in shebang line for EXE003flake0-executables] Allow uvx in shebang line for EXE003
crates/ruff_linter/resources/test/fixtures/flake8_executable/EXE003_uvx.py
Show resolved
Hide resolved
| @@ -0,0 +1,3 @@ | |||
| #!/usr/bin/env -S uvx | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a more realistic example. I don't think running that script as is would work. Instead, uvx needs to be called with a tool name (see the issue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One idea for the uvx test case would be:
#!/usr/bin/env -S uvx ruff check --isolated --select EXE003
print("hello world")And for the uv tool run test case suggested above:
#!/usr/bin/env -S uv tool run ruff check --isolated --select EXE003
print("hello world")While these are not examples you would commonly see in the real world, they demonstrate the functionality involved and would run without error (after the resolution of this issue is released). They also have a good chance of being easily understood by people working on Astral projects.
Plus, who can resist the fun of a little self-referential code. 😉
|
everything is done 👍 |
ntBre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you!
flake0-executables] Allow uvx in shebang line for EXE003flake8-executable] Allow uvx in shebang line (EXE003)
…sh#18967) ## Summary closes astral-sh#18902 ## Test Plan I have added a test case
Summary
closes #18902
Test Plan
I have added a test case