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

style: Fix superfluous-else-return (RET505) #4459

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

echoix
Copy link
Member

@echoix echoix commented Oct 5, 2024

Ruff rule: https://docs.astral.sh/ruff/rules/superfluous-else-return/

When there is an if with a return, the next elif: or else: can be flattened with one less nested level. This kind of early-return pattern is common in C#. Having simpler conditions that return, then the rest of flow continues otherwise

@echoix echoix added this to the 8.5.0 milestone Oct 5, 2024
@echoix echoix requested a review from ninsbl October 5, 2024 19:46
@github-actions github-actions bot added GUI wxGUI related raster Related to raster data processing temporal Related to temporal data processing Python Related code is in Python translation Message translation related libraries module docs general imagery labels Oct 5, 2024
@echoix echoix force-pushed the fix-RET505-superfluous-else-return branch from a2c672e to fb48b27 Compare October 5, 2024 21:30
echoix added 2 commits October 5, 2024 21:41
Ruff rule: https://docs.astral.sh/ruff/rules/superfluous-else-return/

When there is an if with a return, the next `elif:` or `else:` can be flattened with one less nested level. This kind of early-return pattern is common in C#. Having simpler conditions that return, then the rest of flow continues otherwise
@echoix echoix force-pushed the fix-RET505-superfluous-else-return branch from fb48b27 to 46352ab Compare October 5, 2024 21:41
@echoix echoix enabled auto-merge (squash) October 6, 2024 00:44
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

I reviewed a lot of the files, but all of them is too much. So I will trust you with this.

@echoix echoix merged commit 703d9f8 into OSGeo:main Oct 7, 2024
27 checks passed
@echoix echoix deleted the fix-RET505-superfluous-else-return branch October 7, 2024 14:53
@wenzeslaus wenzeslaus removed the request for review from ninsbl October 7, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs general GUI wxGUI related imagery libraries module Python Related code is in Python raster Related to raster data processing temporal Related to temporal data processing translation Message translation related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants