diff --git a/src/rules/flake8_executable/helpers.rs b/src/rules/flake8_executable/helpers.rs index fa147373abe93..db47bcba38809 100644 --- a/src/rules/flake8_executable/helpers.rs +++ b/src/rules/flake8_executable/helpers.rs @@ -2,7 +2,7 @@ use once_cell::sync::Lazy; use regex::Regex; static SHEBANG_REGEX: Lazy = - Lazy::new(|| Regex::new(r"(?P\s*)#!(?P.*)").unwrap()); + Lazy::new(|| Regex::new(r"^(?P\s*)#!(?P.*)").unwrap()); #[derive(Debug)] pub enum ShebangDirective<'a> { @@ -67,7 +67,7 @@ mod tests { )); assert!(matches!( extract_shebang("print('test') #!/usr/bin/python"), - ShebangDirective::Match(2, 17, 32, "/usr/bin/python") + ShebangDirective::None )); } } diff --git a/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_3.py.snap b/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_3.py.snap index c738409c4f8e5..8874a32d9c088 100644 --- a/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_3.py.snap +++ b/src/rules/flake8_executable/snapshots/ruff__rules__flake8_executable__tests__EXE004_3.py.snap @@ -2,5 +2,14 @@ source: src/rules/flake8_executable/mod.rs expression: diagnostics --- -[] +- kind: + ShebangMissingExecutableFile: ~ + location: + row: 1 + column: 0 + end_location: + row: 1 + column: 0 + fix: ~ + parent: ~