Skip to content

[BUG] rich.Console.input method fails to propagate the "end" attribute of passed "prompt" TextType #3643

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

Open
2 tasks done
AetherBreaker opened this issue Feb 27, 2025 · 2 comments

Comments

@AetherBreaker
Copy link

Describe the bug

As stated in the title.

The "input" method of the Console class in rich.console.py fails to propagate the "end" attribute of the prompt variable passed in as one of the methods inputs when calling self.print()

It instead ignores the value of prompt.end and instead passes end="" to self.print()

def input(
    self,
    prompt: TextType = "",
    *,
    markup: bool = True,
    emoji: bool = True,
    password: bool = False,
    stream: Optional[TextIO] = None,
) -> str:
    """Displays a prompt and waits for input from the user. The prompt may contain color / style.

    It works in the same way as Python's builtin :func:`input` function and provides elaborate line editing and history features if Python's builtin :mod:`readline` module is previously loaded.

    Args:
        prompt (Union[str, Text]): Text to render in the prompt.
        markup (bool, optional): Enable console markup (requires a str prompt). Defaults to True.
        emoji (bool, optional): Enable emoji (requires a str prompt). Defaults to True.
        password: (bool, optional): Hide typed text. Defaults to False.
        stream: (TextIO, optional): Optional file to read input from (rather than stdin). Defaults to None.

    Returns:
        str: Text read from stdin.
    """
    if prompt:
        self.print(prompt, markup=markup, emoji=emoji, end="")
Copy link

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

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

2 participants
@AetherBreaker and others