-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
- I've checked docs and closed issues for possible solutions.
- I can't find my issue in the FAQ.
Describe the bug
When using a Live without anything that renders, it will leave behind a spurious newline despite setting transient=True. However, even a single empty string makes the newline go away.
from rich.live import Live
from rich.console import Group
list: list[RenderableType] = []
live = Live(Group(*list), transient=True)
with live: pass
exit(0)The code above will leave behind a spurious newline (see screenshot). If I were to initialize list as [""], the newline does not appear anymore.
Some more details on the usecase: I use a live to render a varying number of elements indicating progress - once the task is done, the associated elements will go away as well. Consequently, at the end of my program, the list of renderables in the group is empty, and my code leaves behind a spurious newline. Always having the empty string as a "hack" is slightly annoying as well, since then during the Live display, there is always an additional empty line at the bottom of the screen - limiting the real estate.
Platform
Click to expand
python -m rich.diagnose
pip freeze | grep rich
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface. │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=177 ColorSystem.TRUECOLOR> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ color_system = 'truecolor' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│ height = 31 │
│ 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=177, height=31), │
│ legacy_windows=False, │
│ min_width=1, │
│ max_width=177, │
│ is_terminal=True, │
│ encoding='utf-8', │
│ max_height=31, │
│ justify=None, │
│ overflow=None, │
│ no_wrap=False, │
│ highlight=None, │
│ markup=None, │
│ height=None │
│ ) │
│ quiet = False │
│ record = False │
│ safe_box = True │
│ size = ConsoleDimensions(width=177, height=31) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 177 │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available. │
│ │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│ │
│ truecolor = False │
│ vt = False │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ { │
│ 'CLICOLOR': None, │
│ 'COLORTERM': 'truecolor', │
│ 'COLUMNS': None, │
│ 'JPY_PARENT_PID': None, │
│ 'JUPYTER_COLUMNS': None, │
│ 'JUPYTER_LINES': None, │
│ 'LINES': None, │
│ 'NO_COLOR': None, │
│ 'TERM_PROGRAM': 'vscode', │
│ 'TERM': 'xterm-256color', │
│ 'TTY_COMPATIBLE': None, │
│ 'VSCODE_VERBOSE_LOGGING': None │
│ } │
╰────────────────────────────────────╯
platform="Linux"
rich==14.0.0