Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dilyanpalauzov
Copy link
Contributor

No description provided.

if subtype in weak:
return True
return False
return subtype in weak
Copy link
Member

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':
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants