On 2022-01-18 21:58, Pablo Galindo Salgado wrote:
The code that computes the lines is already quite complex (to the point that has to do some AST analysis and post-parsing) so I am quite worried to introduce a lot of complexity in this area. I am fine doing something that we can easily check for (spawns all the line) but I would be against having to start doing even more analysis (especially for things that are not AST-based).
Take into account that code that displays exceptions need to be very resilient because it can be called in some tricky situations and validating that all the code works correctly is very hard, and complex to maintain.
As I said, I think I would be supportive of considering adding a check for the full line, but I think that adding more complexity here is quite dangerous.
It might be enough to check that there's only whitespace before the first ^ and only whitespace optionally followed by a comment (#) after the last ^ on that line.
On Tue, 18 Jan 2022 at 21:49, Patrick Reader <_@pxeger.com http://pxeger.com> wrote:
On 18/01/2022 20:41, Pablo Galindo Salgado wrote:
We cannot base the computation on a % because is possible that the location markers are relevant but the variables, function names or constructs are just very large. I think that the idea of "spawns the whole line" is sensible, though.
On Tue, 18 Jan 2022 at 20:32, Steve Dower
mailto:steve.dower@python.org> wrote: Omitting the line of ^ where over x% (75%? 90%?) of characters on the line would be marked would be fine by me.
It would also need to take into account cases where a line contains an inline comment, which does not contribute to the code producing the error, but where all of the rest of the line (the code) is the source of the error and highlighting it is not useful
# test.py:
code_that_causes_an_error # a comment
$ python3.11 test.py
Traceback (most recent call last): File "test.py", line 1, in <module> code_that_causes_an_error # a comment ^^^^^^^^^^^^^^^^^^^^^^^^^ NameError: name 'code_that_causes_an_error' is not defined
(the traceback shown is from a current `main` build)