Recommend disabling "Boolean variable check can be simplified"

A long-time Pylint user, I've been enjoying PyCharm's inspections. I particularly like PyCharm's inspections for HTML, where I carelessly leave open tags or refactor one, but fail to close the other, end of a tag. Though for Python, I strongly recommend that my fellow PyCharm users disable the following check: "Boolean variable check can be simplified"

The idea behind the check is basically to "simplify" if statements. For example "if x is None" is simplified to "if not x". Sometimes his is valuable, but usually, a Python programmer is smart enough to be aware of the simplificaiton, and he's being explicit.

For examle, a value of "0" might be very different from a value of None. If you have a variable called price, 0 might be free, while None might mean unpriced. There's a difference between checking for a variable that happens to evaluate to false, as opposed to checking for the evaluation result itself.

Anyway, just a thought. If I weren't paying attention and just followed PyCharm's advice on simplification, it would break my code all over. But that's why checks can be disabled.

Please sign in to leave a comment.