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

[BUG] Modifying console theme has no effect on traceback #1786

Closed
AaronBeaudoin opened this issue Dec 29, 2021 · 1 comment · Fixed by #1811
Closed

[BUG] Modifying console theme has no effect on traceback #1786

AaronBeaudoin opened this issue Dec 29, 2021 · 1 comment · Fixed by #1811
Assignees
Labels
bug Something isn't working

Comments

@AaronBeaudoin
Copy link
Contributor

Description

When a traceback is printed to a console which has a modified theme applied to it, the theme's styles are not used when printing the traceback.

Reproduction

In this example, I expect the border of the traceback to be blue and the "tag" name and contents to be black. Instead, the defaults continue to be used. Removing the theme="bw" does not produce the expect result either.

from rich.console import Console
from rich.theme import Theme

console = Console(theme=Theme({
    "repr.tag_name": "bold black",
    "repr.tag_contents": "black",
    "traceback.border": "blue",
    "traceback.border.syntax_error": "blue"}))

try: raise Exception
except Exception: console.print_exception(theme="bw", show_locals=True)

Platform

MacOS, Terminal App (Happens in VS Code too.)

Diagnostics

$ python -m rich.diagnose

╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=139 ColorSystem.EIGHT_BIT>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = '256'                                                         │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 46                                                            │
│    is_alt_screen = False                                                         │
│ is_dumb_terminal = False                                                         │
│   is_interactive = True                                                          │
│       is_jupyter = False                                                         │
│      is_terminal = True                                                          │
│   legacy_windows = False                                                         │
│         no_color = False                                                         │
│          options = ConsoleOptions(                                               │
│                        size=ConsoleDimensions(width=139, height=46),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=139,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=46,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=139, height=46)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 139                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
$ python -m rich._windows

platform="Darwin"
WindowsConsoleFeatures(vt=False, truecolor=False)
$ python -m pip freeze | grep rich

rich==10.16.1
@AaronBeaudoin AaronBeaudoin changed the title [BUG] Modifying traceback theme has no effect [BUG] Modifying console theme has no effect on traceback Dec 29, 2021
@darrenburns darrenburns added bug Something isn't working and removed Needs triage labels Jan 6, 2022
@darrenburns darrenburns linked a pull request Jan 6, 2022 that will close this issue
9 tasks
@github-actions
Copy link

github-actions bot commented Jan 7, 2022

Did I solve your problem?

Why not buy the devs a coffee to say thanks?

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jan 11, 2022
11.0.0

Added

Added max_depth arg to pretty printing Textualize/rich#1585
Added vertical_align to Table.add_row Textualize/rich#1590

Fixed

Fixed issue with pretty repr in jupyter notebook Textualize/rich#1717
Fix Traceback theme defaults override user supplied styles Textualize/rich#1786

Changed

breaking Deprecated rich.console.RenderGroup, now named rich.console.Group
breaking Syntax.__init__ parameter lexer_name renamed to lexer
Syntax constructor accepts both str and now a pygments lexer Textualize/rich#1748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants