[BUG] disabled progress bar has unexpected behavior that breaks doctests
- [x] I've checked docs and closed issues for possible solutions.
- [x] I can't find my issue in the FAQ.
Describe the bug
If you have a disabled progress bar it seems to create blank lines that break doctests:
# contents of main.py
from rich.progress import Progress
def create_disabled_progress_bar():
with Progress(disable=True) as progress:
pass
def main():
"""
>>> create_disabled_progress_bar()
>>>
"""
pytest --doctest-modules fails with:
011 >>> create_disabled_progress_bar()
Expected nothing
Got:
<BLANKLINE>
If you comment out:
# with Progress(disable=True) as progress:
The test passes. My current workaround is to monkeypatch Progress to a dummy class that does nothing so not a HUGE deal, but this seems like not ideal behavior.
Platform
Click to expand
What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
Mac. Reproduced on multiple terminals.
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
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface. │
│ │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=169 ColorSystem.TRUECOLOR> │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│ │
│ color_system = 'truecolor' │
│ 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=169, height=46), │
│ legacy_windows=False, │
│ min_width=1, │
│ max_width=169, │
│ 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=169, height=46) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 169 │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available. │
│ │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│ │
│ truecolor = False │
│ vt = False │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ { │
│ 'TERM': 'xterm-kitty', │
│ 'COLORTERM': 'truecolor', │
│ 'CLICOLOR': None, │
│ '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="Darwin"
rich==13.5.2
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
I think here should be and not self.disable as well
def stop(self) -> None:
"""Stop the progress display."""
self.live.stop()
if not any([
self.console.is_interactive,
self.console.is_jupyter,
self.disabled,
]):
self.console.print()