Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I disable a bogus pylint warning for a multi-line string only

Tags:

python

pylint

How do I disable a bogus pylint warning for a multiline string just for that string?

The first disable works, the second (bogus warning) does not.

Edited after initial answer for a simpler example.

#!/usr/bin/env python

print 0!= 1 # pylint: disable=C0322
print {''
# pylint: disable=C0322
: '''%      
'''
# pylint: enable=C0322
}

I get

************* Module foobar
C0322:  4: Operator not preceded by a space
print {''

: '''%
     ^
like image 375
Mark Galeck Avatar asked Sep 11 '14 04:09

Mark Galeck


People also ask

How do I turn off 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.

How do I remove Pylint from a specific line?

you can ignore it by adding a comment in the format # pylint: disable=[problem-code] at the end of the line where [problem-code] is the value inside pylint(...) in the pylint message – for example, abstract-class-instantiated for the problem report listed above.

How do I get rid of invalid name Pylint?

How do I get rid of invalid name pylint? Create an empty Python file called run-tests.py. At the top of the file, add # pylint: disable=invalid-name so that pylint won't complain about the module name.

What does Pylint check for?

Pylint analyses your code without actually running it. 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).


1 Answers

you can do something like

# pylint: disable=C0322
print 0!= 1
print '''%
'''
# pylint: enable=C0322
like image 81
Peeyush Avatar answered Oct 28 '22 13:10

Peeyush