21

I use PyCharm to write code and I also have CI server configured to run PyLint on every PR. The problem is PyCharm and PyLint use different comments for warning suppression:

# noinspection PyMethodMayBeStatic
# pylint: disable=no-self-use

I don't like having two comments for both PyCharm and PyLint. Is there a way to configure PyLint to understand PyCharm comments or to configure PyCharm to understand PyLint comments?

Zelta
  • 754
  • 5
  • 14
  • I might have misunderstood, but why do you need do disable inspection per line? why not change the configuration globally using `.pylintrc`? – Daniel Dror Sep 14 '17 at 06:20
  • 1
    Because sometimes those inspections make sense and sometimes they don't. I don't want to miss bugs because I had to globally disable something. – Zelta Sep 14 '17 at 14:16
  • I know that I'm not answering you, and it may just be my opinion, but you really should reconsider. have rules that only apply sometimes can be confusing. strict rules are better for long-term maintenance.. – Daniel Dror Sep 14 '17 at 14:25
  • @DanielDubovski A rule that makes sense 99% of the time may not make sense 1% of the time. Remember PEP20: *"Special cases aren't special enough to break the rules. Although practicality beats purity."* – C14L Sep 14 '17 at 17:11

2 Answers2

6

Is there a way to configure PyLint to understand PyCharm comments or to configure PyCharm to understand PyLint comments?

No. At least not currently that i am aware of. You could always write something, although i believe there is a simpler option.

I am looking for a way to make PyCharm understand the PyLint syntax, that is comments like # pylint: disable=unused-argument to supress specific linter warnings.

Rather than make "PyCharm understand the PyLint syntax" Why not integrate PyLint with PyCharm:

Within PyCharm:

    Navigate to the preferences window
    Select “External Tools”
    Click the plus sign at the bottom of the dialog to add a new external task
    In the dialog, populate the following fields:
    Name:   Pylint
    Description:    A Python source code analyzer which looks for programming errors, helps enforcing a coding standard and sniffs for some code smells.
    Synchronize files after execution:
        unchecked
    Program:    /path/to/pylint
    Parameters: $FilePath$
    Click OK

The option to check the current file with Pylint should now be available in Tools > External Tools > Pylint.

Then in disable the PyCharm specific warnings in PyCharm. Now you only need to use the PyLint warnings. I realise this isn't exactly what you wanted but i hope it helps. It works for me atleast. The nice thing about using only PyLint warnings is that sharing the code with people who use other editors is simpler.

axwr
  • 2,118
  • 1
  • 16
  • 29
0

There is a pylint plugin for PyCharm:

File => Settings => Plugins => search for "pylint" and install

https://github.com/leinardi/pylint-pycharm

=> Maybe use that plugin and disable the duplicate PyCharm Inspections?

Stefan
  • 10,010
  • 7
  • 61
  • 117