Skip to content

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

@AetherBreaker

Description

@AetherBreaker

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="")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions