-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Elide uninformative traceback indicators in return
and simple assignment statements
#99180
Comments
CC @pablogsal |
Thanks a lot for raising these @Zac-HD! I think both of this make sense. I am a bit wary of complicating the already-complex machinery to detect and deal with the ranges even more because the code is becoming a bit complex to maintain but I can give it a go to see how it looks. Also, we have a bunch of in-flight PRs for this area already so we need to land them before attempting anything here. I have been thinking about all of this and I think the long term solution may be to use colors if possible instead of underlining the ranges with extra characters. This way we save lines and reduce clutter. If colors would be used in the situations you highlight would this have been acceptable? |
I think colors would be overridden by the pytest error machinery, as well as much of our logging infra at work, so that would be equivalent to disabling range indicators entirely. That would certainly solve the problem of uninformative indicators, but at the cost of losing useful information too! |
Ok, I have this a go and here are my initial thoughts.
|
In any case I created #112670 in case other core devs think otherwise. @isidentical @lysnikolaou opinions? |
…nts that cover all the displayed range
…nts that cover all the displayed range Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
…nts that cover all the displayed range Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
…nts that cover all the displayed range Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@pablogsal Would it be feasible to only skip the highlights if the highlighted section spans the entire |
Yes, but this still will not cover the OP cases because now we use two characters in many places, including calls. For example:
|
Hmm, I'm +1 for keeping it as is then. Requiring the user to deduct that the last call of the line is the one failing, if no carets are there, sounds like bad experience. |
Another thing to do is explore the entire AST and do this ONLY if there is a single call where the callable is a simple name. But this is more computation at error time which I am not super happy about |
Oh yes, that achieves what I was trying to achieve above.
This is true, but it isn't much more computation, and we've always been happy to sacrifice a bit of time for better errors UX, right? Although it's up to you to decide whether it's too much. |
…nts that cover all the displayed range Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Apply suggestions from code review Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> fix whitespace issue causing the lint check to fail
…at cover all the displayed range (#112670)
…nts that cover all the displayed range (python#112670)
…nGH-119554) (cherry picked from commit 4b7eb32) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
The new traceback indicators can be really nice, though at times also quite verbose. #93883/#93994 by @belm0 improved this situation by skipping the indicators for lines where the entire line was indicated, which helps substantially. I'd like to propose that we take this a small step further:
return
statement, where every part execpt thereturn
keyword is indicated; e.g.return foo()
name = some.more(complicated, call=here)
These heuristics are slightly more complicated than "don't indicate the entire line", but I argue that in each of these cases the indicators add little to no information, while compressing the traceback makes it easier to navigate and draws attention to the remaining more-specific indicators.
My motivating example is the traceback reported in pytest-dev/pytest#10466, where I count seven already-elided indicator lines, twelve that would be elided by the return heuristic, seven by the simple-assignment heuristic, and four other lines where the indicators would not be affected by this proposal. I'd even argue that dropping uninformative indicators from a majority (19/30) of traceback lines could be considered a bugfix - indicating on 4/30 lines is quite different to 23/30!
Linked PRs
StackSummary.should_show_carets
private #119554StackSummary.should_show_carets
private (GH-119554) #119556The text was updated successfully, but these errors were encountered: