-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
New rule: Decimal with float argument #11840
Comments
I don't think we have a check for this. Can you say more on why it's something to be avoided? |
Consider:
In the first example you basically creating an exact representation of the floating point approximation to 0.1. To my mind that is almost certainly not what is wanted as it seems to defeat the purpose of using Decimal in the first place. |
Yeah, @mayanyax is exactly right. Passing a |
This would be a good addition, I have use cases where this has caused potential bugs. |
this is a footgun i keep forgetting, and i would definitely enjoy seeing this rule implemented. |
Fixed by #12909 |
I'm interested in adding a new rule to check for
Decimal
being called with a float literal argument. For example:This seems like a generally useful check. I searched for open issues and PRs involving
Decimal
and didn't find any mention of this type of check. I'm happy to work on a PR, but wanted to make sure this check makes sense inruff
. Please let me know if I'm missing something or there's any reason this check wouldn't be accepted.Thanks!
The text was updated successfully, but these errors were encountered: