-
Notifications
You must be signed in to change notification settings - Fork 182
Description
Original report by scoutoss on Launchpad:
Working with some NumPy code recently, I accidentally wrote this:
<build output array>
<build mask array>
out[mask] == NaN # This should have been a single `=`, not a ==.
return out
After a few minutes of debugging my NaN-less array, I realized that I had accidentally written ==
instead of =
, turning my assignment statement into no-op comparison operator.
I'd be nice if PyFlakes gave a warning for a statement that's just an expression performing an equality comparison. There are very few cases where I'd expect that something like this is doing what the author intended.
A more aggressive version of this check would be to warn on any expression that's just a binary operator. The assumption there would be that the "statement" a + b
is at best dead code, and at worst an operator with a highly non-obvious side-effect.
I'd be happy to work on either version of this if there's support for it.