You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SIM107 documentation example may be misleading #22325
I have a question about the example shown in the SIM107 (return-in-try-except-finally) documentation. Could you clarify the intended purpose of this documentation example?
The current documentation includes this as good example:
Thanks for the report! I agree that this is confusing. I think the minimal change to get something that actually works is to remove only the return in the finally arm for the "Use instead" example:
I thought for a while and searched online, and I could not find a good example. The best one to me is the one from the issue @ftnext linked (MartinThoma/flake8-simplify#9).
I'm so surprised that this rule is in the flake8-simplify linter. This is not about simplifing code, returning in a finally block is never what we want!!
Activity
ntBre commentedon Jan 1, 2026
Thanks for the report! I agree that this is confusing. I think the minimal change to get something that actually works is to remove only the return in the
finallyarm for the "Use instead" example:but even that is a bit confusing. Maybe a better initial example would be helpful.
LoicRiegel commentedon Jan 3, 2026
I thought for a while and searched online, and I could not find a good example. The best one to me is the one from the issue @ftnext linked (MartinThoma/flake8-simplify#9).
I'm so surprised that this rule is in the flake8-simplify linter. This is not about simplifing code, returning in a
finallyblock is never what we want!!Fix misleading SIM107 "Use instead" example