Ivan Vari

A minimalist Sysop/Devops Craftsman

Running Pylint in PyCharm

I really liked the Pylint integration in Eclipse/Pydev but I have switched to PyCharm since JetBrains released CE edition. Pycharm supports PEP8 auditing “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:

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:

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

$ less Library/Preferences/PyCharm4.0/tools/CodeCompliance.xml
<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">
      <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$" />
      <option name="NAME" value="ErrorMessages" />
      <option name="DESCRIPTION" value="Creates jump links to non-compliant lines" />
      <option name="REGEXP" value="$FILE_PATH$\:$LINE$\:" />

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

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.