[flake8-executable] Allow uvx in shebang line (EXE003) (#18967)

## Summary
closes #18902 

## Test Plan
I have added a test case
This commit is contained in:
हिमांशु 2025-06-30 19:08:18 +05:30 committed by GitHub
parent db3dcd8ad6
commit d78f18cda9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 1 deletions

View file

@ -0,0 +1,2 @@
#!/usr/bin/env -S uv tool run ruff check --isolated --select EXE003
print("hello world")

View file

@ -0,0 +1,2 @@
#!/usr/bin/env -S uvx ruff check --isolated --select EXE003
print("hello world")

View file

@ -22,6 +22,8 @@ mod tests {
#[test_case(Path::new("EXE002_3.py"))]
#[test_case(Path::new("EXE003.py"))]
#[test_case(Path::new("EXE003_uv.py"))]
#[test_case(Path::new("EXE003_uv_tool.py"))]
#[test_case(Path::new("EXE003_uvx.py"))]
#[test_case(Path::new("EXE004_1.py"))]
#[test_case(Path::new("EXE004_2.py"))]
#[test_case(Path::new("EXE004_3.py"))]

View file

@ -47,7 +47,12 @@ pub(crate) fn shebang_missing_python(
shebang: &ShebangDirective,
context: &LintContext,
) {
if shebang.contains("python") || shebang.contains("pytest") || shebang.contains("uv run") {
if shebang.contains("python")
|| shebang.contains("pytest")
|| shebang.contains("uv run")
|| shebang.contains("uvx")
|| shebang.contains("uv tool run")
{
return;
}

View file

@ -0,0 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_executable/mod.rs
---

View file

@ -0,0 +1,4 @@
---
source: crates/ruff_linter/src/rules/flake8_executable/mod.rs
---