PyCharm
does not have a built-in support for flake8 at the moment. But, flake8
can be configured to run as an external tool.
Sometimes, especia
Today i Also face this problem although @alecxe answer is good for one project settings
If you want to set flake8 globally , you can follow below process
configure the path
Program - The path to the flake8 executable $PyInterpreterDirectory$ is a directory where the Python interpreter of the current project is placed
Argument- Specifies what files and folders should be checked $FilePath$
Working directory - Project root directory $ContentRoot$
I've wrote a library that offer - kind of native flake8 integration with pycharm. The library work by pretending to be a pylint executable. It accept pylint arguments and translate it to flake8 counterpart. Similarly it translate flake8 output to equivalent pylint output.
Result is native flake8 support.
https://gitlab.com/ramast/flake8-for-pycharm/
It is definitely possible.
One approach would be to adjust the flake8
output using the --format command-line option to specify http(s) links to the Flake8Rules
catalog:
--format='%(path)s:%(row)d,%(col)d:%(code)s:%(text)s:https://lintlyci.github.io/Flake8Rules/rules/%(code)s.html'
The problem then is for the console or PyCharm output window to render the links properly.
Fortunately, we can do that using the plugins - "Awesome Console" for the terminal and "Console Link" for the output window.
##Step-by-step Instructions
flake8
installed in the current Python environmentPyCharm Preferences -> Plugins -> Browser Repositories...
PyCharm Preferences -> Tools -> External Tools -> "+"
flake8
as well as $FilePath$
placeholder for the desired directory/path to be processed:
##Demo
Now, let's say we have created this test.py
file with a few violations:
def f(a = 10):
return a*10
If we right-click on a test.py
file, select External Tools -> flake8
, this is the output we are going to get (note the clickable links for every warning):
Now, whenever in doubt, we can follow the link for additional details about a warning.
This is just one way to do it, would be happy to hear if there is an easier or better way to combine these tools and projects.
To all the folks, who need:
To setup that kind of tool in Pycharm:
File | Settings | Tools | Remote SSH External Tools
see below screen for example configuration:
Arguments: -c "flake8 $(git status -s | grep -E '\.py$' | cut -c 4-) --max-line-lengt=120"
In my case the crucial thing was:
/bin/bash
instead of flake8
directly-c "whatever args subcommands etc I need here"
For reference:
$(git status -s | grep -E '\.py$' | cut -c 4-)
is responsible for passing locations of files with changes according to git version control NOTE: to have your flake8 from virtualenv you might want to specify full path like:
/z/your_virtual_envs/bin/flake8