0

I am using a .pylintrc in my project root directory to control the PyLint messages I get when I run it on my project.

There are many options in pylintrc that take a comma separated list of values. For example:

[MASTER]

disable=relative-import,invalid-name,missing-docstring

In my actual pylintrc, this list of values can be quite long. Is there a way to specify such values, one on each line?

This did not work:

disable=relative-import,\
invalid-name,\
missing-docstring

This did not work either:

disable=relative-import
disable+=invalid-name
disable+=missing-docstring
Ashwin Nanjappa
  • 76,204
  • 83
  • 211
  • 292

2 Answers2

3

To specify a disable across several lines, use the following:

disable=relative-import,
    invalid-name,
    missing-docstring

That is:

  • no continuation character \; and
  • indent the subsequent lines.
donkopotamus
  • 22,114
  • 2
  • 48
  • 60
  • This is standard python [`configparser`](https://docs.python.org/3.6/library/configparser.html) format which uses [RFC822 style](https://tools.ietf.org/html/rfc822.html#section-3.1.1) `field: field-body` format – donkopotamus Oct 04 '17 at 23:07
-1

Em, you can add your config line by line, I'm use it in my project.

pylint explain the keyword disable as:

# Disable the message, report, category or checker with the given id(s). You
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"

if you can disable others, for example, im my project, pylint give me this informations,

C0116: Missing function or method docstring (missing-function-docstring)
R0201: Method could be a function (no-self-use)
R1705: Unnecessary "elif" after "return" (no-else-return)

but i want ignore three message, so i add them in disable tags, like this

disable=unnecessary-lambda,
        no-else-return,
        too-many-branches

then pylint dont't report hte three message

libin
  • 420
  • 3
  • 7