Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@CodeMan62
Copy link
Contributor

Summary

closes #18902

Test Plan

I have added a test case

@github-actions
Copy link
Contributor

github-actions bot commented Jun 26, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

if shebang.contains("python")
|| shebang.contains("pytest")
|| shebang.contains("uv run")
|| shebang.contains("uvx run")
Copy link

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.

Copy link
Contributor

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.

@CodeMan62 CodeMan62 changed the title [flake0-executables] Allow uvx run in shebang line for EXE003 [flake0-executables] Allow uvx in shebang line for EXE003 Jun 26, 2025
@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Jun 27, 2025
@@ -0,0 +1,3 @@
#!/usr/bin/env -S uvx
Copy link
Member

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)

Copy link

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. 😉

@CodeMan62 CodeMan62 requested review from MichaReiser and ntBre June 29, 2025 12:26
@CodeMan62
Copy link
Contributor Author

everything is done 👍

Copy link
Contributor

@ntBre ntBre left a 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!

@ntBre ntBre changed the title [flake0-executables] Allow uvx in shebang line for EXE003 [flake8-executable] Allow uvx in shebang line (EXE003) Jun 30, 2025
@ntBre ntBre merged commit d78f18c into astral-sh:main Jun 30, 2025
35 checks passed
iyakushev pushed a commit to iyakushev/ruff that referenced this pull request Jul 1, 2025
…sh#18967)

## Summary
closes astral-sh#18902 

## Test Plan
I have added a test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EXE003 and uvxor uv tool run

4 participants