Skip to content

inconsistent-return-statements with assert False in function call #4019

Closed
@douglas-raillard-arm

Description

@douglas-raillard-arm

Hello,

Steps to reproduce

def f(x):
    if x == 1:
        return 42
    assert False

Current behavior

example.py:2:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)

Expected behavior

No error. This is pretty similar to this issue #1782, except that assert False is being used. I can currently work around with something like raise RuntimeError('Unreachable') but assert False is a common idiom to mark unreachable paths, and should be pretty easy to match.

pylint --version output

pylint 2.6.0
astroid 2.4.2
Python 3.8.7 (default, Dec 24 2020, 17:53:09) 
[GCC 10.2.0]

Metadata

Metadata

Assignees

Labels

Needs investigation 🔬A bug or crash where it's not immediately obvious what is happenning

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions