compare-to-empty-string / C1901#
Message emitted:
Avoid comparisons to empty string
Description:
Used when Pylint detects comparison to an empty string constant.
Problematic code:
x = ""
y = "hello"
if x == "": # [compare-to-empty-string]
print("x is an empty string")
if y != "": # [compare-to-empty-string]
print("y is not an empty string")
Correct code:
x = ""
y = "hello"
if not x:
print("x is an empty string")
if y:
print("y is not an empty string")
Note
This message is emitted by the optional 'compare-to-empty-string' checker which requires the pylint.extensions.emptystring
plugin to be loaded.
Created by the compare-to-empty-string checker.