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] rich.pretty is not showing maxlen for collections.deque #2863

Closed
2 tasks done
XuehaiPan opened this issue Mar 7, 2023 · 2 comments · Fixed by #2864
Closed
2 tasks done

[BUG] rich.pretty is not showing maxlen for collections.deque #2863

XuehaiPan opened this issue Mar 7, 2023 · 2 comments · Fixed by #2864

Comments

@XuehaiPan
Copy link
Contributor

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.

I add rich.pretty in my ipython startup script and overwrite builtins.print with rich.print. It work as expected when I print a large collection object. However, it not works well with collections.deque. rich.print and builtins.print are showing non-whitespace differences.

In [1]: import rich
   ...: import rich.pretty
   ...: from rich import print
   ...: 
   ...: rich.pretty.install(indent_guides=True)

In [2]: print
Out[2]: <function rich.print(*objects: Any, sep: str = ' ', end: str = '\n', file: Optional[IO[str]] = None, flush: bool = False) -> None>

In [3]: from collections import deque

In [4]: import builtins

In [5]: d = deque([1, 2, 3])

In [6]: print(d)
deque([1, 2, 3])

In [7]: builtins.print(d)
deque([1, 2, 3])

In [8]: d
Out[8]: deque([1, 2, 3])

In [9]: repr(d)
Out[9]: 'deque([1, 2, 3])'

In [10]: d = deque([1, 2, 3], maxlen=5)

In [11]: print(d)
deque([1, 2, 3])

In [12]: builtins.print(d)
deque([1, 2, 3], maxlen=5)

In [13]: d
Out[13]: deque([1, 2, 3])

In [14]: repr(d)
Out[14]: 'deque([1, 2, 3], maxlen=5)'

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
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=221 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 67                                                            │
│    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=221, height=67),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=221,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=67,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=221, height=67)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 221                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-256color',      │
│     'COLORTERM': 'truecolor',      │
│     'CLICOLOR': None,              │
│     'NO_COLOR': None,              │
│     'TERM_PROGRAM': 'vscode',      │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JUPYTER_COLUMNS': None,       │
│     'JUPYTER_LINES': None,         │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯
platform="Linux"

rich==13.3.1
@github-actions
Copy link

github-actions bot commented Mar 7, 2023

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

Copy link

github-actions bot commented Jul 1, 2024

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant