EXE rules differ from upstream
While reviewing https://github.com/astral-sh/ruff/pull/27037 and https://github.com/astral-sh/ruff/pull/27702, especially the former, I realized that our EXE rules behave pretty differently from upstream overall. For example, this code produces two diagnostics in Ruff:
hello = 1
hello #! not a shebang
and zero diagnostics with flake8-executable:
❯ uvx --with flake8-executable flake8 example.py --select EXE
❯ echo $?
0
This is because flake8-executable stops looking for shebang lines at the first instance of Python code or the first shebang-like line, rather than checking all comments in the file like we do. I looked at the PRs adding these rules (https://github.com/astral-sh/ruff/pull/2118 and https://github.com/astral-sh/ruff/pull/2023), and while there are some tests demonstrating the divergent behavior, I didn't find any discussion that indicated it was really intentional. I also found that the fix introduced in https://github.com/astral-sh/ruff/pull/2183 for end-of-line "shebang" comments was regressed in https://github.com/astral-sh/ruff/pull/6039, so we even flag those now, as shown in the example above.
I think following the upstream behavior more closely would probably be an improvement and preferable over landing either of the narrower fixes in #27037 or #27702 on their own, but we should make that decision and apply it to all of the EXE rules at once, if desired.
Source: astral-sh/ruff