possibly-used-before-assigment
fails to understand test with immutable bool
#10095
Labels
Control flow
Requires control flow understanding
Duplicate 🐫
Duplicate of an already existing issue
False Positive 🦟
A message is emitted but nothing is wrong with the code
Bug description
As per the docs, this works:
but only because we are using the same test,
not x
, twice.If we instead use the test
x
, pylint fails:Command used
Pylint output
Expected behavior
It is impossible for
print("hi")
(or any intervening code that doesn't assign tox
) to change the value ofx
since it is an immutable bool. Ifnot x
isFalse
at the top of the function,x
will always beTrue
at the bottom of the function. So it is impossible formsg
to be used before assignment - this is a false positive.Pylint version
The text was updated successfully, but these errors were encountered: