Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
48.81k stars 1.71k forks source link

[BUG] Hooking `traceback` in `vscode` notebook prevents exceptions from raising #2146

Open vnghia opened 2 years ago

vnghia commented 2 years ago

Describe the bug

When using traceback.install() in vscode, exceptions aren't raised anymore. The cell status is success and the code continues running.

Inside a notebook in vscode

import rich
rich.traceback.install();
raise ValueError
image

Platform

Click to expand What platform (Win/Linux/Mac) are you running on? What terminal software are you using? I tested on all 3 OSes. ``` ╭──────────────────── ─────────────────────╮ │ A high level console interface. │ │ │ │ ╭─────────────────────────────────────────────────────────────────────╮ │ │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────╯ │ │ │ │ color_system = 'truecolor' │ │ encoding = 'utf-8' │ │ file = │ │ height = 100 │ │ is_alt_screen = False │ │ is_dumb_terminal = False │ │ is_interactive = False │ │ is_jupyter = True │ │ is_terminal = False │ │ legacy_windows = False │ │ no_color = False │ │ options = ConsoleOptions( │ │ size=ConsoleDimensions(width=93, height=100), │ │ legacy_windows=False, │ │ min_width=1, │ │ max_width=93, │ │ is_terminal=False, │ │ encoding='utf-8', │ │ max_height=100, │ │ justify=None, │ │ overflow=None, │ │ no_wrap=False, │ │ highlight=None, │ │ markup=None, │ │ height=None │ │ ) │ │ quiet = False │ │ record = False │ │ safe_box = True │ │ size = ConsoleDimensions(width=93, height=100) │ │ soft_wrap = False │ │ stderr = False │ │ style = None │ │ tab_size = 8 │ │ width = 93 │ ╰─────────────────────────────────────────────────────────────────────────╯ ╭─── ────╮ │ Windows features available. │ │ │ │ ╭───────────────────────────────────────────────────╮ │ │ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │ │ ╰───────────────────────────────────────────────────╯ │ │ │ │ truecolor = False │ │ vt = False │ ╰───────────────────────────────────────────────────────╯ ╭─────── Environment Variables ────────╮ │ { │ │ 'TERM': 'xterm-color', │ │ 'COLORTERM': 'truecolor', │ │ 'CLICOLOR': '1', │ │ 'NO_COLOR': None, │ │ 'TERM_PROGRAM': 'iTerm.app', │ │ 'COLUMNS': None, │ │ 'LINES': None, │ │ 'JPY_PARENT_PID': None, │ │ 'VSCODE_VERBOSE_LOGGING': 'true' │ │ } │ ╰──────────────────────────────────────╯ platform="Darwin" ```

In the meantime, I suggest we disable install() inside vscode by checking VSCODE_PID https://github.com/microsoft/vscode-jupyter/issues/3364. I could send a PR for this if you want. Thank you very much !

pstanisl commented 2 years ago

Same behavior in Databricks, issue #2455

artemisart commented 1 year ago

This is due to #2271

lainisourgod commented 1 year ago

same behaviour