diff options
author | hippo91 <guillaume.peillex@gmail.com> | 2021-04-08 11:18:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-08 11:18:21 +0200 |
commit | 5540bd45fcfd3db7ddb9a1b952bd5d327f49c84b (patch) | |
tree | ece481fbaf6475062e4302397d0be9024e0c6501 /tests | |
parent | db9b7cbfd131404be19002c5e6d1e143d73832d1 (diff) | |
download | pylint-git-5540bd45fcfd3db7ddb9a1b952bd5d327f49c84b.tar.gz |
Bug pylint 4019 (#4311)
* Detects an `assert False` and consider it as a return node
* Test the detection of `assert False`
* Adds an entry
* Takes into account @cdce8p and @Pierre-Sassoulas remarks
* Formatting
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functional/i/inconsistent/inconsistent_returns.py | 19 | ||||
-rw-r--r-- | tests/functional/i/inconsistent/inconsistent_returns.txt | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/functional/i/inconsistent/inconsistent_returns.py b/tests/functional/i/inconsistent/inconsistent_returns.py index a1782979c..cc8458e6a 100644 --- a/tests/functional/i/inconsistent/inconsistent_returns.py +++ b/tests/functional/i/inconsistent/inconsistent_returns.py @@ -387,3 +387,22 @@ def bug_pylint_4122_bis(s): return n except ValueError: parser_error_name('parser error') + + +# https://github.com/PyCQA/pylint/issues/4019 +def bug_pylint_4019(x): + """ + assert False is equivalent to a return + """ + if x == 1: + return 42 + assert False + + +def bug_pylint_4019_wrong(x): # [inconsistent-return-statements] + """ + assert True is not equivalent to a return + """ + if x == 1: + return 42 + assert True diff --git a/tests/functional/i/inconsistent/inconsistent_returns.txt b/tests/functional/i/inconsistent/inconsistent_returns.txt index 74b0ea1a7..749797f91 100644 --- a/tests/functional/i/inconsistent/inconsistent_returns.txt +++ b/tests/functional/i/inconsistent/inconsistent_returns.txt @@ -15,3 +15,4 @@ inconsistent-return-statements:267:0:bug_3468:Either all return statements in a inconsistent-return-statements:277:0:bug_3468_variant:Either all return statements in a function should return an expression, or none of them should. inconsistent-return-statements:322:0:bug_pylint_3873_1:Either all return statements in a function should return an expression, or none of them should. inconsistent-return-statements:366:0:bug_pylint_4122_wrong:Either all return statements in a function should return an expression, or none of them should. +inconsistent-return-statements:402:0:bug_pylint_4019_wrong:Either all return statements in a function should return an expression, or none of them should. |