Skip to content
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

Make the formatting of a code block name extendable #13817

Merged
merged 1 commit into from Nov 28, 2022

Conversation

jasongrout
Copy link
Member

@jasongrout jasongrout commented Nov 9, 2022

Currently the user display of a code block requires a tight coupling between the caching compiler and the ultratb file, i.e., ultratb needs to know internal private variables of the caching compiler. This change makes the user-visible display of the code block name the responsibility of the caching compiler, separating the API more cleanly. A nice result is that the caching compiler can be overridden to have custom terminology in different systems for code blocks executed (for example, in Databricks the "cells" are currently known as "commands".)

I tried to strike a nice balance here between maintaining the existing format exactly and the API of the new method. I think it is a bit weird that the line number formatting is different for files vs cached code blocks (X, line Y vs X:Y). Do we need to preserve the X:Y formatting for automated tools that expect exactly that form for file line numbers?

@jasongrout jasongrout force-pushed the formatcell branch 2 times, most recently from c0f3e9a to 3dbb247 Compare November 9, 2022 07:39
@jasongrout jasongrout marked this pull request as ready for review November 9, 2022 12:07
Currently the user display of a code block requires a tight coupling between the caching compiler and the ultratb file, i.e., ultratb needs to know internal private variables of the caching compiler. This change makes the user-visible display of the code block name the responsibility of the caching compiler. A nice result is that the caching compiler can be overridden to have custom terminology in different systems for code blocks executed.
@jasongrout-db
Copy link

I tried to strike a nice balance here between maintaining the existing format exactly and the API of the new method. I think it is a bit weird that the line number formatting is different for files vs cached code blocks (X, line Y vs X:Y). Do we need to preserve the X:Y formatting for automated tools that expect exactly that form for file line numbers?

There is an extensive discussion of this in #13560, and the answer is "yes", and the format difference here is intentional.

@Carreau Carreau added this to the 8.7 milestone Nov 28, 2022
@Carreau
Copy link
Member

Carreau commented Nov 28, 2022

Let's try and see if we get complaints.

@Carreau Carreau merged commit 47abb68 into ipython:main Nov 28, 2022
@jasongrout
Copy link
Member Author

Let's try and see if we get complaints.

Note that this PR has no change visible to the user - I kept the existing formatting, and just made it extendable.

@jdtsmith
Copy link
Contributor

Some tools parse the UltraTB formatting (at least one flavor of it), so it would be very helpful if iPython sticks to the current format. Hopefully it is expressive enough for Exception Groups too (haven't seen those in the wild).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants