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] Panel docstring says the "box" parameter is optional, when it is not #3609

Open
3 tasks done
kotfu opened this issue Jan 19, 2025 · 3 comments · May be fixed by #3610
Open
3 tasks done

[BUG] Panel docstring says the "box" parameter is optional, when it is not #3609

kotfu opened this issue Jan 19, 2025 · 3 comments · May be fixed by #3610

Comments

@kotfu
Copy link

kotfu commented Jan 19, 2025

  • I've checked docs and closed issues for possible solutions.
  • I can't find my issue in the FAQ.
  • I also checked open issues and didn't see anything like this

Describe the bug

Printing a Panel with box=None raises an AttributeError: 'NoneType' object has no attribute 'substitute'

import rich.console
import rich.panel

c = rich.console.Console()
c.print(rich.panel.Panel("Hello there."))
c.print(rich.panel.Panel("General Kenobi.", box=rich.box.DOUBLE))
c.print(rich.panel.Panel("You are a bold one.", box=None))

Image

Platform

Click to expand

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?

MacOS 15.2 on Mac Studio with Apple M1 Max. Terminal software is iTerm. Python version 3.13.1.

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=100 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 25                                                            │
│    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=100, height=25),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=100,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=25,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=100, height=25)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 100                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <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': 'iTerm.app',   │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JUPYTER_COLUMNS': None,       │
│     'JUPYTER_LINES': None,         │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯
platform="Darwin"
rich==13.9.4
rich-argparse==1.6.0
@willmcgugan
Copy link
Collaborator

willmcgugan commented Jan 19, 2025

The box parameter doesn't accept None, which you can see from the reference.

@willmcgugan willmcgugan reopened this Jan 19, 2025
@Textualize Textualize deleted a comment from github-actions bot Jan 19, 2025
@willmcgugan
Copy link
Collaborator

Ah, the docstring is in error. The box isn't optional, contrary to the docstring.

@willmcgugan willmcgugan changed the title [BUG] Printing a Panel with box=None raises an Attribute Error [BUG] Panel docstring says the "box" parameter is optional, when it is not Jan 19, 2025
@Textualize Textualize deleted a comment from github-actions bot Jan 19, 2025
@kotfu
Copy link
Author

kotfu commented Jan 19, 2025

Gotcha. I'm happy to make a PR.

@kotfu kotfu linked a pull request Jan 19, 2025 that will close this issue
7 tasks
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.

2 participants