Skip to content

fix(magic): use ConsoleRenderer for text config instead of HTMLRenderer - #446

Merged
joerick merged 4 commits into
joerick:mainfrom
fuleinist:fix/jupyter-magic-render-options
Jul 29, 2026
Merged

joerick merged 4 commits into
joerick:mainfrom
fuleinist:fix/jupyter-magic-render-options

Conversation

@fuleinist

Copy link
Copy Markdown
Contributor

Summary

The Jupyter %%pyinstrument magic calls compute_render_options twice — once for the HTML renderer config and once for the text renderer config. Both calls were passing renderer_class=HTMLRenderer, which means renderer-specific options for ConsoleRenderer (like unicode, color, and time) were never set in the text config.

This caused --render-option=time=percent_of_total (and other ConsoleRenderer-specific options) to be silently ignored in the text output.

Fix

Changed the second call to use renderer_class=ConsoleRenderer so that:

  1. unicode and color are properly set in the text config (they were previously being hardcoded to True at line 196–197, which masked the bug for those specific options)
  2. time and other ConsoleRenderer-specific constructor kwargs (like flat, flat_time, short_mode) are now correctly parsed from --render-option flags
  3. processor_options (hide/show regex) are properly passed to the text renderer

Testing

  • --render-option=time=percent_of_total now correctly shows percentages in the text output
  • --hide, --show, --show-all continue to work for both HTML and text output
  • --unicode, --color flags continue to work for both renderers

Fixes #419

The Jupyter magic called compute_render_options with HTMLRenderer for
both the HTML and text renderer configs. The text config should use
ConsoleRenderer so that renderer-specific options (unicode, color) are
properly set. This fixes --render-option=time=percent_of_total and
other ConsoleRenderer-specific options being silently ignored in the
text output of %%pyinstrument.

Fixes joerick#419
@joerick

joerick commented Jul 29, 2026

Copy link
Copy Markdown
Owner

thanks!

@joerick joerick closed this Jul 29, 2026
@joerick joerick reopened this Jul 29, 2026
@joerick
joerick merged commit d0025ab into joerick:main Jul 29, 2026
21 checks passed
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.

Jupyter plugin ignores --render-option=time=percent_of_total

2 participants