def rstrip_last_char(input_str, char_to_strip):
    """
    Strips the last `char_to_strip` from input_str if
    input_str ends with `char_to_strip`.

    :param input_str: Input string to be stripped.
    :type input_str: ``str``

    :rtype: ``str``
    """
    if not input_str:
        return input_str

    if not char_to_strip:
        return input_str

    if input_str.endswith(char_to_strip):
        return input_str[: -len(char_to_strip)]

    return input_str

    Strips the last `char_to_strip` from input_str if
    input_str ends with `char_to_strip`.

    :param input_str: Input string to be stripped.
    :type input_str: ``str``

    :rtype: ``str``
    
st2common/st2common/util/misc.py