[go: nahoru, domu]

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] importing readline breaks rich prompt alignement #2994

Open
2 tasks done
gboutry opened this issue Jun 9, 2023 · 2 comments
Open
2 tasks done

[BUG] importing readline breaks rich prompt alignement #2994

gboutry opened this issue Jun 9, 2023 · 2 comments

Comments

@gboutry
Copy link
gboutry commented Jun 9, 2023

Describe the bug

Importing the library pyroute2 breaks the Rich prompting. Accepting a default (by pressing enter) does not output a new line.

With pyroute2 imported:
image

Without pyroute2 imported:
image

Minimal reproducible code:

Snippet:

# pip install rich pyroute2
from rich.prompt import Prompt

import pyroute2

name = Prompt.ask("Enter your name", choices=["Paul", "Jessica", "Duncan"], default="Paul")
last = Prompt.ask("Enter your last name", default="Atreides")

Platform

Click to expand

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
Linux Ubuntu 22.04, Kitty, but reproducible with gnome-terminal
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
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=248 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 62                                                            │
│    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=248, height=62),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=248,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=62,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=248, height=62)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 248                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <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': None,                                                                                                                                                                                                                            │
│     'COLUMNS': None,                                                                                                                                                                                                                                 │
│     'LINES': None,                                                                                                                                                                                                                                   │
│     'JUPYTER_COLUMNS': None,                                                                                                                                                                                                                         │
│     'JUPYTER_LINES': None,                                                                                                                                                                                                                           │
│     'JPY_PARENT_PID': None,                                                                                                                                                                                                                          │
│     'VSCODE_VERBOSE_LOGGING': None                                                                                                                                                                                                                   │
│ }                                                                                                                                                                                                                                                    │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
platform="Linux"
pip freeze | grep rich
rich==13.4.1
@github-actions
Copy link
github-actions bot commented Jun 9, 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

@gboutry
Copy link
Author
gboutry commented Jun 9, 2023

As far as I can tell, the issue actually comes from importing readline here

Updated snippet

from rich.prompt import Prompt
import readline

name = Prompt.ask("Enter your name", choices=["Paul", "Jessica", "Duncan"], default="Paul")
last = Prompt.ask("Enter your last name", default="Atreides")

@gboutry gboutry changed the title [BUG] importing pyroute2 breaks rich prompt alignement [BUG] importing readline breaks rich prompt alignement Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant