You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Call me Gretel, 'cause I'd like some Breadcrumbs with my traceback
Having usable, well-formatted tracebacks is important for everything unit testing.
rich.traceback does make tracebacks nicer to look at, but in some cases, I can imagine concrete improvements. However I'm not certain these can be boiled down to programmable rules. Thus a discussion and not an Issue.
Consider the following:
$ cat temp.py from enum import Enumclass A(Enum): a = 1A.a = 2
$ python temp.py Traceback (most recent call last): File "/home/leogott/temp.py", line 6, in <module> A.a = 2 ^^^ File "/home/leogott/miniforge3/lib/python3.12/enum.py", line 860, in __setattr__ raise AttributeError('cannot reassign member %r' % (name, ))AttributeError: cannot reassign member 'a'
temp.py:L7-9 are just trailing newlines and could be omitted
the called function ends at enum.py:L861, so all lines past that could be omitted; and enum.py:L857 is also not all that useful.
Enum is only a local in the broadest sense. It's an imported and unmodified symbol
knowing which environment was used can be extremely useful for solving very specific arcane errors caused by src being on the %path, and the way the path gets styled in a low-contrast color (but is still a usable link for certain IDEs) is pretty neat, but I still find it distracting.
which feels like it could/should be special-cased?
actual shortcomings:
the standard python traceback formatter now marks the "precise instruction" that caused the exception, which I think is pretty neat, and extremely useful in lines with nested function calls. Rich currently doesn't use this this(?) Or it does only on syntax errors? I didn't test this exhaustively
the included context for setattr doesn't actually show me in which class this method is defined. something like breadcrumbs, a qualname or whatever would be nice.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Call me Gretel, 'cause I'd like some Breadcrumbs with my tracebackHaving usable, well-formatted tracebacks is important for
everythingunit testing.rich.traceback does make tracebacks nicer to look at, but in some cases, I can imagine concrete improvements. However I'm not certain these can be boiled down to programmable rules. Thus a discussion and not an Issue.
Consider the following:
some nitpicks:
Enum
is only a local in the broadest sense. It's an imported and unmodified symbolan aside:
which feels like it could/should be special-cased?
actual shortcomings:
Examples for how those could look like
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions