-
Notifications
You must be signed in to change notification settings - Fork 237
Code Syntax Refactoring Try #2 #195
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
Conversation
syncplay/utils.py
Outdated
| def formatSize (bytes, precise=False): | ||
| if bytes == 0: # E.g. when file size privacy is enabled | ||
|
|
||
| def formatSize(num_of_bytes, precise=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You rename bytes 'num_of_bytes' at the top of the def but not in the subsequent code. This results in all sizes being incorrectly reported as '???'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that. I forgot I had made this change. It's to avoid shadowing the bytes keyword.
Code Syntax Refactoring Try Syncplay#2
This is the same as PR#192, except it reverts almost all
==True==Falsechanges.All changes should be purely aesthetic except for the following:
not key in dictis changed tokey not in dict. These are the same, but the latter is standard.x == Noneis changed tox is Noneandx != Noneis changed tox is None. Unless the objectxoverrides its__eq__method to handle it, it should behave exactly the same. Let me know if this is an okay change to make.mpv.pyI changed_fileIsLoaded()to much simpler logic. Both logic is binary, so it should not affect any functionality.ConfigurationGetter.pyI have changedif str(varToTest).isdigit() == False:toif not str(varToTest).isdigit()since this is a python built-in.Additional Personal Notes:
x == Trueideally in the future should be changed. This syntax forces a check to strict True values such asTrueor1, but it makes it so all "truthy" values are False. e.g.2 == Trueis False,x == Falseideally should be changed tonot x and not Nonebecause this allows all 'Falsey' values to evaluate how they're expected to. e.g.if '' == Falsewill evaluate asFalsebutif not ''evaluates True. We add aand not Noneto handle the special None case.