-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix location metadata on backslash/unicode escape lints #4003
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
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 the merge request ! Could you also add an example of code that was failing before this change in tests/functional
so we do not regress later ?
Alright added some tests and added a fix to the line metadata to this PR. There is currently no functional test facility for column but this should be feasible to add. Considering that this would mean modifying all existing functional tests, I think it's best left for a follow-on change. |
Cleaned up commit history, as well. |
Wow, you're right the functional test do not check for column ! Well, I made the required change so you can implement this properly : we'll move the legacy backlash functional test to the new functional test framework in : #4012. Also, we're going to add this column check to functional tests in #4013. Feel free to review them as this will impact what you do here :) |
Alright I've rebased the fix for the legacy test to the new functional one. Unfortunately, your PR seems to run into the issue that py3.8 AST has different (read: more accurate) column metadata than do previous versions. Maybe add a config param to all tests to not check columns before py3.8? |
The existing column offset logic does not account for the start-of-line to start-of-string offset nor does the line logic reflect the actual line number of the error for multi-line strings.
@@ -25,7 +25,8 @@ | |||
ESCAPE_UNICODE = "\\\\n" | |||
|
|||
# Bad docstring | |||
"""Even in a docstring # [anomalous-backslash-in-string] | |||
# +3:[anomalous-backslash-in-string] |
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.
👍
Pretty useful MR, I remember having to search for the offending backslash in the whole docstring. This will make a lot of lives easier :) Congratulation on your first contribution to pylint ! |
Thanks so much @Pierre-Sassoulas! And thanks for the review and for implementing column-based testing (even though it can't be merged immediately)! |
The existing logic does not account for the start-of-line to start-of-string offset in the column and does not adjust the line to reflect where the actual backslash occurs.
Steps
doc/whatsnew/<current release.rst>
.Description
Type of Changes
Related Issue