diff options
author | Arianna Y <92831762+areveny@users.noreply.github.com> | 2021-10-29 12:44:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-29 21:44:18 +0200 |
commit | 8c7e2fae6fee28944764e643e65e729a58a5473c (patch) | |
tree | 2dc743324eea667906bcafcc5a313620d40dd8c7 /pylint | |
parent | e8713873813bfab5fafb04b0fb8b5221011faa41 (diff) | |
download | pylint-git-8c7e2fae6fee28944764e643e65e729a58a5473c.tar.gz |
Fix incorrect ``consider-using-ternary`` when condition is inferable as False (#5227)
* Fix incorrect ``consider-using-ternary`` when condition is inferrable as False
* Properly infer the condition in old ternary statements and suggest ``simplify-boolean-expression`` over ``consider-using-ternary`` if it is False
Diffstat (limited to 'pylint')
-rw-r--r-- | pylint/checkers/refactoring/refactoring_checker.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py index e8e403e1b..7929d77e0 100644 --- a/pylint/checkers/refactoring/refactoring_checker.py +++ b/pylint/checkers/refactoring/refactoring_checker.py @@ -1393,10 +1393,10 @@ class RefactoringChecker(checkers.BaseTokenChecker): return inferred_truth_value = utils.safe_infer(truth_value) - if inferred_truth_value in (None, astroid.Uninferable): + if inferred_truth_value is None or inferred_truth_value == astroid.Uninferable: truth_boolean_value = True else: - truth_boolean_value = truth_value.bool_value() + truth_boolean_value = inferred_truth_value.bool_value() if truth_boolean_value is False: message = "simplify-boolean-expression" |