Textualize / rich

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

[BUG] `Live(..., transient=True)` leaves an empty cell in VS Code Interactive Jupyter #3502

Open ma-sadeghi opened 1 week ago

ma-sadeghi commented 1 week ago

Describe the bug

Edit this with a clear and concise description of what the bug.

Provide a minimal code example that demonstrates the issue if you can. If the issue is visual in nature, consider posting a screenshot.

from rich.live import Live
from tqdm.auto import tqdm
import time

# Tqdm `leave` works as expected

print("Before")

for i in tqdm(range(10), leave=False):
    time.sleep(0.1)

print("After")

# Rich `transient` does not work as expected
print("Before")

with Live("", transient=True) as live:
    for i in range(10):
        time.sleep(0.1)
        live.update(f"Processing #{i}")
    live.refresh()

print("After")

https://github.com/user-attachments/assets/cd7aac19-4fab-46a0-8fd3-77d2ac505d76

Platform

Click to expand What platform (Win/Linux/Mac) are you running on? What terminal software are you using? I may ask you to copy and paste the output of the following commands. It may save some time if you do it now. If you're using Rich in a terminal: ``` python -m rich.diagnose pip freeze | grep rich ``` If you're using Rich in a Jupyter Notebook, run the following snippet in a cell and paste the output in your bug report. ```python from rich.diagnose import report report() ``` ╭────────────────────── ──────────────────────╮ │ 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=115, height=100), │ │ legacy_windows=False, │ │ min_width=1, │ │ max_width=115, │ │ 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=115, height=100) │ │ soft_wrap = False │ │ stderr = False │ │ style = None │ │ tab_size = 8 │ │ width = 115 │ ╰────────────────────────────────────────────────────────────────────────────╯ ╭─── ────╮ │ Windows features available. │ │ │ │ ╭───────────────────────────────────────────────────╮ │ │ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │ │ ╰───────────────────────────────────────────────────╯ │ │ │ │ truecolor = False │ │ vt = False │ ╰───────────────────────────────────────────────────────╯ ╭────── Environment Variables ───────╮ │ { │ │ 'TERM': 'xterm-color', │ │ 'COLORTERM': None, │ │ 'CLICOLOR': '1', │ │ 'NO_COLOR': None, │ │ 'TERM_PROGRAM': None, │ │ 'COLUMNS': None, │ │ 'LINES': None, │ │ 'JUPYTER_COLUMNS': None, │ │ 'JUPYTER_LINES': None, │ │ 'JPY_PARENT_PID': None, │ │ 'VSCODE_VERBOSE_LOGGING': None │ │ } │ ╰────────────────────────────────────╯ platform="Linux"
github-actions[bot] commented 1 week ago

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory