question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use flake8 plugins with pre-commit

See original GitHub issue

flake8 plugins are usually distributed through a standalone python package on PyPI, e.g. flake8-print flake8-docstring.

In theory, I can locate where pre-commit’s venv is and install plugin packages into that venv by myself, but it’s really hacky and hard to be deterministically done for all other teammates and CI.

Does pre-commit provide some kind of mechanism to install extra packages into the venv it creates?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

27reactions
asottilecommented, Aug 8, 2018

You’re looking for additional_dependencies.

6reactions
jnnscommented, Dec 4, 2019

Please excuse me for commenting on a closed ticket but I have a question that is related to this issue and you hopefully can clear up easily.

Right now, our flake8 version-pins that we have in requirements.txt are duplicated in .pre-commit-config.yaml (see below). How do you make sure that they’re not getting out of sync?

repos:
  - repo: https://gitlab.com/pycqa/flake8
    rev: '3.7.9'
    hooks:
    -   id: flake8
        additional_dependencies: [
            'flake8-bugbear==19.8.0',
            'flake8-coding==1.3.2',
            'flake8-comprehensions==3.0.1',
            'flake8-debugger==3.2.1',
            'flake8-deprecated==1.3',
            'flake8-docstrings==1.5.0',
            'flake8-isort==2.7.0',
            'flake8-pep3101==1.2.1',
            'flake8-polyfill==1.0.2',
            'flake8-print==3.1.4',
            'flake8-quotes==2.1.1',
            'flake8-string-format==0.2.3',
        ]
  - repo: https://github.com/python/black
    rev: 19.10b0
    hooks:
      - id: black
        language_version: python3.7

A perhaps more elegant solution could be to use a repository local hook. That way, no additional_dependencies need to be specified. The problem with this approach is that I’d need to hardcode the path to the projects virtualenv into .pre-commit-config.yaml and this path is not necessarily the same on my colleagues computers.

Is there an easy solution to this that i’m overlooking?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Version Control Hooks — flake8 6.0.0 documentation
pre-commit creates an isolated environment for hooks. To use ; flake8 plugins, use the ; additional_dependencies setting.
Read more >
Correctly using pre-commit with flake8 plugins - Stack Overflow
Running it from local , the versions of the plugins are managed by poetry, and can be easily modified in pyproject.toml while locking...
Read more >
Automate Python workflow using pre-commits: black and flake8
The pre-commit Python framework · Install pre-commit: pip install pre-commit · Add pre-commit to requirements.txt (or requirements-dev.txt ) ...
Read more >
Automated linting with flake8 and pre-commit hooks
Using a pre-commit Git hook is an excellent way of maintaining ... e.g. through a vim plugin, or a Git pre-commit hook, checking...
Read more >
How to setup your project with pre-commit, black, and flake8
Now that we have the proper files in place we can start using pre-commit to run black and flake8 git hooks. Create a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found