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

Fix RET505 Unnecessary else / elif after return statement #1752

Merged
merged 1 commit into from
Dec 5, 2023

Conversation

brianhelba
Copy link
Collaborator

I'm not sure if I like this rule or not. Most of the time, I think it probably is the right thing for readability, but sometimes it seems worse. Maybe I'm just not used to it?

return self.embargoed_blob.size
else:
return self.zarr.size
return self.zarr.size
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a good example of this rule being kind of bad 🤷‍♂️.

Copy link
Member

Choose a reason for hiding this comment

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

I think overall the design pattern above is suboptimal regardless of the diff which is overall "potato vs potato" to me. Neither original nor new code is provisioning to have some case which is no longer fulfilling the design (e.g. when new types of assets would be added...). Should have been likely a sequence of if/elif/else: raise AssertionError(f"Do not know how to get size for the {self}").

@jjnesbitt
Copy link
Member

I support this rule and would be happy to have this merged. I think 99% of the time this vastly improves readability, and in the other 1% you can disable the rule.

@brianhelba brianhelba changed the title Fix RET505 Unnecessary else / `elif after return statement Fix RET505 Unnecessary else / elif after return statement Nov 27, 2023
@brianhelba brianhelba force-pushed the else-return branch 3 times, most recently from 7601ff0 to e9c2f46 Compare November 30, 2023 19:20
@brianhelba brianhelba merged commit 445f61d into master Dec 5, 2023
10 checks passed
@brianhelba brianhelba deleted the else-return branch December 5, 2023 20:19
@dandibot
Copy link
Member

🚀 PR was released in v0.3.67 🚀

@dandibot dandibot added the released This issue/pull request has been released. label Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants