-
Notifications
You must be signed in to change notification settings - Fork 222
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
==False
changes.All changes should be purely aesthetic except for the following:
not key in dict
is changed tokey not in dict
. These are the same, but the latter is standard.x == None
is changed tox is None
andx != None
is changed tox is None
. Unless the objectx
overrides its__eq__
method to handle it, it should behave exactly the same. Let me know if this is an okay change to make.mpv.py
I changed_fileIsLoaded()
to much simpler logic. Both logic is binary, so it should not affect any functionality.ConfigurationGetter.py
I have changedif str(varToTest).isdigit() == False:
toif not str(varToTest).isdigit()
since this is a python built-in.Additional Personal Notes:
x == True
ideally in the future should be changed. This syntax forces a check to strict True values such asTrue
or1
, but it makes it so all "truthy" values are False. e.g.2 == True
is False,x == False
ideally should be changed tonot x and not None
because this allows all 'Falsey' values to evaluate how they're expected to. e.g.if '' == False
will evaluate asFalse
butif not ''
evaluates True. We add aand not None
to handle the special None case.