pylint

R1705 (no-else-return)

Unnecessary else after return.

Used in order to highlight an unnecessary block of code following an if containing a return statement. As such, it will warn when it encounters an else following a chain of ifs, all of them containing a return statement.

:x: Incorrect code

def foo(x):
    if x:
        return 1
    else:
        return 2

:heavy_check_mark: Correct code

def foo(x):
    if x:
        return 1
    return 2

Why is this better?

<Here we will explain to the user why this is better and provide some context>

Resources