def strip_punctuation(data: Union[str, spacy.tokens.doc.Doc]) -> str:
    """
    Removes all punctuation from `data`.
    """
    if isinstance(data, str):
        return data.rstrip(string.punctuation)
    elif isinstance(data, spacy.tokens.doc.Doc):
        while len(data) and data[-1].is_punct:
            data = data[:-1]
    else:
        # Can log a warning here, but it may get noisy.
        pass
    return str(data)
Removes all punctuation from `data`.
allennlp/confidence_checks/task_checklists/utils.py