Home Running Pylint in PyCharm
Post
Cancel

Running Pylint in PyCharm

I really liked the Pylintintegration in Eclipse/Pydev but I have switched to PyCharm since JetBrains released CE edition. Pycharm supports PEP8auditing “out of the box”, but I found out lately, that it is a little “loose” on style compared to pylint. Running pylint in pycharm didn’t seem to be supported in any ways so I became curious about how I could add this functionality to my favourite IDE.

After some searching, I realised that there is not much out there about this topic. I could not accept it and went after the challenge…

Running Pylint in PyCharm

As it turned out, it is much simpler than I initially thought. First install pylint, it’s very easy, there are various ways of doing it depending on operating system, your preference, etc. so the installation is out of the scope of this guide.

Create an external tool:

Config

My pylint config is fairly simple, nearly stock standard so I simply added my customisation to the “parameters” line, but for more complex setups, I strongly recommend setting up .pylintrc in your HOME then adding your config file to the parameter line as an argument. This basically pipes your code through pylint and displays the results in the “run” console.

Configure output filter:

Filter

These will create an XML config that looks like this on OSX:

1
$ less Library/Preferences/PyCharm4.0/tools/CodeCompliance.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<toolSet name="CodeCompliance">
  <tool name="Pylint" description="External module to integrate pylint compliance checks into PyCharm" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="true" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
    <exec>
      <option name="COMMAND" value="pylint"/>
      <option name="PARAMETERS" value="--disable=W0106,W0212 --max-line-length=120 --msg-template=&quot;$FileDir$/{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}&quot; $FilePath$"/>
      <option name="WORKING_DIRECTORY" value="$FileDir$"/>
    </exec>
    <filter>
      <option name="NAME" value="ErrorMessages"/>
      <option name="DESCRIPTION" value="Creates jump links to non-compliant lines"/>
      <option name="REGEXP" value="$FILE_PATH$\:$LINE$\:"/>
    </filter>
  </tool>
</toolSet>

As the description says, this will essentially give you quick jump links to the parts of your code where the non-compliant code is.

Console

Clicking on any of the blue lines will simply navigate you to the line where the issue is, and adding keymap to this tool can improve your workflow too.

This post is licensed under CC BY 4.0 by the author.

Solving Camel ActiveMQ Clients in TCP TIME_WAIT

Dashlane vs 1Password

Comments powered by Disqus.