def strip_comments(line: str) -> str:
    """Remove comments from line"""
    # comment at the beginning of the line
    if line.startswith("#"):
        return ""

    # in-line comment
    left = line.rsplit("#", 1)[0]
    # be sure we are not inside a string
    if left.count('"') % 2 == 0 and left.count("'") % 2 == 0:
        return left.strip()

    return line