astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
32.27k stars 1.07k forks source link

Rule request: Floating point numbers should not be tested for equality (Sonar - `RSPEC-1244`) #12615

Open daara-s opened 2 months ago

daara-s commented 2 months ago

Keywords: RSPEC-1244, float, sonar

RSPEC-1244 from sonar rules checks whether equality checks are made on floating point numbers, which often leads to non-deterministic results in tests.

This rule forms part of Sonar's Python scanner checks, which I've seen is open as a feature request.

Would it be possible to add this individual rule either as a one-off or as a starting point in porting sonar's rules over?

MichaReiser commented 2 months ago

Makes sense to me. The one big question is where we should add the rule.