-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Refactor unneeded 'continue' jumps in jobs #33846
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
My personal opinion: nothing bad with break in
tryblock,try ... elsedo not add viable benefits here.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.
tryblock should contain only code that is expected to throw an exception.Uh oh!
There was an error while loading. Please reload this page.
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 started to like more the try/except/else. It does have a nice property where it clerly separates the "exception handling" logic with "no exception" logic. In this case it does not add much value, but I think there is an educational value. I think one reason we do not use it is that it's somewhat under-used (even if pretty old) Python language construct and by using it in more places in Airflow we might get people learn more about it and use more of it.
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.
We step on the field:
tabsvsspacesand"vs'.According to the documentation for python
Personally I do not know the tool which automatically replace it, so I can't see how we can't prevent new code without
elseclause appear in codebase. UnboundLocalError should in theory prevented by ruff or mypy anywayUh oh!
There was an error while loading. Please reload this page.
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 tihink we can't enforce it, but we can at least have a lot examples in our code that people learn to use it.
But yes. this is a bit of "tabs vs. spaces". Maybe worth discussing it at the devlist what we prefer if this is controversial and get to lazy consensus or even vote, This has been done multiple times in the past for various conventions we use. We even enforced some of those. And as everything here - as long as we agree on something as a convention, the "disagree but engage" rule will kick in and we will all follow.
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.
so @eumiro - maybe that's a good point to start a discussion on devlist where you would explain and ask people for opinions (just be prepared for a bit of flamewar)
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.
First of all I'm not against rule "use
elseintry..except", we just need to use in places where it actually need, rather than always. IMO this is informal rule, in category "might/might not" and not in "should/should not" and definitely not in "must".I'm sure that we have a rule readability first and in previous version it very easy to see what is going on:
In new version
try..except tv series🤣 ) if no exception happen then exit from loopSomeone could also appeal to the fact that
elseintry...exceptwould cost additional ... couple nanoseconds (OMG in Application which communicate with DB right after commit 🤣 ), and we could easily start to play code golf and optimise in place where it not required.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.
And we just started
tabs vs spacesand" vs 'I've also have another topic for "Python Holy War": "use
:=since we have Python 3.8 or try to avoid this operator"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.
:D