mirror of
https://fuchsia.googlesource.com/third_party/github.com/pylint-dev/pylint
synced 2024-09-19 23:21:12 +00:00
Extend test cases for 'condition-evals-to-constant' (#8721)
Related to #7933. The original issue reported pylint as missing bugs in comparisons like: `if get_text() == "string A" or "string B":` In reality this is already covered by the message 'condition-evals-to-constant', however test cases with strings were missing, they have been added to self-document other cases this checker applies to and extend coverage.
This commit is contained in:
parent
c5f3ff4c37
commit
8cdccbbe73
|
@ -44,3 +44,10 @@ if True: # pylint: disable=using-constant-test
|
|||
CONSTANT or True
|
||||
bool(CONSTANT or OTHER)
|
||||
bool(func(CONSTANT or True))
|
||||
|
||||
# Strings also evaluate as True (they are constants)
|
||||
if func("a") == "b" or "c": # [condition-evals-to-constant]
|
||||
pass
|
||||
|
||||
if 1 == func(2) or "fermi": # [condition-evals-to-constant]
|
||||
pass
|
||||
|
|
|
@ -13,3 +13,5 @@ condition-evals-to-constant:33:7:33:19::Boolean condition 'True or True' will al
|
|||
condition-evals-to-constant:34:7:34:21::Boolean condition 'False or False' will always evaluate to 'False':UNDEFINED
|
||||
condition-evals-to-constant:35:7:35:20::Boolean condition 'True and True' will always evaluate to 'True':UNDEFINED
|
||||
condition-evals-to-constant:36:7:36:22::Boolean condition 'False and False' will always evaluate to 'False':UNDEFINED
|
||||
condition-evals-to-constant:49:3:49:26::Boolean condition 'func('a') == 'b' or 'c'' will always evaluate to ''c'':UNDEFINED
|
||||
condition-evals-to-constant:52:3:52:26::Boolean condition '1 == func(2) or 'fermi'' will always evaluate to ''fermi'':UNDEFINED
|
||||
|
|
Loading…
Reference in New Issue
Block a user