[python] How do I disable a Pylint warning?

This is a FAQ:

4.1 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.

4.2 Is there a way to disable a message for a particular module only?

Yes, you can disable or enable (globally disabled) messages at the module level by adding the corresponding option in a comment at the top of the file:

# pylint: disable=wildcard-import, method-hidden
# pylint: enable=too-many-lines

You can disable messages by:

  • numerical ID: E1101, E1102, etc.
  • symbolic message: no-member, undefined-variable, etc.
  • the name of a group of checks. You can grab those with pylint --list-groups.
  • category of checks: C, R, W, etc.
  • all the checks with all.

See the documentation (or run pylint --list-msgs in the terminal) for the full list of Pylint's messages. The documentation also provide a nice example of how to use this feature.