-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update checks for PEP 765 - return/break/continue in finally block #10480
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10480 +/- ##
==========================================
- Coverage 95.86% 95.86% -0.01%
==========================================
Files 176 176
Lines 19155 19154 -1
==========================================
- Hits 18363 18362 -1
Misses 792 792
🚀 New features to boost your workflow:
|
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 2971fe3 |
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.
Thank you for working on this. It's strange to decrease the error level while this became a syntax error upstream (thus it could have been a warning before in pylint but now it should be an error ?). I'm a little confused by this. The old/current message in pylint feel not accurate before 3.14 which add to the confusion.
I wouldn't think of it this way. Using continue in a finally block was originally a syntax error until 3.8 (I believe) at which point pylint also stopped emitting the error for it. I've now repurposed it to warn for the new syntax warning. So it's more
|
Are you sure it's going to be a SyntaxWarning ? In the PEP it's one or the other but it looked like a SyntaxError to me when parsing with python 3.14 in astroid. (I searched for the release note and you're indeed right: https://docs.python.org/3.14/whatsnew/3.14.html#pep-765-disallow-return-break-continue-that-exit-a-finally-block. It was preventing all analysis of a file with a syntax error though (at least until recently maybe it changed ?).) |
That was because of our pytest config with Maybe this would even work for astroid. Haven't checked it yet. |
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.
Wow, okay then. I wonder how I missed that. Thank you for clarifying.
Maybe we want to make return-in-finally
's verbiage consistent with the others ? (i.e. "'x' discouraged inside 'finally' clause" vs "'x' shadowed inside 'finally' clause ") ?
Decided against doing that as "shadowed inside finally clause" is technically better IMO. The PEP even separates the two cases |
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.
Great PR !
Description
Python 3.14 will emit SyntaxWarnings for
return
/break
/continue
inside finally blocks. Pylint has some checks for it already.return-in-finally
continue-in-finally
-> previously only emitted for Python <3.8 as error. This is now changed to a warning (similar toreturn-in-finally
) and emitted for every Python version.Added a new check for
break-in-finally
.https://peps.python.org/pep-0765/