Giter Site home page Giter Site logo

xuhdev / flake8-executable Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 3.0 90 KB

A Flake8 plugin for checking executable permissions and shebangs.

Home Page: https://pypi.org/project/flake8-executable/

License: GNU Lesser General Public License v3.0

Python 99.55% Shell 0.45%

flake8-executable's Introduction

flake8-executable

Pyversions PyPI PyPI - Downloads Build Status

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.

This is a Flake8 plugin that ensures the executable permissions and shebangs of Python files are correctly set. Specifically, it checks the following errors:

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

Installation

Run:

pip install flake8-executable

Or through pre-commit with the .pre-commit-config.yaml:

repos:
-   repo: https://github.com/PyCQA/flake8
    rev: 6.0.0  # replace with the latest flake8 release
    hooks:
    -   id: flake8
        additional_dependencies:
        - flake8-executable

Usage

Normally, after flake8-executable is installed, invoking flake8 will also run this plugin. For more details, check out the Flake8 plugin page.

Copyright and License

Copyright (c) 2019 Hong Xu [email protected]

flake8-executable is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

flake8-executable is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with flake8-executable. If not, see https://www.gnu.org/licenses/.

flake8-executable's People

Contributors

dependabot[bot] avatar honkinggoose avatar renovate[bot] avatar sbrugman avatar xuhdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flake8-executable's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Check __name__ == ‘__main__’?

Thanks for the great plugin.

What do you think about adding name == main checks vs the shebang line, under a couple of new EXEnnn IDs?

  • Found name == main but no shebang
  • Found shebang but no name == main

I frequently forget both the executable bit and the shebang when writing new command line scripts, so this would help. This also encourages better modularity and easier to package the script later as a setuptools entry_point. And finally. ensuring shebang lines aren’t added when they shouldn’t be.

If you agree, I can work on a PR.

ValueError: not enough values to unpack (expected 4, got 3)

When I have it installed, I get:

multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/checker.py", line 676, in _run_checks
    return checker.run_checks()
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/checker.py", line 589, in run_checks
    self.run_ast_checks()
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/checker.py", line 494, in run_ast_checks
    for (line_number, offset, text, _) in runner:
ValueError: not enough values to unpack (expected 4, got 3)
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/math/.pyenv/versions/3.8.6/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/main/application.py", line 363, in run
    self._run(argv)
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/main/application.py", line 351, in _run
    self.run_checks()
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/main/application.py", line 264, in run_checks
    self.file_checker_manager.run()
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/checker.py", line 321, in run
    self.run_parallel()
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/site-packages/flake8/checker.py", line 287, in run_parallel
    for ret in pool_map:
  File "/home/math/.pyenv/versions/3.8.6/lib/python3.8/multiprocessing/pool.py", line 868, in next
    raise value
ValueError: not enough values to unpack (expected 4, got 3)

with Flake8 3.8.4

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/renovate-lint.yml
  • actions/checkout v3
  • actions/setup-node v3
pip_requirements
requirements-dev.txt
requirements/lint.txt
  • bandit ==1.7.4
  • flake8 ==6.0.0
  • flake8-bugbear ==21.11.29
  • flake8-comprehensions ==3.10.1
  • mypy ==0.991
requirements/test.txt
  • coverage ==7.1.0
  • pytest ==7.2.1
pip_setup
setup.py
  • flake8 >= 3.0.0
pre-commit
.pre-commit-config.yaml
  • PyCQA/flake8 6.0.0
  • pre-commit/mirrors-mypy v0.991
  • asottile/yesqa v1.4.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.