-
Notifications
You must be signed in to change notification settings - Fork 4
Add warning for random.random #34
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: migration
Are you sure you want to change the base?
Conversation
of random.random()
|
Please force push a rebase against master before review. |
@ltratt , resolved, thanks for pointing out. |
|
Please squash. |
|
Hmm, actually, maybe I'm wrong. Isn't this warning going to be annoying? Even if someone has updated their code, they're still going to get the "change your code" warning AFAICS? |
@ltratt I think you are right about the warning behavior of my implementation. I think it is generally hard to detect whether user change their code within the warning. Since the warning is about length of random.random(), maybe I should put warning inside of |
|
What one would need to do is track the string output by For example, @nanjekyejoannah can fill you in on the Another way would be to return a "special" string-like object from |
@ltratt Thank you for your suggestions on improving my implementation, I will try to work on either ways and figure out which one is more suitable. Thanks again! |
|
@ltratt I avoid putting a new filed inside of float object since change size of struct might cause some chain reaction. |
|
This looks interesting but dumb question: doesn't this still mean that everyone who does |
@ltratt it seems that len(random.random()) won't run because float objects doesn't have such method. As picture shown below |
|
Sorry, I meant |
|
@ltratt I think since we are intended to warn user about the length change of
We could avoid warning in first case that we also store the extra information about whether generated from random in string-object and check in We could maybe also maintain a global dictionary with key be location of warning (code line number, etc) and value be a bool of whether user change their code when user run pygrate3 on their code that we assume user's change is correct and mark bool at that location to be true and avoid throw warning to user in next check. But if we assume user's change is correct then 1 run of pygrate3 is enough such that we don't even need to worry about silence problem. |
|
@Eddy114514 lets first find a justification for duplicate C code on floats to avoid duplication. |

add warning for random.random() that in python 3 its string representation is longer (~18 digit) than python 2 (~14 digit).
as following:


