Descriptive flake8 errors in PyCharm

前端 未结 4 730
太阳男子
太阳男子 2021-02-02 12:52

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

4条回答
  •  感动是毒
    2021-02-02 13:36

    To all the folks, who need:

    • run against files using a remote python interpreter with SSH
    • who want only flake8 on changed files regarding git status
    • who want to pass any other flake8 arguments without pain

    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:

    1. use /bin/bash instead of flake8 directly
    2. Filling the arguments section by -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
    • https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000610520-Remote-SSH-external-tool-run-multiple-commands-once

    NOTE: to have your flake8 from virtualenv you might want to specify full path like: /z/your_virtual_envs/bin/flake8

提交回复
热议问题