Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress warning for both pycharm and pylint

Tags:

pycharm

pylint

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?

like image 572
Zelta Avatar asked Feb 01 '17 12:02

Zelta


People also ask

How do I turn off PyCharm warnings?

Disable inspections In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | Inspections. Locate the inspection you want to disable, and clear the checkbox next to it. Apply the changes and close the dialog.

How do I disable pylint warnings?

This may be done by adding # pylint: disable=some-message,another-one at the desired block level or at the end of the desired line of code.

Does PyCharm use pylint?

pylint is a code analyzer tool that checks your code and detects any style, logic, and usage problems. It might be a great addition to the code validation features available with PyCharm. Press Ctrl+Alt+S to open the IDE settings and select Project | Python Interpreter. to install a new package.

Which Linter does PyCharm use?

By default, PyCharm uses the TSLint package from the project node_modules folder and the tslint. json configuration file from the folder where the current file is stored. If no tslint. json is found in the current file folder, PyCharm will look for one in its parent folders up to the project root.


1 Answers

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.

like image 113
axwr Avatar answered Sep 22 '22 17:09

axwr