Skip to content
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

Implement flake8-executable #2024

Closed
5 tasks done
sbrugman opened this issue Jan 20, 2023 · 2 comments
Closed
5 tasks done

Implement flake8-executable #2024

sbrugman opened this issue Jan 20, 2023 · 2 comments
Labels
plugin Implementing a known but unsupported plugin

Comments

@sbrugman
Copy link
Contributor

sbrugman commented Jan 20, 2023

  • EXE001: Shebang is present but the file is not executable.
  • EXE002: The file is executable but no shebang is present.
  • EXE003: Shebang is present but does not contain "python".
  • EXE004: There is whitespace before shebang.
  • EXE005: There are blank or comment lines before shebang.

Tracking issue for flake8-executable:

Very often, developers mess up the executable permissions and shebangs of Python files. For example,
sometimes the executable permission was accidentally granted, sometimes it is forgotten. Moreover,
this should be consistent with Top-level code environment checks.

(Plugin would already be relevant for scripts/)

@charliermarsh charliermarsh added the plugin Implementing a known but unsupported plugin label Jan 20, 2023
charliermarsh pushed a commit that referenced this issue Jan 20, 2023
Tracking issue: #2024

Implementation for EXE003, EXE004 and EXE005 of `flake8-executable` 
(shebang should contain "python", not have whitespace before, and should be on the first line)

Please take in mind that this is my first rust contribution.

The remaining EXE-rules are a combination of shebang (`lines.rs`), file permissions (`fs.rs`) and if-conditions (`ast.rs`). I was not able to find other rules that have interactions/dependencies in them. Any advice on how this can be best implemented would be very welcome.

For autofixing `EXE005`, I had in mind to _move_  the shebang line to the top op the file. This could be achieved by a combination of `Fix::insert` and `Fix::delete` (multiple fixes per diagnostic), or by implementing a dedicated `Fix::move`, or perhaps in other ways. For now I've left it out, but keen on hearing what you think would be most consistent with the package, and pointer where to start (if at all).

---
If you care about another testimonial:
`ruff` not only helps staying on top of the many excellent flake8 plugins and other Python code quality tools that are available, it also applies them at baffling speed.
(Planning to implement it soon for github.com/pandas-profiling/pandas-profiling (as largest contributor) and github.com/ing-bank/popmon.)
@edgarrmondragon
Copy link
Contributor

This can probably be closed now if EXE006 and EXE007 from xuhdev/flake8-executable#66 won't be implemented for the time being.

@charliermarsh
Copy link
Member

Good call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin Implementing a known but unsupported plugin
Projects
None yet
Development

No branches or pull requests

3 participants