You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
While this might be a false positive, do note that the assert False might be stripped if you are running Python with -O, in which case an exception might be the best solution for asserting that a code path is never reached.
Sure, I'm not trying to catch AssertionError anywhere so I don't rely on the exception actually being raised, this is only a safety check in case some other bug means this line ends up being executed, as well as some sort of enforced documentation.
From static analysis point of view, this is a good way to allow the user to pass extra knowledge on the data and control flow in cases that would be almost impossible to guess for the tool. For example, I've seen assembly code generation changes with GCC when using some assert() to add properties about a value (something like unrolling a loop when the induction variable is bounded with a small enough constant or something like that).
Hello,
Steps to reproduce
Current behavior
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 likeraise RuntimeError('Unreachable')
butassert False
is a common idiom to mark unreachable paths, and should be pretty easy to match.pylint --version output
The text was updated successfully, but these errors were encountered: