Is it possible to ignore one single specific line with Pylint?

Pylint message control is documented in the Pylint manual:

Is it possible to locally disable a particular message?

Yes, this feature has been added in Pylint 0.11. 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.

You can use the message code or the symbolic names.

For example,

def test():
    # Disable all the no-member violations in this function
    # pylint: disable=no-member
    ...
    # pylint: enable=no-member

apply to a specific line only:

global VAR  # pylint: disable=global-statement

or for less verbosity, disable the ONLY following line (pylint 2.10+):

# pylint: disable-next=global-statement
global VAR

Pylint's manual also has further examples.

There is a wiki that documents all Pylint messages and their codes.


import config.logging_settings # pylint: disable=W0611

That was simple and is specific for that line.

You can and should use the more readable form:

import config.logging_settings # pylint: disable=unused-import

Tags:

Python

Pylint