With pylint, I know that R1705 warning gets triggered when you put a 'return' inside an 'else'.
This is the warning:
R1705: Unnecessary "else" after "return" (no-else-return)
This is what the docs says about it:
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.
A snippet of code that will trigger R1705:
if CONDITION1:
return something1
else:
return something2
The desired fix to shut down the warning:
if CONDITION1:
return something1
return something2
Is it really needed to obey this? What's the benefit? I mean I understand that after returning something from a function there is no way to come back and read further code.
But I find it way more organized to use 'else'.