GeezerVison is showing github.com — bpo-43950: support some multi-line expressions for PEP 657 by isidentical · Pull Request #27339 · python/cpython
Conversation
isidentical
commented
Jul 24, 2021
•
edited by miss-islington
Loading
Uh oh!
There was an error while loading. Please reload this page.
This is basically something that I noticed up while fixing test runs for another issue. It is really common to have multiline calls, and when they fail the display is kind of weird since we omit the annotations. E.g;
$ ./python t.py
Traceback (most recent call last):
File "/home/isidentical/cpython/cpython/t.py", line 11, in <module>
frame_1()
^^^^^^^^^
File "/home/isidentical/cpython/cpython/t.py", line 5, in frame_1
frame_2(
File "/home/isidentical/cpython/cpython/t.py", line 2, in frame_2
return a / 0 / b / c
~~^~~
ZeroDivisionError: division by zero
This patch basically adds support for annotating the rest of the line, if the instruction covers multiple lines (start_line != end_line).
https://bugs.python.org/issue43950
Automerge-Triggered-By: GH:isidentical
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
isidentical
changed the title
bpo-43950: support multi-line expressions if the intruction covers th…
bpo-43950: support some multi-line expressions for PEP 657
Jul 24, 2021
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 recall they we had this version implemented but we did abandoned it because it looked weird in done scenarios. I am missing anything or is the fact that we are stopping in whitespace enough to account for the problems with the old approach?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The old approach was highlighting the whole line if the end_offset is greater than 256 (-1) but where the instruction was only covering a single line. This is about when an expression covers multiple lines (e.g the call above). Since we now the start point, and we know for a fact that the instruction continue to next lines we can just highlight the line to the end without any false positives.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Can you add some extra tests with some specific cases like function calls spawning multiple lines as well as binops spawning multiple lines (for example)? I will like to cover this with more cases if possible,
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
LGTM modulo my comment regarding more tests
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
ammaraskar
Awaiting requested review from ammaraskar
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|