def has_python_shebang(filepath, accepted_shebangs=None):
    """Checks if the filepath is a python script.

    The file is a python script if the first line starts with '#!' and
    contains of the accepted shebangs. For example, a file starting with
    '#!usr/bin/python3' would return True if the list of shebangs was
    ['python'].

    Args:
        filepath (str): The filepath of the file to check.
        accepted_shebangs (list(str) or None): The list of shebangs
            that constitute a python script. If None, the default list
            of ['python'] is used.

    Returns:
        bool: True if the filepath matches the accepted shebangs.
    """
    if accepted_shebangs is None:
        accepted_shebangs = ['python']
    with open(filepath, 'r') as script:
        try:
            first_line = script.readline().strip()
        except UnicodeDecodeError:
            return False
    if first_line.startswith('#!'):
        for script in accepted_shebangs:
            if script in first_line:
                return True
    return False
