-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[syntax error] Fix a crash when the line and column can't be retrieved #7097
[syntax error] Fix a crash when the line and column can't be retrieved #7097
Conversation
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.
One of the issues with SyntaxErrors
is that their messages changes across versions and implementations. They don't really lend themselves well for our functional test framework.
Perhaps an unittest
would work better here?
865b1b8
to
9266868
Compare
This comment has been minimized.
This comment has been minimized.
Pull Request Test Coverage Report for Build 2765124596
π - Coveralls |
dede3cc
to
319a5c9
Compare
I'm back with a new machine with python 3.10 / ubuntu 22.04 π everything is nicer, there's progress bars in pip ! |
This comment has been minimized.
This comment has been minimized.
@Pierre-Sassoulas Do we understand the primer results? |
No idea, I think it's a primer cache bug ? |
It's weird as you don't have a |
It seems I was already based on b9419a2 which is the latest commit from main so I don't know what I can do. |
See #7156 (comment). |
This comment has been minimized.
This comment has been minimized.
b652f93
to
dbaa36c
Compare
This comment has been minimized.
This comment has been minimized.
We can't reproduce the syntax error with functional tests, will need to create a unit test with a mock, but this can wait 2.15.0 |
This comment has been minimized.
This comment has been minimized.
tests/test_self.py
Outdated
@@ -27,6 +27,7 @@ | |||
from unittest.mock import patch | |||
|
|||
import pytest | |||
from astroid import PY310_PLUS |
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.
? Why from astroid
?
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.
Good catch, I imported the wrong one π
tests/test_self.py
Outdated
@pytest.mark.skipif( | ||
PY310_PLUS, reason="Not a syntax error for python 3.10 or superior" | ||
) | ||
def test_astroid_syntax_error(self, tmp_path) -> None: |
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.
def test_astroid_syntax_error(self, tmp_path) -> None: | |
def test_astroid_syntax_error(self, tmp_path: TempPathFixture?) -> None: |
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.
@Pierre-Sassoulas this was a question. Sorry should have been clearer.
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.
Hurgh, no that's my bad. It's a pathlib.Path.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0a15815
to
15c3d9f
Compare
This is the same error than we have on other branches... I wonder if we should deactivate the tests for pypy. It's likely we'll never think of reactivating it if we do that. |
This comment has been minimized.
This comment has been minimized.
pylint/lint/pylinter.py
Outdated
@@ -918,7 +918,8 @@ def get_ast( | |||
"syntax-error", | |||
line=getattr(ex.error, "lineno", 0), | |||
col_offset=getattr(ex.error, "offset", None), | |||
args=str(ex.error), | |||
args=f"Parsing Python code failed:\n{ex.error}", |
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.
This seems unnecessary? The message is already called syntax-error
?
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.
There's other syntax error for example when there's a syntax error in something we want to import. I think it does not hurt to be explicit.
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.
I don't mind too much, but I don't really understand what it adds. Seems like it just adds unnecessary verbosity. In IDEs that might actually reduce usability.
But if you think this is better please go ahead!
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.
I removed the line break that could be problematic in IDE.
This comment has been minimized.
This comment has been minimized.
39953bf
to
1af2c02
Compare
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 1af2c02 |
Type of Changes
Description
Closes #3860