Add check for break/continue/return in finally blocks#59019
Add check for break/continue/return in finally blocks#59019johnslavik wants to merge 1 commit intoapache:mainfrom johnslavik:lint-jumps-in-finally
Conversation
|
3 fixes needed -- not bad! |
|
@jscheffl How would you like this resolved? I'd fix B012 errors in separate PRs, then merge this one in. Just so that all the changes in different areas are reviewed by proper owners. To track, I'll file 3 to-do issues from this tomorrow. |
|
Cool! Thanks for the initiative in enabling! So in total I see (only) 3 errors, would have expected more. 1 of them is fixed with the PR from @AutomationDev85, the second is in a similar area. And the one in Fab should also be easily fixable in my view. As there is no harm in B012 and actually I agree it is a bad practice I have nothing against it and would rather favor it to enable it as well. But it is valid, there might be other opinions. Therefore we have pull requests! If we wait that the other PR is opened and the other two are fixed (either in this PR or in separate in parallel, then rebase this one...) then we just leave it open for a few days for others to object. |
|
(I'd say similar like I am incrementally enabling all PLW rules in #58116 with parallel PRs...) |
|
I've had to delete the head repo -- will reopen this once the lints are fixed. Sorry for the hassle, had to move around stuff. |
|
Cool find and waiting for reopening. That's an important rule to have. |
https://docs.astral.sh/ruff/rules/jump-statement-in-finally/
This is a follow up to #58488 (comment), where enabling SIM017 was initially proposed.
This PR, however, enables B012, which is a more general rule that, in addition to
return, also catchesbreakandcontinueinfinallyblocks -- an exhaustive list of what PEP 765 prohibits.CC @jscheffl
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.