-
Notifications
You must be signed in to change notification settings - Fork 164
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
Some code simplifications with the return statement #877
base: main
Are you sure you want to change the base?
Conversation
if subtype in weak: | ||
return True | ||
return False | ||
return subtype in weak |
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.
This is a much welcome cleanup though.
from requests.auth import HTTPDigestAuth | ||
return HTTPDigestAuth(username, password) | ||
elif auth == 'guess': | ||
if auth == 'guess': |
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.
I don't really like this change.
It makes it far harder to figure out the flow. At a glance, I'd get the impression that this code run if auth == 'guess'
, but there's actually a return nested further above.
The elif
makes it a bit more obvious that these are mutually exclusive code-paths.
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.
In all programming languages, writing else
after return
has no added value.
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.
It helps readability, IMO.
@@ -181,7 +181,7 @@ def get_status_path(base_path, pair, collection=None, data_type=None): | |||
def load_status(base_path, pair, collection=None, data_type=None): | |||
path = get_status_path(base_path, pair, collection, data_type) | |||
if not os.path.exists(path): | |||
return None | |||
return |
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.
👍
No description provided.