Search code examples
pythonflake8

How to make flake8 fail if a plugin is not installed?


I use flake8 + flake8-docstrings for enforcing the style guide in one of my projects. My pre-commit git hook has this line in it, so that it fails if flake8 finds something:

flake8 --config=setup.cfg ./ || exit 1

But if my code has errors in docstring formatting and flake8-docstrings is not installed, this hook silently passes, even if I specify --select=flake8-docstrings or --select=non-existing-plugin.

I've read --help, man, online docs and Google, it looks like such functionality doesn't exist.

Am I correct? Should I post a feature request? Does it make sense to add cludges to my pre-commit script, such as greping flake8 --help for flake8-docstrings?


Solution

  • currently there is no such feature -- but in flake8 5.x (the next released version) there will be a (name pending) --require-plugins option

    your best bet at the moment is to either (1) search pip freeze for flake8-docstrings (2) search flake8's --version output for flake8-docstrings

    $ pip freeze | grep flake8-docstrings
    flake8-docstrings==1.6.0
    $ flake8 --version | grep flake8-docstrings
    4.0.1 (flake8-docstrings: 1.6.0, pydocstyle: 6.1.1, mccabe: 0.6.1,
    

    disclaimer: I'm the current flake8 maintainer