Open NicoB77 opened 3 months ago
Thank you for opening the issue.
I feel like the nan should be handled in another conditional because explicit is better than implicit:
target = float(target)
if math.isnan(target) or target <= 0.0:
raise ValueError('Target must be positive!')
Not sure if we should upgrade the check's message to add math.isnan
to all the suggestions though. Might be a little verbose and not relevant most of the time. Or it might be a nice "beware of nan" reminder that actually helps user ?
Thanks for your reply. The explicit call of isnan looks too verbose to me, I would rather not add this to the suggestions. Since the usual equivalences of comparisons do not hold for floats, I am not sure if there should be a warning in the first place. As a workaround I have disabled this warning for my project.
Bug description
The code below causes unnecessary-negation, which is wrong. For float comparisons, "not a < b" and "b <= a" are not equivalent: if a or b is nan, the first condition is true while the second is false.
Command used
Pylint output
Expected behavior
No warning
Pylint version