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.
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
Use selected syntax style for tracebacks and improve ANSI color codes support #608
Use selected syntax style for tracebacks and improve ANSI color codes support #608
Changes from 6 commits
caaff4c
b0eb600
b273787
f5d14e3
ddedcdf
608d0e5
65308b5
f593961
56fb9e9
7a1a34c
2e752c6
ff43880
f7bbaa0
dd5c5b3
cf7ad25
7de610f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
A couple of comments about this change:
_tb_highlight_style
attribute was added in IPython 8.15 (see Add hack to change traceback syntax highlighting ipython/ipython#14138). So, it's necessary a check that executes the new code for that or more recent versions, and leaves the previous one for older versions._tb_highlight_style
a public attribute ofVerboseTB
by submitting a PR to IPython. That would require an additional check here but it'd prevent they breaking us in the future.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.
That's quite a good point! Thinking about that, and the fact that this way of customizing things is based on a hack, I would say that we should implement the validation using some sort of fallback approach rather than checking the package version (maybe at some point that hack is removed in favor of an actual public method for customization). Maybe we could check if the attribute is available and depending on that use it or fallback to the previous code that uses the magic?
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 think something like this could work:
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.
This is very good approach, thanks @dalthviz! However, given that
_tb_highlight_style
is a private attribute ofVerboseTB
, I think it'd be a good idea to promote it to a public one in IPython and let Matthias know that we're using it here.Otherwise, this functionality could break easily without us being aware of it (given that now there's a fallback in case that attribute is no longer available).
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.
Created ipython/ipython#14464 to check your suggestion @ccordoba12
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.
Yep, thanks! I saw Matthias answer, so now please proceed to implement his suggestions there.