Skip to content

remove_prefix

faststream.cli.utils.parser.remove_prefix #

remove_prefix(text: str, prefix: str) -> str

Removes a prefix from a given text.

PARAMETER DESCRIPTION
text

The text from which the prefix will be removed.

TYPE: str

prefix

The prefix to be removed from the text.

TYPE: str

RETURNS DESCRIPTION
str

The text with the prefix removed. If the text does not start with the prefix, the original text is returned.

TYPE: str

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

Source code in faststream/cli/utils/parser.py
def remove_prefix(text: str, prefix: str) -> str:
    """Removes a prefix from a given text.

    Args:
        text (str): The text from which the prefix will be removed.
        prefix (str): The prefix to be removed from the text.

    Returns:
        str: The text with the prefix removed. If the text does not start with the prefix, the original text is returned.
    !!! note

        The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
    """
    if text.startswith(prefix):
        return text[len(prefix) :]
    return text

Last update: 2023-11-13