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
[ruff
] Re-implement unreachable
#10891
base: main
Are you sure you want to change the base?
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF014 | 22 | 22 | 0 | 0 | 0 |
Formatter (stable)
✅ ecosystem check detected no format changes.
Formatter (preview)
✅ ecosystem check detected no format changes.
Nice, I'm a fan of this. |
No promises, just started taking a look at it. |
Can you give me some background on why this was never activated? Was there just too many false positives? |
c993823
to
5897adb
Compare
CodSpeed Performance ReportMerging #10891 will not alter performanceComparing Summary
|
4493aaf
to
9dc225a
Compare
This reverts commit f9dd7bb.
…ith multiple blocks
eda9b6b
to
557974b
Compare
557974b
to
552cb09
Compare
4d724c3
to
87a3e96
Compare
This is probably not completely ready for merging, but considering the size it's probably worth getting some feedback now. All the ecosystem checks seem like true positives, there might still be some false negatives, but those will be harder to find. |
@charliermarsh when you get the time please have a look at this |
Summary
This PR re-introduces the control-flow graph implementation which was first introduced in #5384, and then removed in #9463 due to not being feature complete. Mainly, it lacked the ability to process
try
-except
blocks, along some more minor bugs.I will now highlight the major changes implemented in this PR, in order of implementation.
continue
orbreak
statements within the loop body and redirect them appropriately.try
processing with the following logic (resolves Completetry
-except
handling in control-flow graph #8959):ExceptionRaised
forking if an exception was (or will be) raised in the try block. This is not possible to know (except for trivial cases) so we assume both paths can be taken unconditionally.try
path the cfg goestry
->else
->finally
unconditionally.except
path the cfg will meet several conditionalExceptionCaught
which fork depending on the nature of the exception caught. Again there's no way to know which exceptions may be raised so both paths are assumed to be taken unconditionally.raises
orreturns
within the blocks appropriately.with
processing with the following logic:with
statements have no conditional execution (apart from the hidden logic handling the enter and exit), so the block is assumed to execute unconditionally.with
blocks even if the blocks containraise
orreturn
statements. This is handled in a post-processing step.Test Plan
Additionaly test fixtures, and control-flow fixtures were added.