Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure pylint in the python source

Is it possible to disable certain pylint errors/warnings in the python source code itself ?

like image 238
doberkofler Avatar asked Sep 24 '12 20:09

doberkofler


People also ask

How do I enable Pylint in Python?

Enable linting# To enable linters, open the Command Palette (Ctrl+Shift+P) and select the Python: Select Linter command. The Select Linter command adds "python. linting. <linter>Enabled": true to your settings, where <linter> is the name of the chosen linter.

How does Pylint work in Python?

It checks for errors, enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored. Pylint can infer actual values from your code using its internal code representation (astroid). If your code is import logging as argparse , Pylint will know that argparse.


3 Answers

def foo():
    print "000000000000000000000000000000000000000000000000000000000000000000000000000"
print "111111111111111111111111111111111111111111111111111111111111111111111111111"

pylint output:

C:  2: Line too long (87/80)
C:  3: Line too long (83/80)
C:  1: Missing docstring
C:  1:foo: Black listed name "foo"
C:  1:foo: Missing docstring

Add comment "# pylint: disable=CODE", code for "Line too long" message - C0301:

def foo():
    # pylint: disable=C0301
    print "000000000000000000000000000000000000000000000000000000000000000000000000000"
print "111111111111111111111111111111111111111111111111111111111111111111111111111"

pylint output:

I:  2: Locally disabling C0301
C:  4: Line too long (83/80)
C:  1: Missing docstring
C:  1:foo: Black listed name "foo"
C:  1:foo: Missing docstring
like image 168
kalgasnik Avatar answered Oct 21 '22 16:10

kalgasnik


The #pylint: disable syntax mentionned by @kalgasnik is the correct one. You can find more information about this in the Pylint FAQ (your question is meth2)

like image 8
gurney alex Avatar answered Oct 21 '22 17:10

gurney alex


In the eclipse ide, with pydev, you can put a comment after the line of code, with the format # IGNORE:_ID_. I don't know if this also works in other programs. For example:

import something  # IGNORE:W0611
like image 5
BrtH Avatar answered Oct 21 '22 16:10

BrtH