from pathlib import Path


def libcst_parser_syntax_error_message(path: Path, err) -> str:
    """Refactor `LibCST.ParserSyntaxError` message.

    :param path: where the exception has occurred.
    :param err: instance of `LibCST.ParserSyntaxError`.
    :returns: refactored message.
    """
    location = f"{path}:{err.raw_line}:{err.raw_column}"
    line = err._lines[0].replace("\n", "").lstrip()
    postfix = f" {line!r}"
    return f"{location} libcst.ParserSyntaxError: {err.message.rstrip('.')}:{postfix}"