-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Include modname in AST warnings #2380
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2380 +/- ##
=======================================
Coverage 92.75% 92.75%
=======================================
Files 94 94
Lines 11065 11067 +2
=======================================
+ Hits 10263 10265 +2
Misses 802 802
Flags with carried forward coverage won't be shown. Click here to find out more.
|
with pytest.raises(AstroidSyntaxError, match="invalid escape sequence") as ctx: | ||
self.builder.string_build("'\\d+\\.\\d+'") | ||
assert isinstance(ctx.value.error, SyntaxError) | ||
assert ctx.value.error.filename == "<unknown>" |
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.
Not exactly sure why the SyntaxError
is raised for all Python version. Additionally this should only emit a SyntaxWarning
at the moment, not a SyntaxError
(which is reraised as AstroidSyntaxError
).
Might be some pytest magic though..
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.
Thanks!
Type of Changes
Description
Python 3.12 change the DeprecationWarning for
invalid escape sequence
to aSyntaxWarning
. These are now printed when the module is imported / the ast tree build. An exampleUsually it's an actual filename for warnings and not just the modname. However, it should be good enough for now.
Long term it might make sense to adjust the warnings filter for astroid to make all
SyntaxWarnings
->SyntaxErrors
which would get re-raised. Thus it would be possible to add apylint: disable
(but only because the whole import isn't analyzed at all / skipped after the error).For know this will at least help debug where the warning is coming from. Users can still choose to ignore them