from datetime import datetime


def years_query(query):
    """
    process a year query and returns the list of years integers
    satisfying the query.
    ex.
    "2020,2021,2023" --> [2020, 2021, 2023]
    "2020-2022" --> [2020, 2021, 2022]
    "2020, 2021-2023" --> [2020, 2021, 2022, 2023]
    "2020-" --> [2020, 2021, ..., datetime.now().year]
    """
    coma_sep = [comp.strip() for comp in query.split(",")]
    years_list = []
    for comp in coma_sep:
        if comp.find('-') >= 0:
            start, end = comp.split('-')
            if len(start.strip()) == 0:
                start = 2010
            else:
                start = int(start.strip())
            if len(end.strip()) == 0:
                end = datetime.now().year
            else:
                end = int(end.strip())
            years_list += list(range(start, end + 1))

        else:
            if len(comp.strip()) > 0:
                years_list.append(int(comp))
    return list(set(years_list))