Pylint: Disable Unnecessary "else" after "return" (no-else-return) warning

Biclops picture Biclops · Jul 27, 2017 · Viewed 13.2k times · Source

I'm looking through my RC file and I can't for the life of me, find which one of these variables disables that feature.

I searched for "if", "else" and "return" and I didn't see anything. Unless I've missed it.

Thanks.

More Info

pylint 1.7.2,
astroid 1.5.3
Python 2.7.10 (default, Jul 30 2016, 18:31:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]

What I'm putting into the terminal

pylint --rcfile=.pylintrc Test.py

Test code

""" Module Docstring """

def IS_POSITIVE(number):
    """ detects positive """
    if number > 0:
        return "+++"
    else:
        return "---"


print IS_POSITIVE(3)

The print out

************* Module Test
R: 27, 4: Unnecessary "else" after "return" (no-else-return)

------------------------------------------------------------------
Your code has been rated at 8.00/10 (previous run: 8.00/10, +0.00)

Answer

PCManticore picture PCManticore · Jul 29, 2017

You should add no-else-return to the comma separated list of disabled options in the disable setting in your .pylintrc file.

Also see the Pylint docs:
http://pylint.pycqa.org/en/latest/technical_reference/features.html#messages-control-options