Pylint: Unnecessary "else" after "return" false positive

Created on 18 Jul 2018  路  3Comments  路  Source: PyCQA/pylint

This seems to be a regression in 2.0.

Steps to reproduce

def function(val):
    if val == 1:
        return 1
    elif val == 2:
        return 2
    return 0

Current behavior

This currently raises:

pylint_bug2.py:2:4: R1705: Unnecessary "else" after "return" (no-else-return)

Obviously, I am ignoring the complaints on the docstrings.

Expected behavior

Well, the code avoids precisely the issue raised by pylint, there is no else!

pylint --version output

pylint 2.0.0
astroid 2.0.0.dev4
Python 3.6.5 (default, Apr  1 2018, 05:46:30) 
[GCC 7.3.0]

All 3 comments

dupe of #2295

Ok, and that's a feature, apparently.

Yes, that's a feature.

Was this page helpful?
0 / 5 - 0 ratings