-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[consider-math-not-float] Add a check for float("inf")
, float("nan")
and float("typos")
#10621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
341d145
to
b127d04
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10621 +/- ##
=======================================
Coverage 95.95% 95.96%
=======================================
Files 176 176
Lines 19504 19517 +13
=======================================
+ Hits 18716 18729 +13
Misses 788 788
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
b127d04
to
fe7f298
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
d767cb7
to
bda3d30
Compare
This comment has been minimized.
This comment has been minimized.
Off by default? 🤔 |
Do you mean it should be disabled by default in extension or added in checkers instead of extension ? 😄 |
be11be6
to
d25b7fb
Compare
float("inf")
, float("nan")
and float("typos")
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Morwenn <[email protected]>
Ah, I didn't realize it was in an extensions. nice. |
Yeah, originally it wasn't obvious it should be an extension but I suppose the microbenchmark is misleading in the ruff issue because it doesn't take the "import math" into account. I also changed the "use" to "consider" in the message name because of this. If mypy understand better float("inf") one day this is going to be a really situational warning. |
float("inf")
, float("nan")
and float("typos")
float("inf")
, float("nan")
and float("typos")
Type of Changes
Description
float("nan") and float("inf") are slower than their counterpart math.inf and math.nan by a factor of 4 :
But:
They are also not well typed when using mypy, see discussion in ruff: astral-sh/ruff#15908
I chose the code style checker without thinking too much about it and because there was already an inference call on the name of a call here. I can move it to the refactoring checker considering the benefit ? (Did this at work in pair so at least someone else than me and 4 person thumbsupping in the ruff issue consider this worthwhile)