One of my favorite things about pylint is a feature that allows to disable/enable message for a block or statement.
For instance, consider the function below:
def scan_code(co, module):
assert co and module
if DEBUG: print co.co_filename
...
The function scan_code has so many debug prints. For performance reason, however, they are if DEBUG: print statements. Now pylint would report so many messages (C: means convention, for programming standard violation).
% pylint scan_code
...
C:107:scan_code: More than one statement on a single line
C:110:scan_code: More than one statement on a single line
C:114:scan_code: More than one statement on a single line
C:117:scan_code: More than one statement on a single line
C:123:scan_code: More than one statement on a single line
You can disable these messages for scan_code function. # pylint: disable-msg=... style comment can be used everywhere in the source code and affects a block or statement.
# pylint: disable-msg=C0321
def scan_code(co, module):
assert co and module
if DEBUG: print co.co_filename
...

0 comments:
Post a Comment