diff --git a/holidays/__init__.py b/holidays/__init__.py index 439f79f83..ed78e0a7c 100644 --- a/holidays/__init__.py +++ b/holidays/__init__.py @@ -12,8 +12,7 @@ # License: MIT (see LICENSE file) from holidays.countries import * from holidays.constants import MON, TUE, WED, THU, FRI, SAT, SUN, WEEKEND -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase, createHolidaySum from holidays.utils import list_supported_countries, CountryHoliday diff --git a/holidays/constants.py b/holidays/constants.py index ff61883ae..161069b82 100644 --- a/holidays/constants.py +++ b/holidays/constants.py @@ -14,5 +14,4 @@ MON, TUE, WED, THU, FRI, SAT, SUN = range(7) WEEKEND = (SAT, SUN) -JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC = range(1, 13) +JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC = range(1, 13) diff --git a/holidays/countries/argentina.py b/holidays/countries/argentina.py index a1afa4ca0..181314849 100644 --- a/holidays/countries/argentina.py +++ b/holidays/countries/argentina.py @@ -17,8 +17,7 @@ from dateutil.relativedelta import relativedelta as rd, FR, TH from holidays.constants import WEEKEND -from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -29,7 +28,7 @@ class Argentina(HolidayBase): # https://www.clarin.com/feriados/ def __init__(self, **kwargs): - self.country = 'AR' + self.country = "AR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -45,8 +44,10 @@ def _populate(self, year): self[easter(year) - rd(days=47)] = name # Memory's National Day for the Truth and Justice - name = "Día Nacional de la Memoria por la Verdad y la Justicia " \ - "[Memory's National Day for the Truth and Justice]" + name = ( + "Día Nacional de la Memoria por la Verdad y la Justicia " + "[Memory's National Day for the Truth and Justice]" + ) if not self.observed and date(year, MAR, 24).weekday() in WEEKEND: pass @@ -56,7 +57,7 @@ def _populate(self, year): # Holy Week name_thu = "Semana Santa (Jueves Santo) [Holy day (Holy Thursday)]" name_fri = "Semana Santa (Viernes Santo) [Holy day (Holy Friday)]" - name_easter = 'Día de Pascuas [Easter Day]' + name_easter = "Día de Pascuas [Easter Day]" self[easter(year) + rd(weekday=TH(-1))] = name_thu self[easter(year) + rd(weekday=FR(-1))] = name_fri @@ -70,10 +71,12 @@ def _populate(self, year): if not self.observed and date(year, APR, 2).weekday() in WEEKEND: pass else: - self[date(year, APR, 2)] = "Día del Veterano y de los Caidos " \ - "en la Guerra de Malvinas [Veterans" \ - " Day and the Fallen in the" \ + self[date(year, APR, 2)] = ( + "Día del Veterano y de los Caidos " + "en la Guerra de Malvinas [Veterans" + " Day and the Fallen in the" " Malvinas War]" + ) # Labor Day name = "Día del Trabajo [Labour Day]" @@ -90,18 +93,22 @@ def _populate(self, year): self[date(year, MAY, 25)] = name # Day Pass to the Immortality of General Martín Miguel de Güemes. - name = "Día Pase a la Inmortalidad " \ - "del General Martín Miguel de Güemes [Day Pass " \ - "to the Immortality of General Martín Miguel de Güemes]" + name = ( + "Día Pase a la Inmortalidad " + "del General Martín Miguel de Güemes [Day Pass " + "to the Immortality of General Martín Miguel de Güemes]" + ) if not self.observed and date(year, JUN, 17).weekday() in WEEKEND: pass else: self[date(year, JUN, 17)] = name # Day Pass to the Immortality of General D. Manuel Belgrano. - name = "Día Pase a la Inmortalidad " \ - "del General D. Manuel Belgrano [Day Pass " \ - "to the Immortality of General D. Manuel Belgrano]" + name = ( + "Día Pase a la Inmortalidad " + "del General D. Manuel Belgrano [Day Pass " + "to the Immortality of General D. Manuel Belgrano]" + ) if not self.observed and date(year, JUN, 20).weekday() in WEEKEND: pass else: @@ -115,9 +122,11 @@ def _populate(self, year): self[date(year, JUL, 9)] = name # Day Pass to the Immortality of General D. José de San Martin - name = "Día Pase a la Inmortalidad " \ - "del General D. José de San Martin [Day Pass " \ - "to the Immortality of General D. José de San Martin]" + name = ( + "Día Pase a la Inmortalidad " + "del General D. José de San Martin [Day Pass " + "to the Immortality of General D. José de San Martin]" + ) if not self.observed and date(year, AUG, 17).weekday() in WEEKEND: pass else: @@ -129,9 +138,11 @@ def _populate(self, year): elif year < 2010: self[date(year, OCT, 12)] = "Día de la Raza [Columbus day]" else: - self[date(year, OCT, 12)] = "Día del Respeto a la Diversidad" \ - " Cultural [Respect for" \ + self[date(year, OCT, 12)] = ( + "Día del Respeto a la Diversidad" + " Cultural [Respect for" " Cultural Diversity Day]" + ) # National Sovereignty Day name = "Día Nacional de la Soberanía [National Sovereignty Day]" if not self.observed and date(year, NOV, 20).weekday() in WEEKEND: @@ -143,8 +154,7 @@ def _populate(self, year): if not self.observed and date(year, DEC, 8).weekday() in WEEKEND: pass else: - self[date(year, DEC, 8)] = "La Inmaculada Concepción" \ - " [Immaculate Conception]" + self[date(year, DEC, 8)] = "La Inmaculada Concepción" " [Immaculate Conception]" # Christmas self[date(year, DEC, 25)] = "Navidad [Christmas]" diff --git a/holidays/countries/aruba.py b/holidays/countries/aruba.py index 89c55275c..ba7c2218e 100644 --- a/holidays/countries/aruba.py +++ b/holidays/countries/aruba.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR -from holidays.constants import JAN, MAR, APR, MAY, AUG, \ - DEC +from holidays.constants import JAN, MAR, APR, MAY, AUG, DEC from holidays.holiday_base import HolidayBase @@ -26,7 +25,7 @@ class Aruba(HolidayBase): # https://www.visitaruba.com/about-aruba/national-holidays-and-celebrations/ def __init__(self, **kwargs): - self.country = 'AW' + self.country = "AW" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -37,18 +36,24 @@ def _populate(self, year): self[date(year, JAN, 25)] = "Dia Di Betico [Betico Day]" # Carnaval Monday - self[easter(year) + rd(days=-48)] = "Dialuna di Carnaval \ + self[ + easter(year) + rd(days=-48) + ] = "Dialuna di Carnaval \ [Carnaval Monday]" # Dia di Himno y Bandera - self[date(year, MAR, 18)] = "Dia di Himno y Bandera \ + self[ + date(year, MAR, 18) + ] = "Dia di Himno y Bandera \ [National Anthem & Flag Day]" # Good Friday self[easter(year) + rd(weekday=FR(-1))] = "Bierna Santo [Good Friday]" # Easter Monday - self[easter(year) + rd(days=1)] = "Di Dos Dia di Pasco di Resureccion \ + self[ + easter(year) + rd(days=1) + ] = "Di Dos Dia di Pasco di Resureccion \ [Easter Monday]" # King's Day @@ -83,7 +88,9 @@ def _populate(self, year): self[date(year, DEC, 25)] = "Pasco di Nacemento [Christmas]" # Second Christmas - self[date(year, DEC, 26)] = "Di Dos Dia di Pasco di \ + self[ + date(year, DEC, 26) + ] = "Di Dos Dia di Pasco di \ Nacemento [Second Christmas]" diff --git a/holidays/countries/australia.py b/holidays/countries/australia.py index 00bf89f7e..fe9820af0 100644 --- a/holidays/countries/australia.py +++ b/holidays/countries/australia.py @@ -16,18 +16,17 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, SA, FR, WE, TU -from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, SEP, OCT, NOV, DEC from holidays.constants import SAT, SUN, WEEKEND from holidays.holiday_base import HolidayBase class Australia(HolidayBase): - PROVINCES = ['ACT', 'NSW', 'NT', 'QLD', 'SA', 'TAS', 'VIC', 'WA'] + PROVINCES = ["ACT", "NSW", "NT", "QLD", "SA", "TAS", "VIC", "WA"] def __init__(self, **kwargs): - self.country = 'AU' - self.prov = kwargs.pop('prov', None) + self.country = "AU" + self.prov = kwargs.pop("prov", None) HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -52,19 +51,19 @@ def _populate(self, year): # Australia Day jan26 = date(year, JAN, 26) if year >= 1935: - if self.prov == 'NSW' and year < 1946: + if self.prov == "NSW" and year < 1946: name = "Anniversary Day" else: name = "Australia Day" self[jan26] = name if self.observed and year >= 1946 and jan26.weekday() in WEEKEND: self[jan26 + rd(weekday=MO)] = name + " (Observed)" - elif year >= 1888 and self.prov != 'SA': + elif year >= 1888 and self.prov != "SA": name = "Anniversary Day" self[jan26] = name # Adelaide Cup - if self.prov == 'SA': + if self.prov == "SA": name = "Adelaide Cup" if year >= 2006: # subject to proclamation ?!?! @@ -75,7 +74,7 @@ def _populate(self, year): # Canberra Day # Info from https://www.timeanddate.com/holidays/australia/canberra-day # and https://en.wikipedia.org/wiki/Canberra_Day - if self.prov == 'ACT' and year >= 1913: + if self.prov == "ACT" and year >= 1913: name = "Canberra Day" if year >= 1913 and year <= 1957: self[date(year, MAR, 12)] = name @@ -88,9 +87,9 @@ def _populate(self, year): # Easter self[easter(year) + rd(weekday=FR(-1))] = "Good Friday" - if self.prov in ('ACT', 'NSW', 'NT', 'QLD', 'SA', 'VIC'): + if self.prov in ("ACT", "NSW", "NT", "QLD", "SA", "VIC"): self[easter(year) + rd(weekday=SA(-1))] = "Easter Saturday" - if self.prov in ('ACT', 'NSW', 'QLD', 'VIC'): + if self.prov in ("ACT", "NSW", "QLD", "VIC"): self[easter(year)] = "Easter Sunday" self[easter(year) + rd(weekday=MO)] = "Easter Monday" @@ -100,14 +99,13 @@ def _populate(self, year): apr25 = date(year, APR, 25) self[apr25] = name if self.observed: - if apr25.weekday() == SAT and self.prov in ('WA', 'NT'): + if apr25.weekday() == SAT and self.prov in ("WA", "NT"): self[apr25 + rd(weekday=MO)] = name + " (Observed)" - elif (apr25.weekday() == SUN and - self.prov in ('ACT', 'QLD', 'SA', 'WA', 'NT')): + elif apr25.weekday() == SUN and self.prov in ("ACT", "QLD", "SA", "WA", "NT"): self[apr25 + rd(weekday=MO)] = name + " (Observed)" # Western Australia Day - if self.prov == 'WA' and year > 1832: + if self.prov == "WA" and year > 1832: if year >= 2015: name = "Western Australia Day" else: @@ -121,7 +119,7 @@ def _populate(self, year): name = "King's Birthday" if year >= 1936: name = "Queen's Birthday" - if self.prov == 'QLD': + if self.prov == "QLD": if year == 2012: self[date(year, JUN, 11)] = "Queen's Diamond Jubilee" if year < 2016 and year != 2012: @@ -130,10 +128,10 @@ def _populate(self, year): else: dt = date(year, OCT, 1) + rd(weekday=MO) self[dt] = name - elif self.prov == 'WA': + elif self.prov == "WA": # by proclamation ?!?! self[date(year, OCT, 1) + rd(weekday=MO(-1))] = name - elif self.prov in ('NSW', 'VIC', 'ACT', 'SA', 'NT', 'TAS'): + elif self.prov in ("NSW", "VIC", "ACT", "SA", "NT", "TAS"): dt = date(year, JUN, 1) + rd(weekday=MO(+2)) self[dt] = name elif year > 1911: @@ -142,38 +140,38 @@ def _populate(self, year): self[date(year, NOV, 9)] = name # Edward VII # Picnic Day - if self.prov == 'NT': + if self.prov == "NT": name = "Picnic Day" self[date(year, AUG, 1) + rd(weekday=MO)] = name # Bank Holiday - if self.prov == 'NSW': + if self.prov == "NSW": if year >= 1912: name = "Bank Holiday" self[date(year, 8, 1) + rd(weekday=MO)] = name # Labour Day name = "Labour Day" - if self.prov in ('NSW', 'ACT', 'SA'): + if self.prov in ("NSW", "ACT", "SA"): self[date(year, OCT, 1) + rd(weekday=MO)] = name - elif self.prov == 'WA': + elif self.prov == "WA": self[date(year, MAR, 1) + rd(weekday=MO)] = name - elif self.prov == 'VIC': + elif self.prov == "VIC": self[date(year, MAR, 1) + rd(weekday=MO(+2))] = name - elif self.prov == 'QLD': + elif self.prov == "QLD": if 2013 <= year <= 2015: self[date(year, OCT, 1) + rd(weekday=MO)] = name else: self[date(year, MAY, 1) + rd(weekday=MO)] = name - elif self.prov == 'NT': + elif self.prov == "NT": name = "May Day" self[date(year, MAY, 1) + rd(weekday=MO)] = name - elif self.prov == 'TAS': + elif self.prov == "TAS": name = "Eight Hours Day" self[date(year, MAR, 1) + rd(weekday=MO(+2))] = name # Family & Community Day - if self.prov == 'ACT': + if self.prov == "ACT": name = "Family & Community Day" if 2007 <= year <= 2009: self[date(year, NOV, 1) + rd(weekday=TU)] = name @@ -199,12 +197,12 @@ def _populate(self, year): self[date(year, SEP, 25)] = name # Reconciliation Day - if self.prov == 'ACT': + if self.prov == "ACT": name = "Reconciliation Day" if year >= 2018: self[date(year, 5, 27) + rd(weekday=MO)] = name - if self.prov == 'VIC': + if self.prov == "VIC": # Grand Final Day if year == 2020: # Rescheduled due to COVID-19 @@ -219,7 +217,7 @@ def _populate(self, year): # The Show starts on the first Friday of August - providing this is # not prior to the 5th - in which case it will begin on the second # Friday. The Wednesday during the show is a public holiday. - if self.prov == 'QLD': + if self.prov == "QLD": name = "The Royal Queensland Show" if year == 2020: self[date(year, AUG, 14)] = name @@ -235,7 +233,7 @@ def _populate(self, year): self[date(year, DEC, 27)] = name + " (Observed)" # Boxing Day - if self.prov == 'SA': + if self.prov == "SA": name = "Proclamation Day" else: name = "Boxing Day" diff --git a/holidays/countries/austria.py b/holidays/countries/austria.py index a18e96141..8e4649497 100644 --- a/holidays/countries/austria.py +++ b/holidays/countries/austria.py @@ -16,17 +16,16 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO -from holidays.constants import JAN, MAY, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase class Austria(HolidayBase): - PROVINCES = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] + PROVINCES = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] def __init__(self, **kwargs): - self.country = 'AT' - self.prov = kwargs.pop('prov', kwargs.pop('state', '9')) + self.country = "AT" + self.prov = kwargs.pop("prov", kwargs.pop("state", "9")) HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/belarus.py b/holidays/countries/belarus.py index 471722614..27efba422 100644 --- a/holidays/countries/belarus.py +++ b/holidays/countries/belarus.py @@ -46,8 +46,7 @@ def _populate(self, year): self[date(year, JAN, 2)] = "Новый год" # Christmas Day (Orthodox) - self[date(year, JAN, 7)] = "Рождество Христово " \ - "(православное Рождество)" + self[date(year, JAN, 7)] = "Рождество Христово " "(православное Рождество)" # Women's Day self[date(year, MAR, 8)] = "День женщин" @@ -62,15 +61,13 @@ def _populate(self, year): self[date(year, MAY, 9)] = "День Победы" # Independence Day - self[date(year, JUL, 3)] = "День Независимости Республики Беларусь " \ - "(День Республики)" + self[date(year, JUL, 3)] = "День Независимости Республики Беларусь " "(День Республики)" # October Revolution Day self[date(year, NOV, 7)] = "День Октябрьской революции" # Christmas Day (Catholic) - self[date(year, DEC, 25)] = "Рождество Христово " \ - "(католическое Рождество)" + self[date(year, DEC, 25)] = "Рождество Христово " "(католическое Рождество)" class BY(Belarus): diff --git a/holidays/countries/brazil.py b/holidays/countries/brazil.py index 49b4e2520..6d2f1420f 100644 --- a/holidays/countries/brazil.py +++ b/holidays/countries/brazil.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, TU -from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -26,12 +25,38 @@ class Brazil(HolidayBase): https://pt.wikipedia.org/wiki/Feriados_no_Brasil """ - STATES = ['AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 'MA', 'MT', - 'MS', 'MG', 'PA', 'PB', 'PE', 'PI', 'PR', 'RJ', 'RN', 'RS', 'RO', - 'RR', 'SC', 'SP', 'SE', 'TO'] + STATES = [ + "AC", + "AL", + "AP", + "AM", + "BA", + "CE", + "DF", + "ES", + "GO", + "MA", + "MT", + "MS", + "MG", + "PA", + "PB", + "PE", + "PI", + "PR", + "RJ", + "RN", + "RS", + "RO", + "RR", + "SC", + "SP", + "SE", + "TO", + ] def __init__(self, **kwargs): - self.country = 'BR' + self.country = "BR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -64,110 +89,105 @@ def _populate(self, year): self[quaresma - rd(weekday=TU(-1))] = "Carnaval" - if self.state == 'AC': + if self.state == "AC": self[date(year, JAN, 23)] = "Dia do evangélico" self[date(year, JUN, 15)] = "Aniversário do Acre" self[date(year, SEP, 5)] = "Dia da Amazônia" - self[date(year, NOV, 17)] = "Assinatura do Tratado de" \ - " Petrópolis" + self[date(year, NOV, 17)] = "Assinatura do Tratado de" " Petrópolis" - if self.state == 'AL': + if self.state == "AL": self[date(year, JUN, 24)] = "São João" self[date(year, JUN, 29)] = "São Pedro" self[date(year, SEP, 16)] = "Emancipação política de Alagoas" self[date(year, NOV, 20)] = "Consciência Negra" - if self.state == 'AP': + if self.state == "AP": self[date(year, MAR, 19)] = "Dia de São José" self[date(year, JUL, 25)] = "São Tiago" self[date(year, OCT, 5)] = "Criação do estado" self[date(year, NOV, 20)] = "Consciência Negra" - if self.state == 'AM': - self[date(year, SEP, 5)] = "Elevação do Amazonas" \ - " à categoria de província" + if self.state == "AM": + self[date(year, SEP, 5)] = "Elevação do Amazonas" " à categoria de província" self[date(year, NOV, 20)] = "Consciência Negra" self[date(year, DEC, 8)] = "Dia de Nossa Senhora da Conceição" - if self.state == 'BA': + if self.state == "BA": self[date(year, JUL, 2)] = "Independência da Bahia" - if self.state == 'CE': + if self.state == "CE": self[date(year, MAR, 19)] = "São José" self[date(year, MAR, 25)] = "Data Magna do Ceará" - if self.state == 'DF': + if self.state == "DF": self[date(year, APR, 21)] = "Fundação de Brasília" self[date(year, NOV, 30)] = "Dia do Evangélico" - if self.state == 'ES': + if self.state == "ES": self[date(year, OCT, 28)] = "Dia do Servidor Público" - if self.state == 'GO': + if self.state == "GO": self[date(year, OCT, 28)] = "Dia do Servidor Público" - if self.state == 'MA': - self[date(year, JUL, 28)] = "Adesão do Maranhão" \ - " à independência do Brasil" + if self.state == "MA": + self[date(year, JUL, 28)] = "Adesão do Maranhão" " à independência do Brasil" self[date(year, DEC, 8)] = "Dia de Nossa Senhora da Conceição" - if self.state == 'MT': + if self.state == "MT": self[date(year, NOV, 20)] = "Consciência Negra" - if self.state == 'MS': + if self.state == "MS": self[date(year, OCT, 11)] = "Criação do estado" - if self.state == 'MG': + if self.state == "MG": self[date(year, APR, 21)] = "Data Magna de MG" - if self.state == 'PA': - self[date(year, AUG, 15)] = "Adesão do Grão-Pará" \ - " à independência do Brasil" + if self.state == "PA": + self[date(year, AUG, 15)] = "Adesão do Grão-Pará" " à independência do Brasil" - if self.state == 'PB': + if self.state == "PB": self[date(year, AUG, 5)] = "Fundação do Estado" - if self.state == 'PE': + if self.state == "PE": self[date(year, MAR, 6)] = "Revolução Pernambucana (Data Magna)" self[date(year, JUN, 24)] = "São João" - if self.state == 'PI': + if self.state == "PI": self[date(year, MAR, 13)] = "Dia da Batalha do Jenipapo" self[date(year, OCT, 19)] = "Dia do Piauí" - if self.state == 'PR': + if self.state == "PR": self[date(year, DEC, 19)] = "Emancipação do Paraná" - if self.state == 'RJ': + if self.state == "RJ": self[date(year, APR, 23)] = "Dia de São Jorge" self[date(year, OCT, 28)] = "Dia do Funcionário Público" self[date(year, NOV, 20)] = "Zumbi dos Palmares" - if self.state == 'RN': + if self.state == "RN": self[date(year, JUN, 29)] = "Dia de São Pedro" self[date(year, OCT, 3)] = "Mártires de Cunhaú e Uruaçuu" - if self.state == 'RS': + if self.state == "RS": self[date(year, SEP, 20)] = "Revolução Farroupilha" - if self.state == 'RO': + if self.state == "RO": self[date(year, JAN, 4)] = "Criação do estado" self[date(year, JUN, 18)] = "Dia do Evangélico" - if self.state == 'RR': + if self.state == "RR": self[date(year, OCT, 5)] = "Criação de Roraima" - if self.state == 'SC': - self[date(year, AUG, 11)] = "Criação da capitania," \ - " separando-se de SP" + if self.state == "SC": + self[date(year, AUG, 11)] = "Criação da capitania," " separando-se de SP" - if self.state == 'SP': + if self.state == "SP": self[date(year, JUL, 9)] = "Revolução Constitucionalista de 1932" - if self.state == 'SE': + if self.state == "SE": self[date(year, JUL, 8)] = "Autonomia política de Sergipe" - if self.state == 'TO': + if self.state == "TO": self[date(year, JAN, 1)] = "Instalação de Tocantins" self[date(year, SEP, 8)] = "Nossa Senhora da Natividade" self[date(year, OCT, 5)] = "Criação de Tocantins" diff --git a/holidays/countries/bulgaria.py b/holidays/countries/bulgaria.py index e147f51a9..5350aae3a 100644 --- a/holidays/countries/bulgaria.py +++ b/holidays/countries/bulgaria.py @@ -41,7 +41,7 @@ class Bulgaria(HolidayBase): """ def __init__(self, **kwargs): - self.country = 'BG' + self.country = "BG" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -52,20 +52,18 @@ def _populate(self, year): self[date(year, JAN, 1)] = "Нова година" # Liberation Day - self[date(year, MAR, 3)] = \ - "Ден на Освобождението на България от османско иго" + self[date(year, MAR, 3)] = "Ден на Освобождението на България от османско иго" # International Workers' Day - self[date(year, MAY, 1)] = \ - "Ден на труда и на международната работническа солидарност" + self[date(year, MAY, 1)] = "Ден на труда и на международната работническа солидарност" # Saint George's Day - self[date(year, MAY, 6)] = \ - "Гергьовден, Ден на храбростта и Българската армия" + self[date(year, MAY, 6)] = "Гергьовден, Ден на храбростта и Българската армия" # Bulgarian Education and Culture and Slavonic Literature Day - self[date(year, MAY, 24)] = \ - "Ден на българската просвета и култура и на славянската писменост" + self[ + date(year, MAY, 24) + ] = "Ден на българската просвета и култура и на славянската писменост" # Unification Day self[date(year, SEP, 6)] = "Ден на Съединението" @@ -82,10 +80,8 @@ def _populate(self, year): self[date(year, DEC, 26)] = "Рождество Христово" # Easter - self[easter(year, method=EASTER_ORTHODOX) - rd(days=2)] = \ - "Велики петък" - self[easter(year, method=EASTER_ORTHODOX) - rd(days=1)] = \ - "Велика събота" + self[easter(year, method=EASTER_ORTHODOX) - rd(days=2)] = "Велики петък" + self[easter(year, method=EASTER_ORTHODOX) - rd(days=1)] = "Велика събота" self[easter(year, method=EASTER_ORTHODOX)] = "Великден" diff --git a/holidays/countries/burundi.py b/holidays/countries/burundi.py index 56d91dd72..ed773ed08 100644 --- a/holidays/countries/burundi.py +++ b/holidays/countries/burundi.py @@ -34,7 +34,7 @@ class Burundi(HolidayBase): """ def __init__(self, **kwargs): - self.country = 'BI' + self.country = "BI" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -78,7 +78,7 @@ def _populate(self, year): self[hol_date + rd(days=1)] = "Eid Al Adha" # Assumption Day - name = 'Assumption Day' + name = "Assumption Day" self[date(year, AUG, 15)] = name # Prince Louis Rwagasore Day diff --git a/holidays/countries/canada.py b/holidays/countries/canada.py index 57d18ad8f..3466a5bb5 100644 --- a/holidays/countries/canada.py +++ b/holidays/countries/canada.py @@ -17,19 +17,16 @@ from dateutil.relativedelta import relativedelta as rd, MO, SU, FR from holidays.constants import FRI, SAT, SUN, WEEKEND -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, \ - OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase class Canada(HolidayBase): - PROVINCES = ['AB', 'BC', 'MB', 'NB', 'NL', 'NS', 'NT', 'NU', 'ON', 'PE', - 'QC', 'SK', 'YT'] + PROVINCES = ["AB", "BC", "MB", "NB", "NL", "NS", "NT", "NU", "ON", "PE", "QC", "SK", "YT"] def __init__(self, **kwargs): - self.country = 'CA' - self.prov = kwargs.pop('prov', 'ON') + self.country = "CA" + self.prov = kwargs.pop("prov", "ON") HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -38,16 +35,13 @@ def _populate(self, year): name = "New Year's Day" self[date(year, JAN, 1)] = name if self.observed and date(year, JAN, 1).weekday() == SUN: - self[date(year, JAN, 1) + rd(days=+1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, JAN, 1).weekday() == SAT: + self[date(year, JAN, 1) + rd(days=+1)] = name + " (Observed)" + elif self.observed and date(year, JAN, 1).weekday() == SAT: # Add Dec 31st from the previous year without triggering # the entire year to be added expand = self.expand self.expand = False - self[date(year, JAN, 1) + rd(days=-1)] = name + \ - " (Observed)" + self[date(year, JAN, 1) + rd(days=-1)] = name + " (Observed)" self.expand = expand # The next year's observed New Year's Day can be in this year # when it falls on a Friday (Jan 1st is a Saturday) @@ -56,32 +50,29 @@ def _populate(self, year): # Family Day / Louis Riel Day (MB) / Islander Day (PE) # / Heritage Day (NS, YT) - if self.prov in ('AB', 'SK', 'ON') and year >= 2008: + if self.prov in ("AB", "SK", "ON") and year >= 2008: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" - elif self.prov in ('AB', 'SK') and year >= 2007: + elif self.prov in ("AB", "SK") and year >= 2007: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" - elif self.prov == 'AB' and year >= 1990: + elif self.prov == "AB" and year >= 1990: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" - elif self.prov == 'NB' and year >= 2018: + elif self.prov == "NB" and year >= 2018: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" - elif self.prov == 'BC': + elif self.prov == "BC": if year >= 2013 and year <= 2018: - self[date(year, FEB, 1) + rd(weekday=MO(+2))] = \ - "Family Day" + self[date(year, FEB, 1) + rd(weekday=MO(+2))] = "Family Day" elif year > 2018: - self[date(year, FEB, 1) + rd(weekday=MO(+3))] = \ - "Family Day" - elif self.prov == 'MB' and year >= 2008: - self[date(year, FEB, 1) + rd(weekday=MO(+3))] = \ - "Louis Riel Day" - elif self.prov == 'PE' and year >= 2010: + self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Family Day" + elif self.prov == "MB" and year >= 2008: + self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Louis Riel Day" + elif self.prov == "PE" and year >= 2010: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Islander Day" - elif self.prov == 'PE' and year == 2009: + elif self.prov == "PE" and year == 2009: self[date(year, FEB, 1) + rd(weekday=MO(+2))] = "Islander Day" - elif self.prov == 'NS' and year >= 2015: + elif self.prov == "NS" and year >= 2015: # http://novascotia.ca/lae/employmentrights/NovaScotiaHeritageDay.asp self[date(year, FEB, 1) + rd(weekday=MO(+3))] = "Heritage Day" - elif self.prov == 'YT': + elif self.prov == "YT": # start date? # http://heritageyukon.ca/programs/heritage-day # https://en.wikipedia.org/wiki/Family_Day_(Canada)#Yukon_Heritage_Day @@ -90,7 +81,7 @@ def _populate(self, year): self[dt] = "Heritage Day" # St. Patrick's Day - if self.prov == 'NL' and year >= 1900: + if self.prov == "NL" and year >= 1900: dt = date(year, MAR, 17) # Nearest Monday to March 17 dt1 = date(year, MAR, 17) + rd(weekday=MO(-1)) @@ -101,19 +92,19 @@ def _populate(self, year): self[dt1] = "St. Patrick's Day" # Good Friday - if self.prov != 'QC' and year >= 1867: + if self.prov != "QC" and year >= 1867: self[easter(year) + rd(weekday=FR(-1))] = "Good Friday" # Easter Monday - if self.prov == 'QC' and year >= 1867: + if self.prov == "QC" and year >= 1867: self[easter(year) + rd(weekday=MO)] = "Easter Monday" # St. George's Day - if self.prov == 'NL' and year == 2010: + if self.prov == "NL" and year == 2010: # 4/26 is the Monday closer to 4/23 in 2010 # but the holiday was observed on 4/19? Crazy Newfies! self[date(2010, 4, 19)] = "St. George's Day" - elif self.prov == 'NL' and year >= 1990: + elif self.prov == "NL" and year >= 1990: dt = date(year, APR, 23) # Nearest Monday to April 23 dt1 = dt + rd(weekday=MO(-1)) @@ -124,24 +115,24 @@ def _populate(self, year): self[dt1] = "St. George's Day" # Victoria Day / National Patriots' Day (QC) - if self.prov not in ('NB', 'NS', 'PE', 'NL', 'QC') and year >= 1953: + if self.prov not in ("NB", "NS", "PE", "NL", "QC") and year >= 1953: self[date(year, MAY, 24) + rd(weekday=MO(-1))] = "Victoria Day" - elif self.prov == 'QC' and year >= 1953: + elif self.prov == "QC" and year >= 1953: name = "National Patriots' Day" self[date(year, MAY, 24) + rd(weekday=MO(-1))] = name # National Aboriginal Day - if self.prov == 'NT' and year >= 1996: + if self.prov == "NT" and year >= 1996: self[date(year, JUN, 21)] = "National Aboriginal Day" # St. Jean Baptiste Day - if self.prov == 'QC' and year >= 1925: + if self.prov == "QC" and year >= 1925: self[date(year, JUN, 24)] = "St. Jean Baptiste Day" if self.observed and date(year, JUN, 24).weekday() == SUN: self[date(year, JUN, 25)] = "St. Jean Baptiste Day (Observed)" # Discovery Day - if self.prov == 'NL' and year >= 1997: + if self.prov == "NL" and year >= 1997: dt = date(year, JUN, 24) # Nearest Monday to June 24 dt1 = dt + rd(weekday=MO(-1)) @@ -150,53 +141,48 @@ def _populate(self, year): self[dt2] = "Discovery Day" else: self[dt1] = "Discovery Day" - elif self.prov == 'YT' and year >= 1912: + elif self.prov == "YT" and year >= 1912: self[date(year, AUG, 1) + rd(weekday=MO(+3))] = "Discovery Day" # Canada Day / Memorial Day (NL) - if self.prov != 'NL' and year >= 1867: + if self.prov != "NL" and year >= 1867: if year >= 1983: name = "Canada Day" else: name = "Dominion Day" self[date(year, JUL, 1)] = name - if year >= 1879 and self.observed \ - and date(year, JUL, 1).weekday() in WEEKEND: - self[date(year, JUL, 1) + rd(weekday=MO)] = name + \ - " (Observed)" + if year >= 1879 and self.observed and date(year, JUL, 1).weekday() in WEEKEND: + self[date(year, JUL, 1) + rd(weekday=MO)] = name + " (Observed)" elif year >= 1867: if year >= 1983: name = "Memorial Day" else: name = "Dominion Day" self[date(year, JUL, 1)] = name - if year >= 1879 and self.observed \ - and date(year, JUL, 1).weekday() in WEEKEND: - self[date(year, JUL, 1) + rd(weekday=MO)] = name + \ - " (Observed)" + if year >= 1879 and self.observed and date(year, JUL, 1).weekday() in WEEKEND: + self[date(year, JUL, 1) + rd(weekday=MO)] = name + " (Observed)" # Nunavut Day - if self.prov == 'NU' and year >= 2001: + if self.prov == "NU" and year >= 2001: self[date(year, JUL, 9)] = "Nunavut Day" if self.observed and date(year, JUL, 9).weekday() == SUN: self[date(year, JUL, 10)] = "Nunavut Day (Observed)" - elif self.prov == 'NU' and year == 2000: + elif self.prov == "NU" and year == 2000: self[date(2000, 4, 1)] = "Nunavut Day" # Civic Holiday - if self.prov in ('ON', 'MB', 'NT') and year >= 1900: + if self.prov in ("ON", "MB", "NT") and year >= 1900: self[date(year, AUG, 1) + rd(weekday=MO)] = "Civic Holiday" - elif self.prov == 'AB' and year >= 1974: + elif self.prov == "AB" and year >= 1974: # https://en.wikipedia.org/wiki/Civic_Holiday#Alberta self[date(year, AUG, 1) + rd(weekday=MO)] = "Heritage Day" - elif self.prov == 'BC' and year >= 1974: + elif self.prov == "BC" and year >= 1974: # https://en.wikipedia.org/wiki/Civic_Holiday - self[date(year, AUG, 1) + rd(weekday=MO)] = \ - "British Columbia Day" - elif self.prov == 'NB' and year >= 1900: + self[date(year, AUG, 1) + rd(weekday=MO)] = "British Columbia Day" + elif self.prov == "NB" and year >= 1900: # https://en.wikipedia.org/wiki/Civic_Holiday self[date(year, AUG, 1) + rd(weekday=MO)] = "New Brunswick Day" - elif self.prov == 'SK' and year >= 1900: + elif self.prov == "SK" and year >= 1900: # https://en.wikipedia.org/wiki/Civic_Holiday self[date(year, AUG, 1) + rd(weekday=MO)] = "Saskatchewan Day" @@ -205,22 +191,21 @@ def _populate(self, year): self[date(year, SEP, 1) + rd(weekday=MO)] = "Labour Day" # Thanksgiving - if self.prov not in ('NB', 'NS', 'PE', 'NL') and year >= 1931: + if self.prov not in ("NB", "NS", "PE", "NL") and year >= 1931: if year == 1935: # in 1935, Canadian Thanksgiving was moved due to the General # Election falling on the second Monday of October # https://books.google.ca/books?id=KcwlQsmheG4C&pg=RA1-PA1940&lpg=RA1-PA1940&dq=canada+thanksgiving+1935&source=bl&ots=j4qYrcfGuY&sig=gxXeAQfXVsOF9fOwjSMswPHJPpM&hl=en&sa=X&ved=0ahUKEwjO0f3J2PjOAhVS4mMKHRzKBLAQ6AEIRDAG#v=onepage&q=canada%20thanksgiving%201935&f=false self[date(1935, 10, 25)] = "Thanksgiving" else: - self[date(year, OCT, 1) + rd(weekday=MO(+2))] = \ - "Thanksgiving" + self[date(year, OCT, 1) + rd(weekday=MO(+2))] = "Thanksgiving" # Remembrance Day name = "Remembrance Day" - provinces = ('ON', 'QC', 'NS', 'NL', 'NT', 'PE', 'SK') + provinces = ("ON", "QC", "NS", "NL", "NT", "PE", "SK") if self.prov not in provinces and year >= 1931: self[date(year, NOV, 11)] = name - elif self.prov in ('NS', 'NL', 'NT', 'PE', 'SK') and year >= 1931: + elif self.prov in ("NS", "NL", "NT", "PE", "SK") and year >= 1931: self[date(year, NOV, 11)] = name if self.observed and date(year, NOV, 11).weekday() == SUN: name = name + " (Observed)" @@ -229,11 +214,9 @@ def _populate(self, year): # Christmas Day if year >= 1867: self[date(year, DEC, 25)] = "Christmas Day" - if self.observed \ - and date(year, DEC, 25).weekday() == SAT: + if self.observed and date(year, DEC, 25).weekday() == SAT: self[date(year, DEC, 24)] = "Christmas Day (Observed)" - elif self.observed \ - and date(year, DEC, 25).weekday() == SUN: + elif self.observed and date(year, DEC, 25).weekday() == SUN: self[date(year, DEC, 26)] = "Christmas Day (Observed)" # Boxing Day diff --git a/holidays/countries/chile.py b/holidays/countries/chile.py index 44d52ea45..553f92e07 100644 --- a/holidays/countries/chile.py +++ b/holidays/countries/chile.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR -from holidays.constants import JAN, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.constants import WED, THU from holidays.holiday_base import HolidayBase @@ -27,7 +26,7 @@ class Chile(HolidayBase): # https://es.wikipedia.org/wiki/Anexo:D%C3%ADas_feriados_en_Chile def __init__(self, **kwargs): - self.country = 'CL' + self.country = "CL" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -36,7 +35,7 @@ def _populate(self, year): # Holy Week name_fri = "Semana Santa (Viernes Santo) [Holy day (Holy Friday)]" - name_easter = 'Día de Pascuas [Easter Day]' + name_easter = "Día de Pascuas [Easter Day]" self[easter(year) + rd(weekday=FR(-1))] = name_fri self[easter(year)] = name_easter @@ -66,8 +65,7 @@ def _populate(self, year): self[date(year, SEP, 18)] = name # Day of Glories of the Army of Chile - name = "Día de las Glorias del Ejército de Chile [Day of " \ - "Glories of the Army of Chile]" + name = "Día de las Glorias del Ejército de Chile [Day of " "Glories of the Army of Chile]" self[date(year, SEP, 19)] = name # National Holidays Ley 20.215 name = "Fiestas Patrias [National Holidays]" @@ -78,15 +76,17 @@ def _populate(self, year): if year < 2010: self[date(year, OCT, 12)] = "Día de la Raza [Columbus day]" else: - self[date(year, OCT, 12)] = "Día del Respeto a la Diversidad"\ - " [Day of the Meeting " \ - " of Two Worlds]" + self[date(year, OCT, 12)] = ( + "Día del Respeto a la Diversidad" " [Day of the Meeting " " of Two Worlds]" + ) # National Day of the Evangelical and Protestant Churches - name = "Día Nacional de las Iglesias Evangélicas y Protestantes " \ - " [National Day of the " \ - " Evangelical and " \ - " Protestant Churches]" + name = ( + "Día Nacional de las Iglesias Evangélicas y Protestantes " + " [National Day of the " + " Evangelical and " + " Protestant Churches]" + ) self[date(year, OCT, 31)] = name # All Saints Day @@ -94,8 +94,7 @@ def _populate(self, year): self[date(year, NOV, 1)] = name # Immaculate Conception - self[date(year, DEC, 8)] = "La Inmaculada Concepción" \ - " [Immaculate Conception]" + self[date(year, DEC, 8)] = "La Inmaculada Concepción" " [Immaculate Conception]" # Christmas self[date(year, DEC, 25)] = "Navidad [Christmas]" diff --git a/holidays/countries/colombia.py b/holidays/countries/colombia.py index f36a93e26..5fb9cfe16 100644 --- a/holidays/countries/colombia.py +++ b/holidays/countries/colombia.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, TH, FR -from holidays.constants import JAN, MAR, MAY, JUN, JUL, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, MAY, JUN, JUL, AUG, OCT, NOV, DEC from holidays.constants import MON, WEEKEND from holidays.holiday_base import HolidayBase @@ -26,7 +25,7 @@ class Colombia(HolidayBase): # https://es.wikipedia.org/wiki/Anexo:D%C3%ADas_festivos_en_Colombia def __init__(self, **kwargs): - self.country = 'CO' + self.country = "CO" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -58,8 +57,7 @@ def _populate(self, year): if self.observed and date(year, DEC, 8).weekday() in WEEKEND: pass else: - self[date(year, DEC, 8)] = "La Inmaculada Concepción" \ - " [Immaculate Conception]" + self[date(year, DEC, 8)] = "La Inmaculada Concepción" " [Immaculate Conception]" # Christmas self[date(year, DEC, 25)] = "Navidad [Christmas]" @@ -100,34 +98,29 @@ def _populate(self, year): if date(year, OCT, 12).weekday() == MON or not self.observed: self[date(year, OCT, 12)] = name else: - self[date(year, OCT, 12) + rd(weekday=MO)] = name + \ - "(Observed)" + self[date(year, OCT, 12) + rd(weekday=MO)] = name + "(Observed)" # All Saints’ Day name = "Dia de Todos los Santos [All Saint's Day]" if date(year, NOV, 1).weekday() == MON or not self.observed: self[date(year, NOV, 1)] = name else: - self[date(year, NOV, 1) + rd(weekday=MO)] = name + \ - "(Observed)" + self[date(year, NOV, 1) + rd(weekday=MO)] = name + "(Observed)" # Independence of Cartagena name = "Independencia de Cartagena [Independence of Cartagena]" if date(year, NOV, 11).weekday() == MON or not self.observed: self[date(year, NOV, 11)] = name else: - self[date(year, NOV, 11) + rd(weekday=MO)] = name + \ - "(Observed)" + self[date(year, NOV, 11) + rd(weekday=MO)] = name + "(Observed)" # Holidays based on Easter # Maundy Thursday - self[easter(year) + rd(weekday=TH(-1)) - ] = "Jueves Santo [Maundy Thursday]" + self[easter(year) + rd(weekday=TH(-1))] = "Jueves Santo [Maundy Thursday]" # Good Friday - self[easter(year) + rd(weekday=FR(-1)) - ] = "Viernes Santo [Good Friday]" + self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]" # Holidays based on Easter but are observed the following monday # (unless they occur on a monday) diff --git a/holidays/countries/croatia.py b/holidays/countries/croatia.py index 519fe18b2..5e0b89866 100644 --- a/holidays/countries/croatia.py +++ b/holidays/countries/croatia.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, MAY, JUN, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUN, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/czechia.py b/holidays/countries/czechia.py index e7baa0d73..9b6380f39 100644 --- a/holidays/countries/czechia.py +++ b/holidays/countries/czechia.py @@ -17,8 +17,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, MAY, JUL, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUL, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -26,14 +25,13 @@ class Czechia(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_the_Czech_Republic def __init__(self, **kwargs): - self.country = 'CZ' + self.country = "CZ" HolidayBase.__init__(self, **kwargs) def _populate(self, year): - self[date(year, JAN, 1)] = "Den obnovy samostatného českého" \ - " státu" \ - if year >= 2000 else \ - "Nový rok" + self[date(year, JAN, 1)] = ( + "Den obnovy samostatného českého" " státu" if year >= 2000 else "Nový rok" + ) e = easter(year) if year <= 1951 or year >= 2016: @@ -45,17 +43,14 @@ def _populate(self, year): if year >= 1992: self[date(year, MAY, 8)] = "Den vítězství" elif year >= 1947: - self[date(year, MAY, 9)] = "Den vítězství nad hitlerovským" \ - " fašismem" + self[date(year, MAY, 9)] = "Den vítězství nad hitlerovským" " fašismem" if year >= 1951: - self[date(year, JUL, 5)] = "Den slovanských věrozvěstů " \ - "Cyrila a Metoděje" + self[date(year, JUL, 5)] = "Den slovanských věrozvěstů " "Cyrila a Metoděje" self[date(year, JUL, 6)] = "Den upálení mistra Jana Husa" if year >= 2000: self[date(year, SEP, 28)] = "Den české státnosti" if year >= 1951: - self[date(year, OCT, 28)] = "Den vzniku samostatného " \ - "československého státu" + self[date(year, OCT, 28)] = "Den vzniku samostatného " "československého státu" if year >= 1990: self[date(year, NOV, 17)] = "Den boje za svobodu a demokracii" @@ -76,6 +71,5 @@ class CZE(Czechia): class Czech(Czechia): def __init__(self, **kwargs): - warnings.warn("Czech is deprecated, use Czechia instead.", - DeprecationWarning) + warnings.warn("Czech is deprecated, use Czechia instead.", DeprecationWarning) super(Czech, self).__init__(**kwargs) diff --git a/holidays/countries/denmark.py b/holidays/countries/denmark.py index 05069f397..d1cf62f3c 100644 --- a/holidays/countries/denmark.py +++ b/holidays/countries/denmark.py @@ -24,7 +24,7 @@ class Denmark(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Denmark def __init__(self, **kwargs): - self.country = 'DK' + self.country = "DK" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/dominican_republic.py b/holidays/countries/dominican_republic.py index 62aa78173..266ee1509 100644 --- a/holidays/countries/dominican_republic.py +++ b/holidays/countries/dominican_republic.py @@ -25,7 +25,7 @@ class DominicanRepublic(HolidayBase): # https://es.wikipedia.org/wiki/Rep%C3%BAblica_Dominicana#D%C3%ADas_festivos_nacionales def __init__(self, **kwargs): - self.country = 'DO' + self.country = "DO" HolidayBase.__init__(self, **kwargs) @staticmethod @@ -68,12 +68,17 @@ def _populate(self, year): # Restoration Day # Judgment No. 14 of Feb 20, 2008 of the Supreme Court of Justice - restoration_day = date(year, AUG, 16) if ((year - 2000) % 4 == 0) \ - and year < 2008 else self.__change_day_by_law(date(year, AUG, 16)) + restoration_day = ( + date(year, AUG, 16) + if ((year - 2000) % 4 == 0) and year < 2008 + else self.__change_day_by_law(date(year, AUG, 16)) + ) self[restoration_day] = "Día de la Restauración [Restoration Day]" # Our Lady of Mercedes Day - self[date(year, SEP, 24)] = "Día de las Mercedes \ + self[ + date(year, SEP, 24) + ] = "Día de las Mercedes \ [Our Lady of Mercedes Day]" # Constitution Day diff --git a/holidays/countries/egypt.py b/holidays/countries/egypt.py index 167deb9c6..780c48492 100644 --- a/holidays/countries/egypt.py +++ b/holidays/countries/egypt.py @@ -39,7 +39,7 @@ class Egypt(HolidayBase): # is_weekend function is there, however not activated for accuracy. def __init__(self, **kwargs): - self.country = 'EG' + self.country = "EG" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/european_central_bank.py b/holidays/countries/european_central_bank.py index fda9f680b..7afb08db8 100644 --- a/holidays/countries/european_central_bank.py +++ b/holidays/countries/european_central_bank.py @@ -25,7 +25,7 @@ class EuropeanCentralBank(HolidayBase): # http://www.ecb.europa.eu/press/pr/date/2000/html/pr001214_4.en.html def __init__(self, **kwargs): - self.country = 'EU' + self.country = "EU" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/finland.py b/holidays/countries/finland.py index a71638ee7..ec03d30f3 100644 --- a/holidays/countries/finland.py +++ b/holidays/countries/finland.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, SA, FR -from holidays.constants import JAN, MAY, JUN, OCT, \ - DEC +from holidays.constants import JAN, MAY, JUN, OCT, DEC from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/france.py b/holidays/countries/france.py index 8f57f5187..8c60701db 100644 --- a/holidays/countries/france.py +++ b/holidays/countries/france.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -36,14 +35,24 @@ class France(HolidayBase): https://www.service-public.fr/particuliers/vosdroits/F2405 """ - PROVINCES = ['Métropole', 'Alsace-Moselle', 'Guadeloupe', 'Guyane', - 'Martinique', 'Mayotte', 'Nouvelle-Calédonie', 'La Réunion', - 'Polynésie Française', 'Saint-Barthélémy', 'Saint-Martin', - 'Wallis-et-Futuna'] + PROVINCES = [ + "Métropole", + "Alsace-Moselle", + "Guadeloupe", + "Guyane", + "Martinique", + "Mayotte", + "Nouvelle-Calédonie", + "La Réunion", + "Polynésie Française", + "Saint-Barthélémy", + "Saint-Martin", + "Wallis-et-Futuna", + ] def __init__(self, **kwargs): - self.country = 'FR' - self.prov = kwargs.pop('prov', 'Métropole') + self.country = "FR" + self.prov = kwargs.pop("prov", "Métropole") HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -52,74 +61,79 @@ def _populate(self, year): self[date(year, JAN, 1)] = "Jour de l'an" if year > 1919: - name = 'Fête du Travail' + name = "Fête du Travail" if year <= 1948: - name += ' et de la Concorde sociale' + name += " et de la Concorde sociale" self[date(year, MAY, 1)] = name if (1953 <= year <= 1959) or year > 1981: - self[date(year, MAY, 8)] = 'Armistice 1945' + self[date(year, MAY, 8)] = "Armistice 1945" if year >= 1880: - self[date(year, JUL, 14)] = 'Fête nationale' + self[date(year, JUL, 14)] = "Fête nationale" if year >= 1918: - self[date(year, NOV, 11)] = 'Armistice 1918' + self[date(year, NOV, 11)] = "Armistice 1918" # Religious holidays - if self.prov in ['Alsace-Moselle', 'Guadeloupe', 'Guyane', - 'Martinique', 'Polynésie Française']: - self[easter(year) - rd(days=2)] = 'Vendredi saint' - - if self.prov == 'Alsace-Moselle': - self[date(year, DEC, 26)] = 'Deuxième jour de Noël' + if self.prov in [ + "Alsace-Moselle", + "Guadeloupe", + "Guyane", + "Martinique", + "Polynésie Française", + ]: + self[easter(year) - rd(days=2)] = "Vendredi saint" + + if self.prov == "Alsace-Moselle": + self[date(year, DEC, 26)] = "Deuxième jour de Noël" if year >= 1886: - self[easter(year) + rd(days=1)] = 'Lundi de Pâques' - self[easter(year) + rd(days=50)] = 'Lundi de Pentecôte' + self[easter(year) + rd(days=1)] = "Lundi de Pâques" + self[easter(year) + rd(days=50)] = "Lundi de Pentecôte" if year >= 1802: - self[easter(year) + rd(days=39)] = 'Ascension' - self[date(year, AUG, 15)] = 'Assomption' - self[date(year, NOV, 1)] = 'Toussaint' + self[easter(year) + rd(days=39)] = "Ascension" + self[date(year, AUG, 15)] = "Assomption" + self[date(year, NOV, 1)] = "Toussaint" - name = 'Noël' - if self.prov == 'Alsace-Moselle': - name = 'Premier jour de ' + name + name = "Noël" + if self.prov == "Alsace-Moselle": + name = "Premier jour de " + name self[date(year, DEC, 25)] = name # Non-metropolitan holidays (starting dates missing) - if self.prov == 'Mayotte': + if self.prov == "Mayotte": self[date(year, APR, 27)] = "Abolition de l'esclavage" - if self.prov == 'Wallis-et-Futuna': - self[date(year, APR, 28)] = 'Saint Pierre Chanel' + if self.prov == "Wallis-et-Futuna": + self[date(year, APR, 28)] = "Saint Pierre Chanel" - if self.prov == 'Martinique': + if self.prov == "Martinique": self[date(year, MAY, 22)] = "Abolition de l'esclavage" - if self.prov in ['Guadeloupe', 'Saint-Martin']: + if self.prov in ["Guadeloupe", "Saint-Martin"]: self[date(year, MAY, 27)] = "Abolition de l'esclavage" - if self.prov == 'Guyane': + if self.prov == "Guyane": self[date(year, JUN, 10)] = "Abolition de l'esclavage" - if self.prov == 'Polynésie Française': + if self.prov == "Polynésie Française": self[date(year, JUN, 29)] = "Fête de l'autonomie" - if self.prov in ['Guadeloupe', 'Martinique']: - self[date(year, JUL, 21)] = 'Fête Victor Schoelcher' + if self.prov in ["Guadeloupe", "Martinique"]: + self[date(year, JUL, 21)] = "Fête Victor Schoelcher" - if self.prov == 'Wallis-et-Futuna': - self[date(year, JUL, 29)] = 'Fête du Territoire' + if self.prov == "Wallis-et-Futuna": + self[date(year, JUL, 29)] = "Fête du Territoire" - if self.prov == 'Nouvelle-Calédonie': - self[date(year, SEP, 24)] = 'Fête de la Citoyenneté' + if self.prov == "Nouvelle-Calédonie": + self[date(year, SEP, 24)] = "Fête de la Citoyenneté" - if self.prov == 'Saint-Barthélémy': + if self.prov == "Saint-Barthélémy": self[date(year, OCT, 9)] = "Abolition de l'esclavage" - if self.prov == 'La Réunion' and year >= 1981: + if self.prov == "La Réunion" and year >= 1981: self[date(year, DEC, 20)] = "Abolition de l'esclavage" diff --git a/holidays/countries/germany.py b/holidays/countries/germany.py index 4dadbb3c6..d238d7594 100644 --- a/holidays/countries/germany.py +++ b/holidays/countries/germany.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, WE -from holidays.constants import JAN, MAR, MAY, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, MAY, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -56,12 +55,29 @@ class Germany(HolidayBase): both provinces. """ - PROVINCES = ['BW', 'BY', 'BYP', 'BE', 'BB', 'HB', 'HH', 'HE', 'MV', 'NI', - 'NW', 'RP', 'SL', 'SN', 'ST', 'SH', 'TH'] + PROVINCES = [ + "BW", + "BY", + "BYP", + "BE", + "BB", + "HB", + "HH", + "HE", + "MV", + "NI", + "NW", + "RP", + "SL", + "SN", + "ST", + "SH", + "TH", + ] def __init__(self, **kwargs): - self.country = 'DE' - self.prov = kwargs.pop('prov', None) + self.country = "DE" + self.prov = kwargs.pop("prov", None) HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -70,12 +86,12 @@ def _populate(self, year): if year > 1990: - self[date(year, JAN, 1)] = 'Neujahr' + self[date(year, JAN, 1)] = "Neujahr" - if self.prov in ('BW', 'BY', 'BYP', 'ST'): - self[date(year, JAN, 6)] = 'Heilige Drei Könige' + if self.prov in ("BW", "BY", "BYP", "ST"): + self[date(year, JAN, 6)] = "Heilige Drei Könige" - self[easter(year) - rd(days=2)] = 'Karfreitag' + self[easter(year) - rd(days=2)] = "Karfreitag" if self.prov == "BB": # will always be a Sunday and we have no "observed" rule so @@ -83,16 +99,17 @@ def _populate(self, year): # holiday by law self[easter(year)] = "Ostersonntag" - self[easter(year) + rd(days=1)] = 'Ostermontag' + self[easter(year) + rd(days=1)] = "Ostermontag" - self[date(year, MAY, 1)] = 'Erster Mai' + self[date(year, MAY, 1)] = "Erster Mai" if self.prov == "BE" and year == 2020: - self[date(year, MAY, 8)] = \ - "75. Jahrestag der Befreiung vom Nationalsozialismus " \ + self[date(year, MAY, 8)] = ( + "75. Jahrestag der Befreiung vom Nationalsozialismus " "und der Beendigung des Zweiten Weltkriegs in Europa" + ) - self[easter(year) + rd(days=39)] = 'Christi Himmelfahrt' + self[easter(year) + rd(days=39)] = "Christi Himmelfahrt" if self.prov == "BB": # will always be a Sunday and we have no "observed" rule so @@ -100,47 +117,47 @@ def _populate(self, year): # holiday by law self[easter(year) + rd(days=49)] = "Pfingstsonntag" - self[easter(year) + rd(days=50)] = 'Pfingstmontag' + self[easter(year) + rd(days=50)] = "Pfingstmontag" - if self.prov in ('BW', 'BY', 'BYP', 'HE', 'NW', 'RP', 'SL'): - self[easter(year) + rd(days=60)] = 'Fronleichnam' + if self.prov in ("BW", "BY", "BYP", "HE", "NW", "RP", "SL"): + self[easter(year) + rd(days=60)] = "Fronleichnam" - if self.prov in ('BY', 'SL'): - self[date(year, AUG, 15)] = 'Mariä Himmelfahrt' + if self.prov in ("BY", "SL"): + self[date(year, AUG, 15)] = "Mariä Himmelfahrt" - self[date(year, OCT, 3)] = 'Tag der Deutschen Einheit' + self[date(year, OCT, 3)] = "Tag der Deutschen Einheit" - if self.prov in ('BB', 'MV', 'SN', 'ST', 'TH'): - self[date(year, OCT, 31)] = 'Reformationstag' + if self.prov in ("BB", "MV", "SN", "ST", "TH"): + self[date(year, OCT, 31)] = "Reformationstag" - if self.prov in ('HB', 'SH', 'NI', 'HH') and year >= 2018: - self[date(year, OCT, 31)] = 'Reformationstag' + if self.prov in ("HB", "SH", "NI", "HH") and year >= 2018: + self[date(year, OCT, 31)] = "Reformationstag" # in 2017 all states got the Reformationstag (500th anniversary of # Luther's thesis) if year == 2017: - self[date(year, OCT, 31)] = 'Reformationstag' + self[date(year, OCT, 31)] = "Reformationstag" - if self.prov in ('BW', 'BY', 'BYP', 'NW', 'RP', 'SL'): - self[date(year, NOV, 1)] = 'Allerheiligen' + if self.prov in ("BW", "BY", "BYP", "NW", "RP", "SL"): + self[date(year, NOV, 1)] = "Allerheiligen" - if year <= 1994 or self.prov == 'SN': + if year <= 1994 or self.prov == "SN": # can be calculated as "last wednesday before year-11-23" which is # why we need to go back two wednesdays if year-11-23 happens to be # a wednesday base_data = date(year, NOV, 23) weekday_delta = WE(-2) if base_data.weekday() == 2 else WE(-1) - self[base_data + rd(weekday=weekday_delta)] = 'Buß- und Bettag' + self[base_data + rd(weekday=weekday_delta)] = "Buß- und Bettag" if year >= 2019: - if self.prov == 'TH': - self[date(year, SEP, 20)] = 'Weltkindertag' + if self.prov == "TH": + self[date(year, SEP, 20)] = "Weltkindertag" - if self.prov == 'BE': - self[date(year, MAR, 8)] = 'Internationaler Frauentag' + if self.prov == "BE": + self[date(year, MAR, 8)] = "Internationaler Frauentag" - self[date(year, DEC, 25)] = 'Erster Weihnachtstag' - self[date(year, DEC, 26)] = 'Zweiter Weihnachtstag' + self[date(year, DEC, 25)] = "Erster Weihnachtstag" + self[date(year, DEC, 26)] = "Zweiter Weihnachtstag" class DE(Germany): diff --git a/holidays/countries/greece.py b/holidays/countries/greece.py index 2e5e599e4..47aec5ae8 100644 --- a/holidays/countries/greece.py +++ b/holidays/countries/greece.py @@ -24,7 +24,7 @@ class Greece(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Greece def __init__(self, **kwargs): - self.country = 'GR' + self.country = "GR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -49,8 +49,7 @@ def _populate(self, year): self[date(year, MAY, 1)] = "Εργατική Πρωτομαγιά [Labour day]" # Monday of the Holy Spirit - self[eday + rd(days=50)] = \ - "Δευτέρα του Αγίου Πνεύματος [Monday of the Holy Spirit]" + self[eday + rd(days=50)] = "Δευτέρα του Αγίου Πνεύματος [Monday of the Holy Spirit]" # Assumption of Mary self[date(year, AUG, 15)] = "Κοίμηση της Θεοτόκου [Assumption of Mary]" @@ -62,8 +61,7 @@ def _populate(self, year): self[date(year, DEC, 25)] = "Χριστούγεννα [Christmas]" # Day after Christmas - self[date(year, DEC, 26)] = \ - "Επόμενη ημέρα των Χριστουγέννων [Day after Christmas]" + self[date(year, DEC, 26)] = "Επόμενη ημέρα των Χριστουγέννων [Day after Christmas]" class GR(Greece): diff --git a/holidays/countries/honduras.py b/holidays/countries/honduras.py index c4a006f71..e93dd8bde 100644 --- a/holidays/countries/honduras.py +++ b/holidays/countries/honduras.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, TH, FR, SA, SU -from holidays.constants import JAN, FEB, MAR, APR, MAY, SEP, OCT, \ - DEC +from holidays.constants import JAN, FEB, MAR, APR, MAY, SEP, OCT, DEC from holidays.holiday_base import HolidayBase @@ -49,20 +48,16 @@ def _populate(self, year): self[date(year, MAR, 19)] = name # Maundy Thursday - self[easter(year) + rd(weekday=TH(-1)) - ] = "Jueves Santo [Maundy Thursday]" + self[easter(year) + rd(weekday=TH(-1))] = "Jueves Santo [Maundy Thursday]" # Good Friday - self[easter(year) + rd(weekday=FR(-1)) - ] = "Viernes Santo [Good Friday]" + self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]" # Holy Saturday - self[easter(year) + rd(weekday=SA(-1)) - ] = "Sábado de Gloria [Holy Saturday]" + self[easter(year) + rd(weekday=SA(-1))] = "Sábado de Gloria [Holy Saturday]" # Easter Sunday - self[easter(year) + rd(weekday=SU(-1)) - ] = "Domingo de Resurrección [Easter Sunday]" + self[easter(year) + rd(weekday=SU(-1))] = "Domingo de Resurrección [Easter Sunday]" # America Day if self.observed and date(year, APR, 14): @@ -75,7 +70,7 @@ def _populate(self, year): # Mother's Day may_first = date(int(year), 5, 1) weekday_seq = may_first.weekday() - mom_day = (14 - weekday_seq) + mom_day = 14 - weekday_seq if self.observed and date(year, MAY, mom_day): str_day = "Día de la madre [Mother's Day] (Observed)" self[date(year, MAY, mom_day)] = str_day diff --git a/holidays/countries/hongkong.py b/holidays/countries/hongkong.py index a3bc40687..1630bda8c 100644 --- a/holidays/countries/hongkong.py +++ b/holidays/countries/hongkong.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR, SA, MO -from holidays.constants import JAN, APR, MAY, JUL, SEP, OCT, \ - DEC +from holidays.constants import JAN, APR, MAY, JUL, SEP, OCT, DEC from holidays.constants import MON, TUE, WED, THU, FRI, SAT, SUN from holidays.holiday_base import HolidayBase @@ -40,8 +39,7 @@ def _populate(self, year): first_date = date(year, JAN, 1) if self.observed: if first_date.weekday() == SUN: - self[first_date + rd(days=+1)] = day_following + \ - self.first_lower(name) + self[first_date + rd(days=+1)] = day_following + self.first_lower(name) first_date = first_date + rd(days=+1) else: self[first_date] = name @@ -86,8 +84,7 @@ def _populate(self, year): # Ching Ming Festival name = "Ching Ming Festival" - if self.isLeapYear(year) or (self.isLeapYear(year - 1) and - year > 2008): + if self.isLeapYear(year) or (self.isLeapYear(year - 1) and year > 2008): ching_ming_date = date(year, APR, 4) else: ching_ming_date = date(year, APR, 5) @@ -105,17 +102,14 @@ def _populate(self, year): easter_monday = "Easter Monday" if self.observed: self[easter(year) + rd(weekday=FR(-1))] = good_friday - self[easter(year) + rd(weekday=SA(-1))] = day_following + \ - good_friday + self[easter(year) + rd(weekday=SA(-1))] = day_following + good_friday if ching_ming_date == easter(year) + rd(weekday=MO): - self[easter(year) + rd(weekday=MO) + rd(days=+1)] = \ - day_following + easter_monday + self[easter(year) + rd(weekday=MO) + rd(days=+1)] = day_following + easter_monday else: self[easter(year) + rd(weekday=MO)] = easter_monday else: self[easter(year) + rd(weekday=FR(-1))] = good_friday - self[easter(year) + rd(weekday=SA(-1))] = day_following + \ - good_friday + self[easter(year) + rd(weekday=SA(-1))] = day_following + good_friday self[easter(year) + rd(weekday=MO)] = easter_monday # Birthday of the Buddha @@ -166,8 +160,10 @@ def _populate(self, year): # Special holiday on 2015 - The 70th anniversary day of the victory # of the Chinese people's war of resistance against Japanese aggression - name = "The 70th anniversary day of the victory of the Chinese " + \ - "people's war of resistance against Japanese aggression" + name = ( + "The 70th anniversary day of the victory of the Chinese " + + "people's war of resistance against Japanese aggression" + ) if year == 2015: self[date(year, SEP, 3)] = name @@ -179,8 +175,7 @@ def _populate(self, year): if mid_autumn_date.weekday() == SAT: self[mid_autumn_date] = name else: - self[mid_autumn_date + rd(days=+1)] = day_following + \ - "the " + name + self[mid_autumn_date + rd(days=+1)] = day_following + "the " + name mid_autumn_date = mid_autumn_date + rd(days=+1) else: self[mid_autumn_date] = name @@ -189,8 +184,7 @@ def _populate(self, year): name = "National Day" national_date = date(year, OCT, 1) if self.observed: - if (national_date.weekday() == SUN or - national_date == mid_autumn_date): + if national_date.weekday() == SUN or national_date == mid_autumn_date: self[national_date + rd(days=+1)] = day_following + name else: self[national_date] = name @@ -248,46 +242,205 @@ def first_lower(self, s): # 29 days. The 12th to 15th digits indicate the month of the next month. # If it is 0x0F, it means that there is no leap month. g_lunar_month_days = [ - 0xF0EA4, 0xF1D4A, 0x52C94, 0xF0C96, 0xF1536, - 0x42AAC, 0xF0AD4, 0xF16B2, 0x22EA4, 0xF0EA4, # 1901-1910 - 0x6364A, 0xF164A, 0xF1496, 0x52956, 0xF055A, - 0xF0AD6, 0x216D2, 0xF1B52, 0x73B24, 0xF1D24, # 1911-1920 - 0xF1A4A, 0x5349A, 0xF14AC, 0xF056C, 0x42B6A, - 0xF0DA8, 0xF1D52, 0x23D24, 0xF1D24, 0x61A4C, # 1921-1930 - 0xF0A56, 0xF14AE, 0x5256C, 0xF16B4, 0xF0DA8, - 0x31D92, 0xF0E92, 0x72D26, 0xF1526, 0xF0A56, # 1931-1940 - 0x614B6, 0xF155A, 0xF0AD4, 0x436AA, 0xF1748, - 0xF1692, 0x23526, 0xF152A, 0x72A5A, 0xF0A6C, # 1941-1950 - 0xF155A, 0x52B54, 0xF0B64, 0xF1B4A, 0x33A94, - 0xF1A94, 0x8152A, 0xF152E, 0xF0AAC, 0x6156A, # 1951-1960 - 0xF15AA, 0xF0DA4, 0x41D4A, 0xF1D4A, 0xF0C94, - 0x3192E, 0xF1536, 0x72AB4, 0xF0AD4, 0xF16D2, # 1961-1970 - 0x52EA4, 0xF16A4, 0xF164A, 0x42C96, 0xF1496, - 0x82956, 0xF055A, 0xF0ADA, 0x616D2, 0xF1B52, # 1971-1980 - 0xF1B24, 0x43A4A, 0xF1A4A, 0xA349A, 0xF14AC, - 0xF056C, 0x60B6A, 0xF0DAA, 0xF1D92, 0x53D24, # 1981-1990 - 0xF1D24, 0xF1A4C, 0x314AC, 0xF14AE, 0x829AC, - 0xF06B4, 0xF0DAA, 0x52D92, 0xF0E92, 0xF0D26, # 1991-2000 - 0x42A56, 0xF0A56, 0xF14B6, 0x22AB4, 0xF0AD4, - 0x736AA, 0xF1748, 0xF1692, 0x53526, 0xF152A, # 2001-2010 - 0xF0A5A, 0x4155A, 0xF156A, 0x92B54, 0xF0BA4, - 0xF1B4A, 0x63A94, 0xF1A94, 0xF192A, 0x42A5C, # 2011-2020 - 0xF0AAC, 0xF156A, 0x22B64, 0xF0DA4, 0x61D52, - 0xF0E4A, 0xF0C96, 0x5192E, 0xF1956, 0xF0AB4, # 2021-2030 - 0x315AC, 0xF16D2, 0xB2EA4, 0xF16A4, 0xF164A, - 0x63496, 0xF1496, 0xF0956, 0x50AB6, 0xF0B5A, # 2031-2040 - 0xF16D4, 0x236A4, 0xF1B24, 0x73A4A, 0xF1A4A, - 0xF14AA, 0x5295A, 0xF096C, 0xF0B6A, 0x31B54, # 2041-2050 - 0xF1D92, 0x83D24, 0xF1D24, 0xF1A4C, 0x614AC, - 0xF14AE, 0xF09AC, 0x40DAA, 0xF0EAA, 0xF0E92, # 2051-2060 - 0x31D26, 0xF0D26, 0x72A56, 0xF0A56, 0xF14B6, - 0x52AB4, 0xF0AD4, 0xF16CA, 0x42E94, 0xF1694, # 2061-2070 - 0x8352A, 0xF152A, 0xF0A5A, 0x6155A, 0xF156A, - 0xF0B54, 0x4174A, 0xF1B4A, 0xF1A94, 0x3392A, # 2071-2080 - 0xF192C, 0x7329C, 0xF0AAC, 0xF156A, 0x52B64, - 0xF0DA4, 0xF1D4A, 0x41C94, 0xF0C96, 0x8192E, # 2081-2090 - 0xF0956, 0xF0AB6, 0x615AC, 0xF16D4, 0xF0EA4, - 0x42E4A, 0xF164A, 0xF1516, 0x22936, # 2090-2099 + 0xF0EA4, + 0xF1D4A, + 0x52C94, + 0xF0C96, + 0xF1536, + 0x42AAC, + 0xF0AD4, + 0xF16B2, + 0x22EA4, + 0xF0EA4, # 1901-1910 + 0x6364A, + 0xF164A, + 0xF1496, + 0x52956, + 0xF055A, + 0xF0AD6, + 0x216D2, + 0xF1B52, + 0x73B24, + 0xF1D24, # 1911-1920 + 0xF1A4A, + 0x5349A, + 0xF14AC, + 0xF056C, + 0x42B6A, + 0xF0DA8, + 0xF1D52, + 0x23D24, + 0xF1D24, + 0x61A4C, # 1921-1930 + 0xF0A56, + 0xF14AE, + 0x5256C, + 0xF16B4, + 0xF0DA8, + 0x31D92, + 0xF0E92, + 0x72D26, + 0xF1526, + 0xF0A56, # 1931-1940 + 0x614B6, + 0xF155A, + 0xF0AD4, + 0x436AA, + 0xF1748, + 0xF1692, + 0x23526, + 0xF152A, + 0x72A5A, + 0xF0A6C, # 1941-1950 + 0xF155A, + 0x52B54, + 0xF0B64, + 0xF1B4A, + 0x33A94, + 0xF1A94, + 0x8152A, + 0xF152E, + 0xF0AAC, + 0x6156A, # 1951-1960 + 0xF15AA, + 0xF0DA4, + 0x41D4A, + 0xF1D4A, + 0xF0C94, + 0x3192E, + 0xF1536, + 0x72AB4, + 0xF0AD4, + 0xF16D2, # 1961-1970 + 0x52EA4, + 0xF16A4, + 0xF164A, + 0x42C96, + 0xF1496, + 0x82956, + 0xF055A, + 0xF0ADA, + 0x616D2, + 0xF1B52, # 1971-1980 + 0xF1B24, + 0x43A4A, + 0xF1A4A, + 0xA349A, + 0xF14AC, + 0xF056C, + 0x60B6A, + 0xF0DAA, + 0xF1D92, + 0x53D24, # 1981-1990 + 0xF1D24, + 0xF1A4C, + 0x314AC, + 0xF14AE, + 0x829AC, + 0xF06B4, + 0xF0DAA, + 0x52D92, + 0xF0E92, + 0xF0D26, # 1991-2000 + 0x42A56, + 0xF0A56, + 0xF14B6, + 0x22AB4, + 0xF0AD4, + 0x736AA, + 0xF1748, + 0xF1692, + 0x53526, + 0xF152A, # 2001-2010 + 0xF0A5A, + 0x4155A, + 0xF156A, + 0x92B54, + 0xF0BA4, + 0xF1B4A, + 0x63A94, + 0xF1A94, + 0xF192A, + 0x42A5C, # 2011-2020 + 0xF0AAC, + 0xF156A, + 0x22B64, + 0xF0DA4, + 0x61D52, + 0xF0E4A, + 0xF0C96, + 0x5192E, + 0xF1956, + 0xF0AB4, # 2021-2030 + 0x315AC, + 0xF16D2, + 0xB2EA4, + 0xF16A4, + 0xF164A, + 0x63496, + 0xF1496, + 0xF0956, + 0x50AB6, + 0xF0B5A, # 2031-2040 + 0xF16D4, + 0x236A4, + 0xF1B24, + 0x73A4A, + 0xF1A4A, + 0xF14AA, + 0x5295A, + 0xF096C, + 0xF0B6A, + 0x31B54, # 2041-2050 + 0xF1D92, + 0x83D24, + 0xF1D24, + 0xF1A4C, + 0x614AC, + 0xF14AE, + 0xF09AC, + 0x40DAA, + 0xF0EAA, + 0xF0E92, # 2051-2060 + 0x31D26, + 0xF0D26, + 0x72A56, + 0xF0A56, + 0xF14B6, + 0x52AB4, + 0xF0AD4, + 0xF16CA, + 0x42E94, + 0xF1694, # 2061-2070 + 0x8352A, + 0xF152A, + 0xF0A5A, + 0x6155A, + 0xF156A, + 0xF0B54, + 0x4174A, + 0xF1B4A, + 0xF1A94, + 0x3392A, # 2071-2080 + 0xF192C, + 0x7329C, + 0xF0AAC, + 0xF156A, + 0x52B64, + 0xF0DA4, + 0xF1D4A, + 0x41C94, + 0xF0C96, + 0x8192E, # 2081-2090 + 0xF0956, + 0xF0AB6, + 0x615AC, + 0xF16D4, + 0xF0EA4, + 0x42E4A, + 0xF164A, + 0xF1516, + 0x22936, # 2090-2099 ] # Define range of years START_YEAR, END_YEAR = 1901, 1900 + len(g_lunar_month_days) @@ -297,12 +450,10 @@ def first_lower(self, s): LUNAR_END_DATE, SOLAR_END_DATE = (2099, 12, 30), datetime(2100, 2, 18) def get_leap_month(self, lunar_year): - return (self.g_lunar_month_days[lunar_year - self.START_YEAR] >> 16) \ - & 0x0F + return (self.g_lunar_month_days[lunar_year - self.START_YEAR] >> 16) & 0x0F def lunar_month_days(self, lunar_year, lunar_month): - return 29 + ((self.g_lunar_month_days[lunar_year - self.START_YEAR] >> - lunar_month) & 0x01) + return 29 + ((self.g_lunar_month_days[lunar_year - self.START_YEAR] >> lunar_month) & 0x01) def lunar_year_days(self, year): days = 0 diff --git a/holidays/countries/hungary.py b/holidays/countries/hungary.py index ced7e4b31..1aa8a1de4 100644 --- a/holidays/countries/hungary.py +++ b/holidays/countries/hungary.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR -from holidays.constants import JAN, MAR, APR, MAY, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, AUG, OCT, NOV, DEC from holidays.constants import MON, TUE, THU, WEEKEND from holidays.holiday_base import HolidayBase @@ -43,20 +42,17 @@ def _populate(self, year): # National Day if 1945 <= year <= 1950 or 1989 <= year: - self._add_with_observed_day_off( - date(year, MAR, 15), "Nemzeti ünnep") + self._add_with_observed_day_off(date(year, MAR, 15), "Nemzeti ünnep") # Soviet era if 1950 <= year <= 1989: # Proclamation of Soviet socialist governing system - self[date(year, MAR, 21)] = \ - "A Tanácsköztársaság kikiáltásának ünnepe" + self[date(year, MAR, 21)] = "A Tanácsköztársaság kikiáltásának ünnepe" # Liberation Day self[date(year, APR, 4)] = "A felszabadulás ünnepe" # Memorial day of The Great October Soviet Socialist Revolution if year not in (1956, 1989): - self[date(year, NOV, 7)] = \ - "A nagy októberi szocialista forradalom ünnepe" + self[date(year, NOV, 7)] = "A nagy októberi szocialista forradalom ünnepe" easter_date = easter(year) @@ -80,8 +76,7 @@ def _populate(self, year): # International Workers' Day if 1946 <= year: - self._add_with_observed_day_off( - date(year, MAY, 1), "A Munka ünnepe") + self._add_with_observed_day_off(date(year, MAY, 1), "A Munka ünnepe") if 1950 <= year <= 1953: self[date(year, MAY, 2)] = "A Munka ünnepe" @@ -89,23 +84,19 @@ def _populate(self, year): if 1950 <= year < 1990: self[date(year, AUG, 20)] = "A kenyér ünnepe" else: - self._add_with_observed_day_off( - date(year, AUG, 20), "Az államalapítás ünnepe") + self._add_with_observed_day_off(date(year, AUG, 20), "Az államalapítás ünnepe") # National Day if 1991 <= year: - self._add_with_observed_day_off( - date(year, OCT, 23), "Nemzeti ünnep") + self._add_with_observed_day_off(date(year, OCT, 23), "Nemzeti ünnep") # All Saints' Day if 1999 <= year: - self._add_with_observed_day_off( - date(year, NOV, 1), "Mindenszentek") + self._add_with_observed_day_off(date(year, NOV, 1), "Mindenszentek") # Christmas Eve is not endorsed officially # but nowadays it is usually a day off work - if self.observed and 2010 <= year \ - and date(year, DEC, 24).weekday() not in WEEKEND: + if self.observed and 2010 <= year and date(year, DEC, 24).weekday() not in WEEKEND: self[date(year, DEC, 24)] = "Szenteste" # First christmas @@ -114,16 +105,14 @@ def _populate(self, year): # Second christmas if 1955 != year: self._add_with_observed_day_off( - date(year, DEC, 26), "Karácsony másnapja", since=2013, - before=False, after=True) + date(year, DEC, 26), "Karácsony másnapja", since=2013, before=False, after=True + ) # New Year's Eve - if self.observed and 2014 <= year \ - and date(year, DEC, 31).weekday() == MON: + if self.observed and 2014 <= year and date(year, DEC, 31).weekday() == MON: self[date(year, DEC, 31)] = "Szilveszter" - def _add_with_observed_day_off(self, day, desc, since=2010, - before=True, after=True): + def _add_with_observed_day_off(self, day, desc, since=2010, before=True, after=True): # Swapped days off were in place earlier but # I haven't found official record yet. self[day] = desc diff --git a/holidays/countries/iceland.py b/holidays/countries/iceland.py index e7e292d28..60fb2b045 100644 --- a/holidays/countries/iceland.py +++ b/holidays/countries/iceland.py @@ -34,16 +34,14 @@ def _populate(self, year): self[easter(year) + rd(weekday=FR(-1))] = "Föstudagurinn langi" self[easter(year)] = "Páskadagur" self[easter(year) + rd(days=1)] = "Annar í páskum" - self[date(year, APR, 19) + rd(weekday=TH(+1))] = \ - "Sumardagurinn fyrsti" + self[date(year, APR, 19) + rd(weekday=TH(+1))] = "Sumardagurinn fyrsti" self[date(year, MAY, 1)] = "Verkalýðsdagurinn" self[easter(year) + rd(days=39)] = "Uppstigningardagur" self[easter(year) + rd(days=49)] = "Hvítasunnudagur" self[easter(year) + rd(days=50)] = "Annar í hvítasunnu" self[date(year, JUN, 17)] = "Þjóðhátíðardagurinn" # First Monday of August - self[date(year, AUG, 1) + rd(weekday=MO(+1))] = \ - "Frídagur verslunarmanna" + self[date(year, AUG, 1) + rd(weekday=MO(+1))] = "Frídagur verslunarmanna" self[date(year, DEC, 24)] = "Aðfangadagur" self[date(year, DEC, 25)] = "Jóladagur" self[date(year, DEC, 26)] = "Annar í jólum" diff --git a/holidays/countries/india.py b/holidays/countries/india.py index e65e48851..f0c7fb23a 100644 --- a/holidays/countries/india.py +++ b/holidays/countries/india.py @@ -13,8 +13,7 @@ from datetime import date -from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -23,8 +22,26 @@ class India(HolidayBase): # https://www.calendarlabs.com/holidays/india/ # https://slusi.dacnet.nic.in/watershedatlas/list_of_state_abbreviation.htm - PROVINCES = ['AS', 'CG', 'SK', 'KA', 'GJ', 'BR', 'RJ', 'OD', - 'TN', 'AP', 'WB', 'KL', 'HR', 'MH', 'MP', 'UP', 'UK', 'TS'] + PROVINCES = [ + "AS", + "CG", + "SK", + "KA", + "GJ", + "BR", + "RJ", + "OD", + "TN", + "AP", + "WB", + "KL", + "HR", + "MH", + "MP", + "UP", + "UK", + "TS", + ] def __init__(self, **kwargs): self.country = "IND" @@ -57,61 +74,59 @@ def _populate(self, year): self[date(year, MAY, 1)] = "Gujarat Day" self[date(year, OCT, 31)] = "Sardar Patel Jayanti" - if self.prov == 'BR': + if self.prov == "BR": self[date(year, MAR, 22)] = "Bihar Day" - if self.prov == 'RJ': + if self.prov == "RJ": self[date(year, MAR, 30)] = "Rajasthan Day" self[date(year, JUN, 15)] = "Maharana Pratap Jayanti" - if self.prov == 'OD': + if self.prov == "OD": self[date(year, APR, 1)] = "Odisha Day (Utkala Dibasa)" - self[date(year, APR, 15)] = "Maha Vishuva Sankranti / Pana" \ - " Sankranti" + self[date(year, APR, 15)] = "Maha Vishuva Sankranti / Pana" " Sankranti" - if self.prov in ('OD', 'AP', 'BR', 'WB', 'KL', - 'HR', 'MH', 'UP', 'UK', 'TN'): + if self.prov in ("OD", "AP", "BR", "WB", "KL", "HR", "MH", "UP", "UK", "TN"): self[date(year, APR, 14)] = "Dr. B. R. Ambedkar's Jayanti" - if self.prov == 'TN': + if self.prov == "TN": self[date(year, APR, 14)] = "Puthandu (Tamil New Year)" self[date(year, APR, 15)] = "Puthandu (Tamil New Year)" - if self.prov == 'WB': + if self.prov == "WB": self[date(year, APR, 14)] = "Pohela Boishakh" self[date(year, APR, 15)] = "Pohela Boishakh" self[date(year, MAY, 9)] = "Rabindra Jayanti" - if self.prov == 'AS': + if self.prov == "AS": self[date(year, APR, 15)] = "Bihu (Assamese New Year)" - if self.prov == 'MH': + if self.prov == "MH": self[date(year, MAY, 1)] = "Maharashtra Day" - if self.prov == 'SK': + if self.prov == "SK": self[date(year, MAY, 16)] = "Annexation Day" - if self.prov == 'KA': + if self.prov == "KA": self[date(year, NOV, 1)] = "Karnataka Rajyotsava" - if self.prov == 'AP': + if self.prov == "AP": self[date(year, NOV, 1)] = "Andhra Pradesh Foundation Day" - if self.prov == 'HR': + if self.prov == "HR": self[date(year, NOV, 1)] = "Haryana Foundation Day" - if self.prov == 'MP': + if self.prov == "MP": self[date(year, NOV, 1)] = "Madhya Pradesh Foundation Day" - if self.prov == 'KL': + if self.prov == "KL": self[date(year, NOV, 1)] = "Kerala Foundation Day" - if self.prov == 'CG': + if self.prov == "CG": self[date(year, NOV, 1)] = "Chhattisgarh Foundation Day" # TS is Telangana State which was bifurcated in 2014 from AP # (AndhraPradesh) - if self.prov == 'TS': + if self.prov == "TS": self[date(year, OCT, 6)] = "Bathukamma Festival" self[date(year, APR, 6)] = "Eid al-Fitr" diff --git a/holidays/countries/ireland.py b/holidays/countries/ireland.py index 089b14997..7bfa74a73 100644 --- a/holidays/countries/ireland.py +++ b/holidays/countries/ireland.py @@ -16,9 +16,8 @@ class Ireland(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Ireland' + self.country = "Ireland" HolidayBase.__init__(self, **kwargs) diff --git a/holidays/countries/israel.py b/holidays/countries/israel.py index 1fb178927..1152c6d92 100644 --- a/holidays/countries/israel.py +++ b/holidays/countries/israel.py @@ -20,7 +20,7 @@ class Israel(HolidayBase): def __init__(self, **kwargs): - self.country = 'IL' + self.country = "IL" HolidayBase.__init__(self, **kwargs) @@ -31,16 +31,15 @@ def _populate(self, year): name = "Passover I" year, month, day = hebrew.to_jd_gregorianyear(year, hebrew.NISAN, 14) passover_start_dt = date(year, month, day) - self[passover_start_dt] = name + ' - Eve' + self[passover_start_dt] = name + " - Eve" self[passover_start_dt + rd(days=1)] = name - name = 'Passover' + name = "Passover" for offset in range(2, 6): - self[passover_start_dt + rd(days=offset)] = \ - name + ' - Chol HaMoed' + self[passover_start_dt + rd(days=offset)] = name + " - Chol HaMoed" name = "Passover VII" - self[passover_start_dt + rd(days=6)] = name + ' - Eve' + self[passover_start_dt + rd(days=6)] = name + " - Eve" self[passover_start_dt + rd(days=7)] = name # Memorial Day @@ -52,13 +51,12 @@ def _populate(self, year): if self.observed: day_in_week = date(year, month, day).weekday() if day_in_week in (2, 3): - observed_delta = - (day_in_week - 1) + observed_delta = -(day_in_week - 1) elif 2004 <= year and day_in_week == 5: observed_delta = 1 if observed_delta != 0: - self[date(year, month, day) + rd(days=observed_delta + 1)] = \ - name + " (Observed)" + self[date(year, month, day) + rd(days=observed_delta + 1)] = name + " (Observed)" # Independence Day name = "Independence Day" @@ -66,8 +64,7 @@ def _populate(self, year): self[date(year, month, day) + rd(days=1)] = name if self.observed and observed_delta != 0: - self[date(year, month, day) + rd(days=observed_delta + 1)] = \ - name + " (Observed)" + self[date(year, month, day) + rd(days=observed_delta + 1)] = name + " (Observed)" # Lag Baomer name = "Lag B'Omer" @@ -90,39 +87,39 @@ def _populate(self, year): # Yom Kippur name = "Yom Kippur" year, month, day = hebrew.to_jd_gregorianyear(year, hebrew.TISHRI, 9) - self[date(year, month, day)] = name + ' - Eve' + self[date(year, month, day)] = name + " - Eve" self[date(year, month, day) + rd(days=1)] = name # Sukkot name = "Sukkot I" year, month, day = hebrew.to_jd_gregorianyear(year, hebrew.TISHRI, 14) sukkot_start_dt = date(year, month, day) - self[sukkot_start_dt] = name + ' - Eve' + self[sukkot_start_dt] = name + " - Eve" self[sukkot_start_dt + rd(days=1)] = name - name = 'Sukkot' + name = "Sukkot" for offset in range(2, 7): - self[sukkot_start_dt + rd(days=offset)] = name + ' - Chol HaMoed' + self[sukkot_start_dt + rd(days=offset)] = name + " - Chol HaMoed" name = "Sukkot VII" - self[sukkot_start_dt + rd(days=7)] = name + ' - Eve' + self[sukkot_start_dt + rd(days=7)] = name + " - Eve" self[sukkot_start_dt + rd(days=8)] = name # Hanukkah - name = 'Hanukkah' + name = "Hanukkah" year, month, day = hebrew.to_jd_gregorianyear(year, hebrew.KISLEV, 25) for offset in range(8): self[date(year, month, day) + rd(days=offset)] = name # Purim - name = 'Purim' + name = "Purim" heb_month = hebrew.VEADAR if is_leap_year else hebrew.ADAR year, month, day = hebrew.to_jd_gregorianyear(year, heb_month, 14) self[date(year, month, day)] = name - self[date(year, month, day) - rd(days=1)] = name + ' - Eve' + self[date(year, month, day) - rd(days=1)] = name + " - Eve" - name = 'Shushan Purim' + name = "Shushan Purim" self[date(year, month, day) + rd(days=1)] = name diff --git a/holidays/countries/italy.py b/holidays/countries/italy.py index 295f5963c..2c1864af5 100644 --- a/holidays/countries/italy.py +++ b/holidays/countries/italy.py @@ -16,28 +16,73 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, \ - OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase class Italy(HolidayBase): - PROVINCES = ['AN', 'AO', 'BA', 'BL', 'BO', - 'BZ', 'BS', 'CB', 'CT', 'Cesena', - 'CH', 'CS', 'KR', 'EN', 'FE', 'FI', - 'FC', 'Forli', 'FR', 'GE', 'GO', 'IS', - 'SP', 'LT', 'MN', 'MS', 'MI', - 'MO', 'MB', 'NA', 'PD', 'PA', - 'PR', 'PG', 'PE', 'PC', 'PI', - 'PD', 'PT', 'RA', 'RE', - 'RI', 'RN', 'RM', 'RO', 'SA', - 'SR', 'TE', 'TO', 'TS', 'Pesaro', 'PU', - 'Urbino', 'VE', 'VC', 'VI'] + PROVINCES = [ + "AN", + "AO", + "BA", + "BL", + "BO", + "BZ", + "BS", + "CB", + "CT", + "Cesena", + "CH", + "CS", + "KR", + "EN", + "FE", + "FI", + "FC", + "Forli", + "FR", + "GE", + "GO", + "IS", + "SP", + "LT", + "MN", + "MS", + "MI", + "MO", + "MB", + "NA", + "PD", + "PA", + "PR", + "PG", + "PE", + "PC", + "PI", + "PD", + "PT", + "RA", + "RE", + "RI", + "RN", + "RM", + "RO", + "SA", + "SR", + "TE", + "TO", + "TS", + "Pesaro", + "PU", + "Urbino", + "VE", + "VC", + "VI", + ] def __init__(self, **kwargs): - self.country = 'IT' - self.prov = kwargs.pop('prov', kwargs.pop('state', '')) + self.country = "IT" + self.prov = kwargs.pop("prov", kwargs.pop("state", "")) HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -58,83 +103,83 @@ def _populate(self, year): # Provinces holidays if self.prov: - if self.prov == 'AN': + if self.prov == "AN": self[date(year, MAY, 4)] = "San Ciriaco" - elif self.prov == 'AO': + elif self.prov == "AO": self[date(year, SEP, 7)] = "San Grato" - elif self.prov in ('BA'): + elif self.prov in ("BA"): self[date(year, DEC, 6)] = "San Nicola" - elif self.prov == 'BL': + elif self.prov == "BL": self[date(year, NOV, 11)] = "San Martino" - elif self.prov in ('BO'): + elif self.prov in ("BO"): self[date(year, OCT, 4)] = "San Petronio" - elif self.prov == 'BZ': + elif self.prov == "BZ": self[date(year, AUG, 15)] = "Maria Santissima Assunta" - elif self.prov == 'BS': + elif self.prov == "BS": self[date(year, FEB, 15)] = "Santi Faustino e Giovita" - elif self.prov == 'CB': + elif self.prov == "CB": self[date(year, APR, 23)] = "San Giorgio" - elif self.prov == 'CT': + elif self.prov == "CT": self[date(year, FEB, 5)] = "Sant'Agata" - elif self.prov in ('FC', 'Cesena'): + elif self.prov in ("FC", "Cesena"): self[date(year, JUN, 24)] = "San Giovanni Battista" - if self.prov in ('FC', 'Forlì'): + if self.prov in ("FC", "Forlì"): self[date(year, FEB, 4)] = "Madonna del Fuoco" - elif self.prov == 'CH': + elif self.prov == "CH": self[date(year, MAY, 11)] = "San Giustino di Chieti" - elif self.prov == 'CS': + elif self.prov == "CS": self[date(year, FEB, 12)] = "Madonna del Pilerio" - elif self.prov == 'KR': + elif self.prov == "KR": self[date(year, OCT, 9)] = "San Dionigi" - elif self.prov == 'EN': + elif self.prov == "EN": self[date(year, JUL, 2)] = "Madonna della Visitazione" - elif self.prov == 'FE': + elif self.prov == "FE": self[date(year, APR, 23)] = "San Giorgio" - elif self.prov == 'FI': + elif self.prov == "FI": self[date(year, JUN, 24)] = "San Giovanni Battista" - elif self.prov == 'FR': + elif self.prov == "FR": self[date(year, JUN, 20)] = "San Silverio" - elif self.prov == 'GE': + elif self.prov == "GE": self[date(year, JUN, 24)] = "San Giovanni Battista" - elif self.prov == 'GO': + elif self.prov == "GO": self[date(year, MAR, 16)] = "Santi Ilario e Taziano" - elif self.prov == 'IS': + elif self.prov == "IS": self[date(year, MAY, 19)] = "San Pietro Celestino" - elif self.prov == 'SP': + elif self.prov == "SP": self[date(year, MAR, 19)] = "San Giuseppe" - elif self.prov == 'LT': + elif self.prov == "LT": self[date(year, APR, 25)] = "San Marco evangelista" - elif self.prov == 'ME': + elif self.prov == "ME": self[date(year, JUN, 3)] = "Madonna della Lettera" - elif self.prov == 'MI': + elif self.prov == "MI": self[date(year, DEC, 7)] = "Sant'Ambrogio" - elif self.prov == 'MN': + elif self.prov == "MN": self[date(year, MAR, 18)] = "Sant'Anselmo da Baggio" - elif self.prov == 'MS': + elif self.prov == "MS": self[date(year, OCT, 4)] = "San Francesco d'Assisi" - elif self.prov == 'MO': + elif self.prov == "MO": self[date(year, JAN, 31)] = "San Geminiano" - elif self.prov == 'MB': + elif self.prov == "MB": self[date(year, JUN, 24)] = "San Giovanni Battista" - elif self.prov == 'NA': + elif self.prov == "NA": self[date(year, SEP, 19)] = "San Gennaro" - elif self.prov == 'PD': + elif self.prov == "PD": self[date(year, JUN, 13)] = "Sant'Antonio di Padova" - elif self.prov == 'PA': + elif self.prov == "PA": self[date(year, JUL, 15)] = "San Giovanni" - elif self.prov == 'PR': + elif self.prov == "PR": self[date(year, JAN, 13)] = "Sant'Ilario di Poitiers" - elif self.prov == 'PG': + elif self.prov == "PG": self[date(year, JAN, 29)] = "Sant'Ercolano e San Lorenzo" - elif self.prov == 'PC': + elif self.prov == "PC": self[date(year, JUL, 4)] = "Sant'Antonino di Piacenza" - elif self.prov == 'RM': + elif self.prov == "RM": self[date(year, JUN, 29)] = "Santi Pietro e Paolo" - elif self.prov == 'TO': + elif self.prov == "TO": self[date(year, JUN, 24)] = "San Giovanni Battista" - elif self.prov == 'TS': + elif self.prov == "TS": self[date(year, NOV, 3)] = "San Giusto" - elif self.prov == 'VI': + elif self.prov == "VI": self[date(year, APR, 25)] = "San Marco" # TODO: add missing provinces' holidays: diff --git a/holidays/countries/japan.py b/holidays/countries/japan.py index aa4327cb8..c7a0e90af 100644 --- a/holidays/countries/japan.py +++ b/holidays/countries/japan.py @@ -15,8 +15,7 @@ from dateutil.relativedelta import relativedelta as rd, MO -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, MAR, APR, MAY, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -24,7 +23,7 @@ class Japan(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Japan def __init__(self, **kwargs): - self.country = 'JP' + self.country = "JP" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -45,7 +44,7 @@ def _populate(self, year): # Reiwa Emperor's Birthday if year >= 2020: - self[date(year, FEB, 23)] = '天皇誕生日' + self[date(year, FEB, 23)] = "天皇誕生日" # Vernal Equinox Day self[self._vernal_equinox_day(year)] = "春分の日" @@ -112,9 +111,9 @@ def _populate(self, year): # Regarding the Emperor of Reiwa if year == 2019: # Enthronement Day - self[date(year, MAY, 1)] = '天皇の即位の日' + self[date(year, MAY, 1)] = "天皇の即位の日" # Enthronement ceremony - self[date(year, OCT, 22)] = '即位礼正殿の儀が行われる日' + self[date(year, OCT, 22)] = "即位礼正殿の儀が行われる日" # A weekday between national holidays becomes a holiday too (国民の休日) self._add_national_holidays(year) @@ -159,8 +158,23 @@ def _autumnal_equinox_day(self, year): return date(year, SEP, day) def _add_national_holidays(self, year): - if year in (1993, 1999, 2004, 1988, 1994, 2005, 1989, 1995, 2000, 2006, - 1990, 2001, 1991, 1996, 2002): + if year in ( + 1993, + 1999, + 2004, + 1988, + 1994, + 2005, + 1989, + 1995, + 2000, + 2006, + 1990, + 2001, + 1991, + 1996, + 2002, + ): self[date(year, MAY, 4)] = "国民の休日" if year in (2032, 2049, 2060, 2077, 2088, 2094): @@ -170,35 +184,56 @@ def _add_national_holidays(self, year): self[date(year, SEP, 22)] = "国民の休日" if year == 2019: - self[date(year, APR, 30)] = '国民の休日' - self[date(year, MAY, 2)] = '国民の休日' + self[date(year, APR, 30)] = "国民の休日" + self[date(year, MAY, 2)] = "国民の休日" def _add_substitute_holidays(self, year): table = ( - (1, 2, (1978, 1984, 1989, 1995, 2006, 2012, 2017, 2023, 2034, 2040, - 2045)), + (1, 2, (1978, 1984, 1989, 1995, 2006, 2012, 2017, 2023, 2034, 2040, 2045)), (1, 16, (1978, 1984, 1989, 1995)), - (2, 12, (1979, 1990, 1996, 2001, 2007, 2018, 2024, 2029, 2035, - 2046)), + (2, 12, (1979, 1990, 1996, 2001, 2007, 2018, 2024, 2029, 2035, 2046)), (2, 24, (2020,)), (3, 21, (1988, 2005, 2016, 2033, 2044, 2050)), (3, 22, (1982, 1999, 2010, 2027)), - (4, 30, (1973, 1979, 1984, 1990, 2001, 2007, 2012, 2018, 2029, - 2035, 2040, 2046)), + (4, 30, (1973, 1979, 1984, 1990, 2001, 2007, 2012, 2018, 2029, 2035, 2040, 2046)), (5, 4, (1981, 1987, 1992, 1998)), - (5, 6, (1985, 1991, 1996, 2002, 2013, 2019, 2024, 2030, 2041, 2047, - 2008, 2014, 2025, 2031, 2036, 2042, 2009, 2015, 2020, 2026, - 2037, 2043, 2048)), + ( + 5, + 6, + ( + 1985, + 1991, + 1996, + 2002, + 2013, + 2019, + 2024, + 2030, + 2041, + 2047, + 2008, + 2014, + 2025, + 2031, + 2036, + 2042, + 2009, + 2015, + 2020, + 2026, + 2037, + 2043, + 2048, + ), + ), (7, 21, (1997,)), (8, 12, (2019, 2024, 2030, 2041, 2047)), (9, 16, (1974, 1985, 1991, 1996, 2002)), (9, 23, (2024,)), (9, 24, (1973, 1984, 1990, 2001, 2007, 2018, 2029, 2035, 2046)), (10, 11, (1976, 1982, 1993, 1999)), - (11, 4, (1974, 1985, 1991, 1996, 2002, 2013, 2019, 2024, 2030, - 2041, 2047)), - (11, 24, (1975, 1980, 1986, 1997, 2003, 2008, 2014, 2025, 2031, - 2036, 2042)), + (11, 4, (1974, 1985, 1991, 1996, 2002, 2013, 2019, 2024, 2030, 2041, 2047)), + (11, 24, (1975, 1980, 1986, 1997, 2003, 2008, 2014, 2025, 2031, 2036, 2042)), (12, 24, (1990, 2001, 2007, 2012, 2018)), ) for holiday in table: diff --git a/holidays/countries/kenya.py b/holidays/countries/kenya.py index fc12d9693..88e8ca1fd 100644 --- a/holidays/countries/kenya.py +++ b/holidays/countries/kenya.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR, MO -from holidays.constants import JAN, MAY, JUN, OCT, \ - DEC +from holidays.constants import JAN, MAY, JUN, OCT, DEC from holidays.constants import SUN from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/korea.py b/holidays/countries/korea.py index e56de1ca8..a9650ac42 100644 --- a/holidays/countries/korea.py +++ b/holidays/countries/korea.py @@ -45,8 +45,7 @@ def _populate(self, year): if self.observed: self[first_date] = name if first_date.weekday() == SUN: - self[first_date + rd(days=+1)] = alt_holiday + \ - self.first_lower(name) + self[first_date + rd(days=+1)] = alt_holiday + self.first_lower(name) first_date = first_date + rd(days=+1) else: self[first_date] = name @@ -193,8 +192,9 @@ def _populate(self, year): # convert lunar calendar date to solar def get_solar_date(self, year, month, day): self.korean_cal.setLunarDate(year, month, day, False) - return date(self.korean_cal.solarYear, self.korean_cal.solarMonth, - self.korean_cal.solarDay) + return date( + self.korean_cal.solarYear, self.korean_cal.solarMonth, self.korean_cal.solarDay + ) def first_lower(self, s): return s[0].lower() + s[1:] diff --git a/holidays/countries/latvia.py b/holidays/countries/latvia.py index 5cd636a60..a8bf3ca0f 100644 --- a/holidays/countries/latvia.py +++ b/holidays/countries/latvia.py @@ -51,7 +51,9 @@ def _populate(self, year): # Latvia proclaimed its independence from the USSR, # and restoration of the Republic of Latvia. if year >= 1990: - self[date(year, 5, 4)] = "Latvijas Republikas \ + self[ + date(year, 5, 4) + ] = "Latvijas Republikas \ Neatkarības atjaunošanas diena" # by law @@ -67,8 +69,7 @@ def _populate(self, year): # Proclamation Day of the Republic of Latvia if year >= 1918: - self[date(year, 11, 18)] = \ - "Latvijas Republikas proklamēšanas diena" + self[date(year, 11, 18)] = "Latvijas Republikas proklamēšanas diena" # Christmas Eve self[date(year, 12, 24)] = "Ziemassvētku vakars" diff --git a/holidays/countries/lithuania.py b/holidays/countries/lithuania.py index f2de4c21c..baa680983 100644 --- a/holidays/countries/lithuania.py +++ b/holidays/countries/lithuania.py @@ -34,14 +34,12 @@ def _populate(self, year): # Day of Restoration of the State of Lithuania (1918) if year >= 1918: - self[date(year, 2, 16)] = "Lietuvos valstybės " \ - "atkūrimo diena" + self[date(year, 2, 16)] = "Lietuvos valstybės " "atkūrimo diena" # Day of Restoration of Independence of Lithuania # (from the Soviet Union, 1990) if year >= 1990: - self[date(year, 3, 11)] = "Lietuvos nepriklausomybės " \ - "atkūrimo diena" + self[date(year, 3, 11)] = "Lietuvos nepriklausomybės " "atkūrimo diena" # Easter easter_date = easter(year) @@ -66,13 +64,12 @@ def _populate(self, year): # Statehood Day if year >= 1991: - self[date(year, 7, 6)] = "Valstybės (Lietuvos " \ - "karaliaus Mindaugo " \ - "karūnavimo) diena" + self[date(year, 7, 6)] = ( + "Valstybės (Lietuvos " "karaliaus Mindaugo " "karūnavimo) diena" + ) # Assumption Day - self[date(year, 8, 15)] = "Žolinė (Švč. Mergelės " \ - "Marijos ėmimo į dangų diena)" + self[date(year, 8, 15)] = "Žolinė (Švč. Mergelės " "Marijos ėmimo į dangų diena)" # All Saints' Day self[date(year, 11, 1)] = "Visų šventųjų diena (Vėlinės)" diff --git a/holidays/countries/luxembourg.py b/holidays/countries/luxembourg.py index 7f8841ddf..6dbc2da61 100644 --- a/holidays/countries/luxembourg.py +++ b/holidays/countries/luxembourg.py @@ -25,7 +25,7 @@ class Luxembourg(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Luxembourg def __init__(self, **kwargs): - self.country = 'LU' + self.country = "LU" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/mexico.py b/holidays/countries/mexico.py index 9a51939b3..aa9629755 100755 --- a/holidays/countries/mexico.py +++ b/holidays/countries/mexico.py @@ -21,9 +21,8 @@ class Mexico(HolidayBase): - def __init__(self, **kwargs): - self.country = 'MX' + self.country = "MX" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -40,8 +39,7 @@ def _populate(self, year): # Constitution Day name = "Día de la Constitución [Constitution Day]" if self.observed and year >= 2007: - self[date(year, FEB, 1) + rd(weekday=MO(+1))] = \ - name + " (Observed)" + self[date(year, FEB, 1) + rd(weekday=MO(+1))] = name + " (Observed)" if year >= 1917: self[date(year, FEB, 5)] = name @@ -49,8 +47,7 @@ def _populate(self, year): # Benito Juárez's birthday name = "Natalicio de Benito Juárez [Benito Juárez's birthday]" if self.observed and year >= 2007: - self[date(year, MAR, 1) + rd(weekday=MO(+3))] = \ - name + " (Observed)" + self[date(year, MAR, 1) + rd(weekday=MO(+3))] = name + " (Observed)" if year >= 1917: self[date(year, MAR, 21)] = name @@ -74,8 +71,7 @@ def _populate(self, year): # Revolution Day name = "Día de la Revolución [Revolution Day]" if self.observed and year >= 2007: - self[date(year, NOV, 1) + rd(weekday=MO(+3))] = \ - name + " (Observed)" + self[date(year, NOV, 1) + rd(weekday=MO(+3))] = name + " (Observed)" if year >= 1917: self[date(year, NOV, 20)] = name diff --git a/holidays/countries/morocco.py b/holidays/countries/morocco.py index 284822447..6d93488a8 100644 --- a/holidays/countries/morocco.py +++ b/holidays/countries/morocco.py @@ -43,7 +43,7 @@ class Morocco(HolidayBase): """ def __init__(self, **kwargs): - self.country = 'MA' + self.country = "MA" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -65,8 +65,9 @@ def is_weekend(self, hol_date, hol_name): # Independence Manifesto Day post 1944 if year > 1944: - self[date(year, JAN, 11)] = "Commémoration de la présentation " \ - "du manifeste de l'indépendance" + self[date(year, JAN, 11)] = ( + "Commémoration de la présentation " "du manifeste de l'indépendance" + ) # Labor day self[date(year, MAY, 1)] = "Fête du Travail" @@ -83,8 +84,7 @@ def is_weekend(self, hol_date, hol_name): self[date(year, AUG, 14)] = "Journée de Oued Ed-Dahab" # Revolution Day - self[date(year, AUG, 20)] = "Commémoration de la révolution du " \ - "Roi et du peuple" + self[date(year, AUG, 20)] = "Commémoration de la révolution du " "Roi et du peuple" # Youth day if year > 2000: diff --git a/holidays/countries/netherlands.py b/holidays/countries/netherlands.py index 4a736488b..244141d16 100644 --- a/holidays/countries/netherlands.py +++ b/holidays/countries/netherlands.py @@ -22,7 +22,6 @@ class Netherlands(HolidayBase): - def __init__(self, **kwargs): # http://www.iamsterdam.com/en/plan-your-trip/practical-info/public-holidays self.country = "NL" diff --git a/holidays/countries/new_zealand.py b/holidays/countries/new_zealand.py index 62b02a6b9..05016d8b5 100644 --- a/holidays/countries/new_zealand.py +++ b/holidays/countries/new_zealand.py @@ -16,18 +16,30 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, FR, WE, TU -from holidays.constants import JAN, FEB, MAR, APR, JUN, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, MAR, APR, JUN, SEP, OCT, NOV, DEC from holidays.constants import TUE, WED, THU, WEEKEND from holidays.holiday_base import HolidayBase class NewZealand(HolidayBase): - PROVINCES = ['NTL', 'AUK', 'TKI', 'HKB', 'WGN', 'MBH', 'NSN', 'CAN', - 'STC', 'WTL', 'OTA', 'STL', 'CIT'] + PROVINCES = [ + "NTL", + "AUK", + "TKI", + "HKB", + "WGN", + "MBH", + "NSN", + "CAN", + "STC", + "WTL", + "OTA", + "STL", + "CIT", + ] def __init__(self, **kwargs): - self.country = 'NZ' + self.country = "NZ" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -120,8 +132,8 @@ def _populate(self, year): self[date(year, DEC, 28)] = name + " (Observed)" # Province Anniversary Day - if self.prov in ('NTL', 'Northland', 'AUK', 'Auckland'): - if 1963 < year <= 1973 and self.prov in ('NTL', 'Northland'): + if self.prov in ("NTL", "Northland", "AUK", "Auckland"): + if 1963 < year <= 1973 and self.prov in ("NTL", "Northland"): name = "Waitangi Day" dt = date(year, FEB, 6) else: @@ -132,16 +144,16 @@ def _populate(self, year): else: self[dt + rd(weekday=MO)] = name - elif self.prov in ('TKI', 'Taranaki', 'New Plymouth'): + elif self.prov in ("TKI", "Taranaki", "New Plymouth"): name = "Taranaki Anniversary Day" self[date(year, MAR, 1) + rd(weekday=MO(+2))] = name - elif self.prov in ('HKB', "Hawke's Bay"): + elif self.prov in ("HKB", "Hawke's Bay"): name = "Hawke's Bay Anniversary Day" labour_day = date(year, OCT, 1) + rd(weekday=MO(+4)) self[labour_day + rd(weekday=FR(-1))] = name - elif self.prov in ('WGN', 'Wellington'): + elif self.prov in ("WGN", "Wellington"): name = "Wellington Anniversary Day" jan22 = date(year, JAN, 22) if jan22.weekday() in (TUE, WED, THU): @@ -149,12 +161,12 @@ def _populate(self, year): else: self[jan22 + rd(weekday=MO)] = name - elif self.prov in ('MBH', 'Marlborough'): + elif self.prov in ("MBH", "Marlborough"): name = "Marlborough Anniversary Day" labour_day = date(year, OCT, 1) + rd(weekday=MO(+4)) self[labour_day + rd(weeks=1)] = name - elif self.prov in ('NSN', 'Nelson'): + elif self.prov in ("NSN", "Nelson"): name = "Nelson Anniversary Day" feb1 = date(year, FEB, 1) if feb1.weekday() in (TUE, WED, THU): @@ -162,18 +174,17 @@ def _populate(self, year): else: self[feb1 + rd(weekday=MO)] = name - elif self.prov in ('CAN', 'Canterbury'): + elif self.prov in ("CAN", "Canterbury"): name = "Canterbury Anniversary Day" - showday = date(year, NOV, 1) + rd(weekday=TU) + \ - rd(weekday=FR(+2)) + showday = date(year, NOV, 1) + rd(weekday=TU) + rd(weekday=FR(+2)) self[showday] = name - elif self.prov in ('STC', 'South Canterbury'): + elif self.prov in ("STC", "South Canterbury"): name = "South Canterbury Anniversary Day" dominion_day = date(year, SEP, 1) + rd(weekday=MO(4)) self[dominion_day] = name - elif self.prov in ('WTL', 'Westland'): + elif self.prov in ("WTL", "Westland"): name = "Westland Anniversary Day" dec1 = date(year, DEC, 1) # Observance varies?!?! @@ -184,7 +195,7 @@ def _populate(self, year): else: self[dec1 + rd(weekday=MO)] = name - elif self.prov in ('OTA', 'Otago'): + elif self.prov in ("OTA", "Otago"): name = "Otago Anniversary Day" mar23 = date(year, MAR, 23) # there is no easily determined single day of local observance?!?! @@ -196,7 +207,7 @@ def _populate(self, year): dt += rd(days=1) self[dt] = name - elif self.prov in ('STL', 'Southland'): + elif self.prov in ("STL", "Southland"): name = "Southland Anniversary Day" jan17 = date(year, JAN, 17) if year > 2011: @@ -207,7 +218,7 @@ def _populate(self, year): else: self[jan17 + rd(weekday=MO)] = name - elif self.prov in ('CIT', 'Chatham Islands'): + elif self.prov in ("CIT", "Chatham Islands"): name = "Chatham Islands Anniversary Day" nov30 = date(year, NOV, 30) if nov30.weekday() in (TUE, WED, THU): diff --git a/holidays/countries/nicaragua.py b/holidays/countries/nicaragua.py index fb560ee52..24e55b8d8 100644 --- a/holidays/countries/nicaragua.py +++ b/holidays/countries/nicaragua.py @@ -21,19 +21,18 @@ class Nicaragua(HolidayBase): - PROVINCES = ['MN'] + PROVINCES = ["MN"] def __init__(self, **kwargs): - self.country = 'NI' - self.prov = kwargs.pop('prov', kwargs.pop('state', 'MN')) + self.country = "NI" + self.prov = kwargs.pop("prov", kwargs.pop("state", "MN")) HolidayBase.__init__(self, **kwargs) def _populate(self, year): # New Years self[date(year, JAN, 1)] = "Año Nuevo [New Year's Day]" # Maundy Thursday - self[easter(year) + rd(weekday=TH(-1))] =\ - "Jueves Santo [Maundy Thursday]" + self[easter(year) + rd(weekday=TH(-1))] = "Jueves Santo [Maundy Thursday]" # Good Friday self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]" # Labor Day @@ -42,11 +41,9 @@ def _populate(self, year): if 2020 >= year >= 1979: self[date(year, JUL, 19)] = "Día de la Revolución [Revolution Day]" # Battle of San Jacinto Day - self[date(year, SEP, 14)] =\ - "Batalla de San Jacinto [Battle of San Jacinto]" + self[date(year, SEP, 14)] = "Batalla de San Jacinto [Battle of San Jacinto]" # Independence Day - self[date(year, SEP, 15)] =\ - "Día de la Independencia [Independence Day]" + self[date(year, SEP, 15)] = "Día de la Independencia [Independence Day]" # Virgin's Day self[date(year, DEC, 8)] = "Concepción de María [Virgin's Day]" # Christmas @@ -54,7 +51,7 @@ def _populate(self, year): # Provinces festive day if self.prov: - if self.prov == 'MN': + if self.prov == "MN": # Santo Domingo Day Down self[date(year, AUG, 1)] = "Bajada de Santo Domingo" # Santo Domingo Day Up diff --git a/holidays/countries/nigeria.py b/holidays/countries/nigeria.py index 12ac20551..740f8036c 100644 --- a/holidays/countries/nigeria.py +++ b/holidays/countries/nigeria.py @@ -13,8 +13,7 @@ from datetime import date -from holidays.constants import JAN, MAY, JUN, OCT, \ - DEC +from holidays.constants import JAN, MAY, JUN, OCT, DEC from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/norway.py b/holidays/countries/norway.py index 3fca43439..01e2c5b31 100644 --- a/holidays/countries/norway.py +++ b/holidays/countries/norway.py @@ -52,9 +52,7 @@ def _populate(self, year): # Add all the sundays of the year before adding the "real" holidays if self.include_sundays: first_day_of_year = date(year, JAN, 1) - first_sunday_of_year = \ - first_day_of_year + \ - rd(days=SUN - first_day_of_year.weekday()) + first_sunday_of_year = first_day_of_year + rd(days=SUN - first_day_of_year.weekday()) cur_date = first_sunday_of_year while cur_date < date(year + 1, 1, 1): diff --git a/holidays/countries/paraguay.py b/holidays/countries/paraguay.py index ad835791d..b03f88e25 100644 --- a/holidays/countries/paraguay.py +++ b/holidays/countries/paraguay.py @@ -27,7 +27,7 @@ class Paraguay(HolidayBase): # http://www.calendarioparaguay.com/ def __init__(self, **kwargs): - self.country = 'PY' + self.country = "PY" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -38,8 +38,7 @@ def _populate(self, year): self[date(year, JAN, 1)] = "Año Nuevo [New Year's Day]" # Patriots day - name = "Día de los Héroes de la Patria" \ - "[Patriots Day]" + name = "Día de los Héroes de la Patria" "[Patriots Day]" if not self.observed and date(year, MAR, 1).weekday() in WEEKEND: pass @@ -51,7 +50,7 @@ def _populate(self, year): # Holy Week name_thu = "Semana Santa (Jueves Santo) [Holy day (Holy Thursday)]" name_fri = "Semana Santa (Viernes Santo) [Holy day (Holy Friday)]" - name_easter = 'Día de Pascuas [Easter Day]' + name_easter = "Día de Pascuas [Easter Day]" self[easter(year) + rd(weekday=TH(-1))] = name_thu self[easter(year) + rd(weekday=FR(-1))] = name_fri diff --git a/holidays/countries/peru.py b/holidays/countries/peru.py index a4647302c..b0a4d5912 100644 --- a/holidays/countries/peru.py +++ b/holidays/countries/peru.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, TH, FR, SA, SU -from holidays.constants import JAN, MAY, JUN, JUL, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUN, JUL, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -52,20 +51,16 @@ def _populate(self, year): self[date(year, OCT, 8)] = name # Holy Thursday - self[easter(year) + rd(weekday=TH(-1)) - ] = "Jueves Santo [Maundy Thursday]" + self[easter(year) + rd(weekday=TH(-1))] = "Jueves Santo [Maundy Thursday]" # Good Friday - self[easter(year) + rd(weekday=FR(-1)) - ] = "Viernes Santo [Good Friday]" + self[easter(year) + rd(weekday=FR(-1))] = "Viernes Santo [Good Friday]" # Holy Saturday - self[easter(year) + rd(weekday=SA(-1)) - ] = "Sábado de Gloria [Holy Saturday]" + self[easter(year) + rd(weekday=SA(-1))] = "Sábado de Gloria [Holy Saturday]" # Easter Sunday - self[easter(year) + rd(weekday=SU(-1)) - ] = "Domingo de Resurrección [Easter Sunday]" + self[easter(year) + rd(weekday=SU(-1))] = "Domingo de Resurrección [Easter Sunday]" # Labor Day self[date(year, MAY, 1)] = "Día del Trabajo [Labour Day]" diff --git a/holidays/countries/poland.py b/holidays/countries/poland.py index 48257355b..3db5ed814 100644 --- a/holidays/countries/poland.py +++ b/holidays/countries/poland.py @@ -25,34 +25,34 @@ class Poland(HolidayBase): # https://pl.wikipedia.org/wiki/Dni_wolne_od_pracy_w_Polsce def __init__(self, **kwargs): - self.country = 'PL' + self.country = "PL" HolidayBase.__init__(self, **kwargs) def _populate(self, year): - self[date(year, JAN, 1)] = 'Nowy Rok' + self[date(year, JAN, 1)] = "Nowy Rok" if year >= 2011: - self[date(year, JAN, 6)] = 'Święto Trzech Króli' + self[date(year, JAN, 6)] = "Święto Trzech Króli" e = easter(year) - self[e] = 'Niedziela Wielkanocna' - self[e + rd(days=1)] = 'Poniedziałek Wielkanocny' + self[e] = "Niedziela Wielkanocna" + self[e + rd(days=1)] = "Poniedziałek Wielkanocny" if year >= 1950: - self[date(year, MAY, 1)] = 'Święto Państwowe' + self[date(year, MAY, 1)] = "Święto Państwowe" if year >= 1919: - self[date(year, MAY, 3)] = 'Święto Narodowe Trzeciego Maja' + self[date(year, MAY, 3)] = "Święto Narodowe Trzeciego Maja" - self[e + rd(days=49)] = 'Zielone Świątki' - self[e + rd(days=60)] = 'Dzień Bożego Ciała' + self[e + rd(days=49)] = "Zielone Świątki" + self[e + rd(days=60)] = "Dzień Bożego Ciała" - self[date(year, AUG, 15)] = 'Wniebowzięcie Najświętszej Marii Panny' + self[date(year, AUG, 15)] = "Wniebowzięcie Najświętszej Marii Panny" - self[date(year, NOV, 1)] = 'Uroczystość Wszystkich świętych' + self[date(year, NOV, 1)] = "Uroczystość Wszystkich świętych" if (1937 <= year <= 1945) or year >= 1989: - self[date(year, NOV, 11)] = 'Narodowe Święto Niepodległości' + self[date(year, NOV, 11)] = "Narodowe Święto Niepodległości" - self[date(year, DEC, 25)] = 'Boże Narodzenie (pierwszy dzień)' - self[date(year, DEC, 26)] = 'Boże Narodzenie (drugi dzień)' + self[date(year, DEC, 25)] = "Boże Narodzenie (pierwszy dzień)" + self[date(year, DEC, 26)] = "Boże Narodzenie (drugi dzień)" class PL(Poland): @@ -65,6 +65,5 @@ class POL(Poland): class Polish(Poland): def __init__(self, **kwargs): - warnings.warn("Polish is deprecated, use Poland instead.", - DeprecationWarning) + warnings.warn("Polish is deprecated, use Poland instead.", DeprecationWarning) super(Polish, self).__init__(**kwargs) diff --git a/holidays/countries/portugal.py b/holidays/countries/portugal.py index 40a9e469d..c185bf9f3 100644 --- a/holidays/countries/portugal.py +++ b/holidays/countries/portugal.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, OCT, \ - NOV, DEC +from holidays.constants import JAN, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -25,7 +24,7 @@ class Portugal(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Portugal def __init__(self, **kwargs): - self.country = 'PT' + self.country = "PT" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/romania.py b/holidays/countries/romania.py index 927fdb374..ec07f42bd 100644 --- a/holidays/countries/romania.py +++ b/holidays/countries/romania.py @@ -24,7 +24,7 @@ class Romania(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Romania def __init__(self, **kwargs): - self.country = 'RO' + self.country = "RO" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/serbia.py b/holidays/countries/serbia.py index 0f998a26e..4d4a79434 100644 --- a/holidays/countries/serbia.py +++ b/holidays/countries/serbia.py @@ -25,7 +25,7 @@ class Serbia(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Serbia def __init__(self, **kwargs): - self.country = 'RS' + self.country = "RS" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -56,13 +56,10 @@ def _populate(self, year): if self.observed and date(year, NOV, 11).weekday() == SUN: self[date(year, NOV, 12)] = name + " (Observed)" # Easter - self[easter(year, method=EASTER_ORTHODOX) - rd(days=2)] = \ - "Велики петак" - self[easter(year, method=EASTER_ORTHODOX) - rd(days=1)] = \ - "Велика субота" + self[easter(year, method=EASTER_ORTHODOX) - rd(days=2)] = "Велики петак" + self[easter(year, method=EASTER_ORTHODOX) - rd(days=1)] = "Велика субота" self[easter(year, method=EASTER_ORTHODOX)] = "Васкрс" - self[easter(year, method=EASTER_ORTHODOX) + rd(days=1)] = \ - "Други дан Васкрса" + self[easter(year, method=EASTER_ORTHODOX) + rd(days=1)] = "Други дан Васкрса" class RS(Serbia): diff --git a/holidays/countries/singapore.py b/holidays/countries/singapore.py index ead9e9083..77d1a301e 100644 --- a/holidays/countries/singapore.py +++ b/holidays/countries/singapore.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, SA, FR, MO -from holidays.constants import JAN, FEB, MAR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, MAR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.constants import SUN from holidays.holiday_base import HolidayBase from holidays.utils import get_gre_date @@ -49,7 +48,6 @@ def __init__(self, **kwargs): HolidayBase.__init__(self, **kwargs) def _populate(self, year): - def storeholiday(self, hol_date, hol_name): """ Function to store the holiday name in the appropriate @@ -75,14 +73,29 @@ def storeholiday(self, hol_date, hol_name): # Hari Raya Puasa # aka Eid al-Fitr # date of observance is announced yearly - dates_obs = {2001: [(DEC, 16)], 2002: [(DEC, 6)], - 2003: [(NOV, 25)], 2004: [(NOV, 14)], 2005: [(NOV, 3)], - 2006: [(OCT, 24)], 2007: [(OCT, 13)], 2008: [(OCT, 1)], - 2009: [(SEP, 20)], 2010: [(SEP, 10)], 2011: [(AUG, 30)], - 2012: [(AUG, 19)], 2013: [(AUG, 8)], 2014: [(JUL, 28)], - 2015: [(JUL, 17)], 2016: [(JUL, 6)], 2017: [(JUN, 25)], - 2018: [(JUN, 15)], 2019: [(JUN, 5)], 2020: [(MAY, 24)], - 2021: [(MAY, 13)]} + dates_obs = { + 2001: [(DEC, 16)], + 2002: [(DEC, 6)], + 2003: [(NOV, 25)], + 2004: [(NOV, 14)], + 2005: [(NOV, 3)], + 2006: [(OCT, 24)], + 2007: [(OCT, 13)], + 2008: [(OCT, 1)], + 2009: [(SEP, 20)], + 2010: [(SEP, 10)], + 2011: [(AUG, 30)], + 2012: [(AUG, 19)], + 2013: [(AUG, 8)], + 2014: [(JUL, 28)], + 2015: [(JUL, 17)], + 2016: [(JUL, 6)], + 2017: [(JUN, 25)], + 2018: [(JUN, 15)], + 2019: [(JUN, 5)], + 2020: [(MAY, 24)], + 2021: [(MAY, 13)], + } if year in dates_obs: for date_obs in dates_obs[year]: hol_date = date(year, *date_obs) @@ -96,34 +109,47 @@ def storeholiday(self, hol_date, hol_name): else: for date_obs in self.get_hrp_date(year): hol_date = date_obs - storeholiday(self, hol_date, - "Hari Raya Puasa* (*estimated)") + storeholiday(self, hol_date, "Hari Raya Puasa* (*estimated)") # Second day of Hari Raya Puasa (up to and including 1968) if year <= 1968: - storeholiday(self, hol_date + rd(days=+1), - "Second day of Hari Raya Puasa* (*estimated)") + storeholiday( + self, hol_date + rd(days=+1), "Second day of Hari Raya Puasa* (*estimated)" + ) # Hari Raya Haji # aka Eid al-Adha # date of observance is announced yearly - dates_obs = {2001: [(MAR, 6)], 2002: [(FEB, 23)], - 2003: [(FEB, 12)], 2004: [(FEB, 1)], 2005: [(JAN, 21)], - 2006: [(JAN, 10)], 2007: [(DEC, 20)], 2008: [(DEC, 8)], - 2009: [(NOV, 27)], 2010: [(NOV, 17)], 2011: [(NOV, 6)], - 2012: [(OCT, 26)], 2013: [(OCT, 15)], 2014: [(OCT, 5)], - 2015: [(SEP, 24)], 2016: [(SEP, 12)], 2017: [(SEP, 1)], - 2018: [(AUG, 22)], 2019: [(AUG, 11)], 2020: [(JUL, 31)], - 2021: [(JUL, 20)]} + dates_obs = { + 2001: [(MAR, 6)], + 2002: [(FEB, 23)], + 2003: [(FEB, 12)], + 2004: [(FEB, 1)], + 2005: [(JAN, 21)], + 2006: [(JAN, 10)], + 2007: [(DEC, 20)], + 2008: [(DEC, 8)], + 2009: [(NOV, 27)], + 2010: [(NOV, 17)], + 2011: [(NOV, 6)], + 2012: [(OCT, 26)], + 2013: [(OCT, 15)], + 2014: [(OCT, 5)], + 2015: [(SEP, 24)], + 2016: [(SEP, 12)], + 2017: [(SEP, 1)], + 2018: [(AUG, 22)], + 2019: [(AUG, 11)], + 2020: [(JUL, 31)], + 2021: [(JUL, 20)], + } if year in dates_obs: for date_obs in dates_obs[year]: hol_date = date(year, *date_obs) - storeholiday(self, hol_date, - "Hari Raya Haji") + storeholiday(self, hol_date, "Hari Raya Haji") else: for date_obs in self.get_hrh_date(year): hol_date = date_obs - storeholiday(self, hol_date, - "Hari Raya Haji* (*estimated)") + storeholiday(self, hol_date, "Hari Raya Haji* (*estimated)") # Holy Saturday (up to and including 1968) if year <= 1968: @@ -142,20 +168,36 @@ def storeholiday(self, hol_date, hol_name): # Vesak Day # date of observance is announced yearly # https://en.wikipedia.org/wiki/Vesak#Dates_of_observance - dates_obs = {2001: (MAY, 7), 2002: (MAY, 27), - 2003: (MAY, 15), 2004: (JUN, 2), 2005: (MAY, 23), - 2006: (MAY, 12), 2007: (MAY, 31), 2008: (MAY, 19), - 2009: (MAY, 9), 2010: (MAY, 28), 2011: (MAY, 17), - 2012: (MAY, 5), 2013: (MAY, 24), 2014: (MAY, 13), - 2015: (JUN, 1), 2016: (MAY, 20), 2017: (MAY, 10), - 2018: (MAY, 29), 2019: (MAY, 19), 2020: (MAY, 7), - 2021: (MAY, 26)} + dates_obs = { + 2001: (MAY, 7), + 2002: (MAY, 27), + 2003: (MAY, 15), + 2004: (JUN, 2), + 2005: (MAY, 23), + 2006: (MAY, 12), + 2007: (MAY, 31), + 2008: (MAY, 19), + 2009: (MAY, 9), + 2010: (MAY, 28), + 2011: (MAY, 17), + 2012: (MAY, 5), + 2013: (MAY, 24), + 2014: (MAY, 13), + 2015: (JUN, 1), + 2016: (MAY, 20), + 2017: (MAY, 10), + 2018: (MAY, 29), + 2019: (MAY, 19), + 2020: (MAY, 7), + 2021: (MAY, 26), + } if year in dates_obs: hol_date = date(year, *dates_obs[year]) storeholiday(self, hol_date, "Vesak Day") else: - storeholiday(self, self.get_vesak_date(year), - "Vesak Day* (*estimated; ~10% chance +/- 1 day)") + storeholiday( + self, self.get_vesak_date(year), "Vesak Day* (*estimated; ~10% chance +/- 1 day)" + ) # National Day storeholiday(self, date(year, AUG, 9), "National Day") @@ -163,20 +205,36 @@ def storeholiday(self, hol_date, hol_name): # Deepavali # aka Diwali # date of observance is announced yearly - dates_obs = {2001: (NOV, 14), 2002: (NOV, 3), - 2003: (OCT, 23), 2004: (NOV, 11), 2005: (NOV, 1), - 2006: (OCT, 21), 2007: (NOV, 8), 2008: (OCT, 27), - 2009: (OCT, 17), 2010: (NOV, 5), 2011: (OCT, 26), - 2012: (NOV, 13), 2013: (NOV, 2), 2014: (OCT, 22), - 2015: (NOV, 10), 2016: (OCT, 29), 2017: (OCT, 18), - 2018: (NOV, 6), 2019: (OCT, 27), 2020: (NOV, 14), - 2021: (NOV, 4)} + dates_obs = { + 2001: (NOV, 14), + 2002: (NOV, 3), + 2003: (OCT, 23), + 2004: (NOV, 11), + 2005: (NOV, 1), + 2006: (OCT, 21), + 2007: (NOV, 8), + 2008: (OCT, 27), + 2009: (OCT, 17), + 2010: (NOV, 5), + 2011: (OCT, 26), + 2012: (NOV, 13), + 2013: (NOV, 2), + 2014: (OCT, 22), + 2015: (NOV, 10), + 2016: (OCT, 29), + 2017: (OCT, 18), + 2018: (NOV, 6), + 2019: (OCT, 27), + 2020: (NOV, 14), + 2021: (NOV, 4), + } if year in dates_obs: hol_date = date(year, *dates_obs[year]) storeholiday(self, hol_date, "Deepavali") else: - storeholiday(self, self.get_s_diwali_date(year), - "Deepavali* (*estimated; rarely on day after)") + storeholiday( + self, self.get_s_diwali_date(year), "Deepavali* (*estimated; rarely on day after)" + ) # Christmas Day storeholiday(self, date(year, DEC, 25), "Christmas Day") @@ -186,8 +244,13 @@ def storeholiday(self, hol_date, hol_name): storeholiday(self, date(year, DEC, 26), "Boxing Day") # Polling Day - dates_obs = {2001: (NOV, 3), 2006: (MAY, 6), 2011: (MAY, 7), - 2015: (SEP, 11), 2020: (JUL, 10)} + dates_obs = { + 2001: (NOV, 3), + 2006: (MAY, 6), + 2011: (MAY, 7), + 2015: (SEP, 11), + 2020: (JUL, 10), + } if year in dates_obs: self[date(year, *dates_obs[year])] = "Polling Day" @@ -207,46 +270,205 @@ def storeholiday(self, hol_date, hol_name): # 29 days. The 12th to 15th digits indicate the month of the next month. # If it is 0x0F, it means that there is no leap month. g_lunar_month_days = [ - 0xF0EA4, 0xF1D4A, 0x52C94, 0xF0C96, 0xF1536, - 0x42AAC, 0xF0AD4, 0xF16B2, 0x22EA4, 0xF0EA4, # 1901-1910 - 0x6364A, 0xF164A, 0xF1496, 0x52956, 0xF055A, - 0xF0AD6, 0x216D2, 0xF1B52, 0x73B24, 0xF1D24, # 1911-1920 - 0xF1A4A, 0x5349A, 0xF14AC, 0xF056C, 0x42B6A, - 0xF0DA8, 0xF1D52, 0x23D24, 0xF1D24, 0x61A4C, # 1921-1930 - 0xF0A56, 0xF14AE, 0x5256C, 0xF16B4, 0xF0DA8, - 0x31D92, 0xF0E92, 0x72D26, 0xF1526, 0xF0A56, # 1931-1940 - 0x614B6, 0xF155A, 0xF0AD4, 0x436AA, 0xF1748, - 0xF1692, 0x23526, 0xF152A, 0x72A5A, 0xF0A6C, # 1941-1950 - 0xF155A, 0x52B54, 0xF0B64, 0xF1B4A, 0x33A94, - 0xF1A94, 0x8152A, 0xF152E, 0xF0AAC, 0x6156A, # 1951-1960 - 0xF15AA, 0xF0DA4, 0x41D4A, 0xF1D4A, 0xF0C94, - 0x3192E, 0xF1536, 0x72AB4, 0xF0AD4, 0xF16D2, # 1961-1970 - 0x52EA4, 0xF16A4, 0xF164A, 0x42C96, 0xF1496, - 0x82956, 0xF055A, 0xF0ADA, 0x616D2, 0xF1B52, # 1971-1980 - 0xF1B24, 0x43A4A, 0xF1A4A, 0xA349A, 0xF14AC, - 0xF056C, 0x60B6A, 0xF0DAA, 0xF1D92, 0x53D24, # 1981-1990 - 0xF1D24, 0xF1A4C, 0x314AC, 0xF14AE, 0x829AC, - 0xF06B4, 0xF0DAA, 0x52D92, 0xF0E92, 0xF0D26, # 1991-2000 - 0x42A56, 0xF0A56, 0xF14B6, 0x22AB4, 0xF0AD4, - 0x736AA, 0xF1748, 0xF1692, 0x53526, 0xF152A, # 2001-2010 - 0xF0A5A, 0x4155A, 0xF156A, 0x92B54, 0xF0BA4, - 0xF1B4A, 0x63A94, 0xF1A94, 0xF192A, 0x42A5C, # 2011-2020 - 0xF0AAC, 0xF156A, 0x22B64, 0xF0DA4, 0x61D52, - 0xF0E4A, 0xF0C96, 0x5192E, 0xF1956, 0xF0AB4, # 2021-2030 - 0x315AC, 0xF16D2, 0xB2EA4, 0xF16A4, 0xF164A, - 0x63496, 0xF1496, 0xF0956, 0x50AB6, 0xF0B5A, # 2031-2040 - 0xF16D4, 0x236A4, 0xF1B24, 0x73A4A, 0xF1A4A, - 0xF14AA, 0x5295A, 0xF096C, 0xF0B6A, 0x31B54, # 2041-2050 - 0xF1D92, 0x83D24, 0xF1D24, 0xF1A4C, 0x614AC, - 0xF14AE, 0xF09AC, 0x40DAA, 0xF0EAA, 0xF0E92, # 2051-2060 - 0x31D26, 0xF0D26, 0x72A56, 0xF0A56, 0xF14B6, - 0x52AB4, 0xF0AD4, 0xF16CA, 0x42E94, 0xF1694, # 2061-2070 - 0x8352A, 0xF152A, 0xF0A5A, 0x6155A, 0xF156A, - 0xF0B54, 0x4174A, 0xF1B4A, 0xF1A94, 0x3392A, # 2071-2080 - 0xF192C, 0x7329C, 0xF0AAC, 0xF156A, 0x52B64, - 0xF0DA4, 0xF1D4A, 0x41C94, 0xF0C96, 0x8192E, # 2081-2090 - 0xF0956, 0xF0AB6, 0x615AC, 0xF16D4, 0xF0EA4, - 0x42E4A, 0xF164A, 0xF1516, 0x22936, # 2090-2099 + 0xF0EA4, + 0xF1D4A, + 0x52C94, + 0xF0C96, + 0xF1536, + 0x42AAC, + 0xF0AD4, + 0xF16B2, + 0x22EA4, + 0xF0EA4, # 1901-1910 + 0x6364A, + 0xF164A, + 0xF1496, + 0x52956, + 0xF055A, + 0xF0AD6, + 0x216D2, + 0xF1B52, + 0x73B24, + 0xF1D24, # 1911-1920 + 0xF1A4A, + 0x5349A, + 0xF14AC, + 0xF056C, + 0x42B6A, + 0xF0DA8, + 0xF1D52, + 0x23D24, + 0xF1D24, + 0x61A4C, # 1921-1930 + 0xF0A56, + 0xF14AE, + 0x5256C, + 0xF16B4, + 0xF0DA8, + 0x31D92, + 0xF0E92, + 0x72D26, + 0xF1526, + 0xF0A56, # 1931-1940 + 0x614B6, + 0xF155A, + 0xF0AD4, + 0x436AA, + 0xF1748, + 0xF1692, + 0x23526, + 0xF152A, + 0x72A5A, + 0xF0A6C, # 1941-1950 + 0xF155A, + 0x52B54, + 0xF0B64, + 0xF1B4A, + 0x33A94, + 0xF1A94, + 0x8152A, + 0xF152E, + 0xF0AAC, + 0x6156A, # 1951-1960 + 0xF15AA, + 0xF0DA4, + 0x41D4A, + 0xF1D4A, + 0xF0C94, + 0x3192E, + 0xF1536, + 0x72AB4, + 0xF0AD4, + 0xF16D2, # 1961-1970 + 0x52EA4, + 0xF16A4, + 0xF164A, + 0x42C96, + 0xF1496, + 0x82956, + 0xF055A, + 0xF0ADA, + 0x616D2, + 0xF1B52, # 1971-1980 + 0xF1B24, + 0x43A4A, + 0xF1A4A, + 0xA349A, + 0xF14AC, + 0xF056C, + 0x60B6A, + 0xF0DAA, + 0xF1D92, + 0x53D24, # 1981-1990 + 0xF1D24, + 0xF1A4C, + 0x314AC, + 0xF14AE, + 0x829AC, + 0xF06B4, + 0xF0DAA, + 0x52D92, + 0xF0E92, + 0xF0D26, # 1991-2000 + 0x42A56, + 0xF0A56, + 0xF14B6, + 0x22AB4, + 0xF0AD4, + 0x736AA, + 0xF1748, + 0xF1692, + 0x53526, + 0xF152A, # 2001-2010 + 0xF0A5A, + 0x4155A, + 0xF156A, + 0x92B54, + 0xF0BA4, + 0xF1B4A, + 0x63A94, + 0xF1A94, + 0xF192A, + 0x42A5C, # 2011-2020 + 0xF0AAC, + 0xF156A, + 0x22B64, + 0xF0DA4, + 0x61D52, + 0xF0E4A, + 0xF0C96, + 0x5192E, + 0xF1956, + 0xF0AB4, # 2021-2030 + 0x315AC, + 0xF16D2, + 0xB2EA4, + 0xF16A4, + 0xF164A, + 0x63496, + 0xF1496, + 0xF0956, + 0x50AB6, + 0xF0B5A, # 2031-2040 + 0xF16D4, + 0x236A4, + 0xF1B24, + 0x73A4A, + 0xF1A4A, + 0xF14AA, + 0x5295A, + 0xF096C, + 0xF0B6A, + 0x31B54, # 2041-2050 + 0xF1D92, + 0x83D24, + 0xF1D24, + 0xF1A4C, + 0x614AC, + 0xF14AE, + 0xF09AC, + 0x40DAA, + 0xF0EAA, + 0xF0E92, # 2051-2060 + 0x31D26, + 0xF0D26, + 0x72A56, + 0xF0A56, + 0xF14B6, + 0x52AB4, + 0xF0AD4, + 0xF16CA, + 0x42E94, + 0xF1694, # 2061-2070 + 0x8352A, + 0xF152A, + 0xF0A5A, + 0x6155A, + 0xF156A, + 0xF0B54, + 0x4174A, + 0xF1B4A, + 0xF1A94, + 0x3392A, # 2071-2080 + 0xF192C, + 0x7329C, + 0xF0AAC, + 0xF156A, + 0x52B64, + 0xF0DA4, + 0xF1D4A, + 0x41C94, + 0xF0C96, + 0x8192E, # 2081-2090 + 0xF0956, + 0xF0AB6, + 0x615AC, + 0xF16D4, + 0xF0EA4, + 0x42E4A, + 0xF164A, + 0xF1516, + 0x22936, # 2090-2099 ] # Define range of years START_YEAR, END_YEAR = 1901, 1900 + len(g_lunar_month_days) @@ -256,12 +478,10 @@ def storeholiday(self, hol_date, hol_name): LUNAR_END_DATE, SOLAR_END_DATE = (2099, 12, 30), date(2100, 2, 18) def get_leap_month(self, lunar_year): - return (self.g_lunar_month_days[lunar_year - self.START_YEAR] >> 16) \ - & 0x0F + return (self.g_lunar_month_days[lunar_year - self.START_YEAR] >> 16) & 0x0F def lunar_month_days(self, lunar_year, lunar_month): - return 29 + ((self.g_lunar_month_days[lunar_year - self.START_YEAR] >> - lunar_month) & 0x01) + return 29 + ((self.g_lunar_month_days[lunar_year - self.START_YEAR] >> lunar_month) & 0x01) def lunar_year_days(self, year): days = 0 @@ -291,7 +511,7 @@ def get_vesak_date(self, year): for m in range(1, 4 + (4 > leap_month)): span_days += self.lunar_month_days(year, m) span_days += 14 - return (self.SOLAR_START_DATE + timedelta(span_days)) + return self.SOLAR_START_DATE + timedelta(span_days) # Estimate Gregorian date of Southern India Diwali def get_s_diwali_date(self, year): @@ -302,7 +522,7 @@ def get_s_diwali_date(self, year): for m in range(1, 10 + (10 > leap_month)): span_days += self.lunar_month_days(year, m) span_days -= 2 - return (self.SOLAR_START_DATE + timedelta(span_days)) + return self.SOLAR_START_DATE + timedelta(span_days) # Estimate Gregorian date(s) of Hara Rasa Puasa def get_hrp_date(self, year): diff --git a/holidays/countries/slovakia.py b/holidays/countries/slovakia.py index be4e6ad42..6f1743c79 100644 --- a/holidays/countries/slovakia.py +++ b/holidays/countries/slovakia.py @@ -17,8 +17,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, MAY, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAY, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -27,14 +26,14 @@ class Slovakia(HolidayBase): # https://www.slov-lex.sk/pravne-predpisy/SK/ZZ/1993/241/20181011.html def __init__(self, **kwargs): - self.country = 'SK' + self.country = "SK" HolidayBase.__init__(self, **kwargs) def _populate(self, year): self[date(year, JAN, 1)] = "Deň vzniku Slovenskej republiky" - self[date(year, JAN, 6)] = "Zjavenie Pána (Traja králi a" \ - " vianočnýsviatok pravoslávnych" \ - " kresťanov)" + self[date(year, JAN, 6)] = ( + "Zjavenie Pána (Traja králi a" " vianočnýsviatok pravoslávnych" " kresťanov)" + ) e = easter(year) self[e - rd(days=2)] = "Veľký piatok" @@ -47,15 +46,13 @@ def _populate(self, year): self[date(year, JUL, 5)] = "Sviatok svätého Cyrila a svätého Metoda" - self[date(year, AUG, 29)] = "Výročie Slovenského národného" \ - " povstania" + self[date(year, AUG, 29)] = "Výročie Slovenského národného" " povstania" self[date(year, SEP, 1)] = "Deň Ústavy Slovenskej republiky" self[date(year, SEP, 15)] = "Sedembolestná Panna Mária" if year == 2018: - self[date(year, OCT, 30)] = "100. výročie prijatia" \ - " Deklarácie slovenského národa" + self[date(year, OCT, 30)] = "100. výročie prijatia" " Deklarácie slovenského národa" self[date(year, NOV, 1)] = "Sviatok Všetkých svätých" if year >= 2001: @@ -78,6 +75,5 @@ class SVK(Slovakia): class Slovak(Slovakia): def __init__(self, **kwargs): - warnings.warn("Slovak is deprecated, use Slovakia instead.", - DeprecationWarning) + warnings.warn("Slovak is deprecated, use Slovakia instead.", DeprecationWarning) super(Slovak, self).__init__(**kwargs) diff --git a/holidays/countries/slovenia.py b/holidays/countries/slovenia.py index 3282a1218..3c41a3927 100644 --- a/holidays/countries/slovenia.py +++ b/holidays/countries/slovenia.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, FEB, APR, MAY, JUN, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, APR, MAY, JUN, AUG, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -33,7 +32,7 @@ class Slovenia(HolidayBase): """ def __init__(self, **kwargs): - self.country = 'SI' + self.country = "SI" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/south_africa.py b/holidays/countries/south_africa.py index af0fb37bf..8d751821d 100644 --- a/holidays/countries/south_africa.py +++ b/holidays/countries/south_africa.py @@ -17,8 +17,7 @@ from dateutil.relativedelta import relativedelta as rd from holidays.constants import FRI, SUN -from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, \ - DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, DEC from holidays.holiday_base import HolidayBase diff --git a/holidays/countries/spain.py b/holidays/countries/spain.py index a28448ea2..419bfcdbf 100644 --- a/holidays/countries/spain.py +++ b/holidays/countries/spain.py @@ -15,50 +15,70 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, TH, FR, MO -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP,\ - OCT, NOV, DEC +from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase class Spain(HolidayBase): - PROVINCES = ['AN', 'AR', 'AS', 'CB', 'CM', 'CL', 'CT', 'VC', - 'EX', 'GA', 'IB', 'CN', 'MD', 'MC', 'ML', 'NC', 'PV', 'RI'] + PROVINCES = [ + "AN", + "AR", + "AS", + "CB", + "CM", + "CL", + "CT", + "VC", + "EX", + "GA", + "IB", + "CN", + "MD", + "MC", + "ML", + "NC", + "PV", + "RI", + ] def __init__(self, **kwargs): - self.country = 'ES' - self.prov = kwargs.pop('prov', kwargs.pop('state', '')) + self.country = "ES" + self.prov = kwargs.pop("prov", kwargs.pop("state", "")) HolidayBase.__init__(self, **kwargs) def _populate(self, year): self[date(year, JAN, 1)] = "Año nuevo" self[date(year, JAN, 6)] = "Epifanía del Señor" - if year < 2015 and self.prov and self.prov in \ - ['AR', 'CL', 'CM', 'EX', 'GA', 'MD', 'ML', 'MC', 'NC', - 'PV', 'VC']: + if ( + year < 2015 + and self.prov + and self.prov in ["AR", "CL", "CM", "EX", "GA", "MD", "ML", "MC", "NC", "PV", "VC"] + ): self[date(year, MAR, 19)] = "San José" - elif year == 2015 and self.prov and self.prov in \ - ['CM', 'MD', 'ML', 'MC', 'NC', 'PV', 'VC']: + elif ( + year == 2015 and self.prov and self.prov in ["CM", "MD", "ML", "MC", "NC", "PV", "VC"] + ): self[date(year, MAR, 19)] = "San José" - elif year == 2016 and self.prov and self.prov in \ - ['ML', 'MC', 'PV', 'VC']: + elif year == 2016 and self.prov and self.prov in ["ML", "MC", "PV", "VC"]: self[date(year, MAR, 19)] = "San José" - elif year == 2017 and self.prov and self.prov in ['PV']: + elif year == 2017 and self.prov and self.prov in ["PV"]: self[date(year, MAR, 19)] = "San José" - elif 2018 <= year <= 2019 and self.prov and self.prov in \ - ['GA', 'MC', 'NC', 'PV', 'VC']: + elif 2018 <= year <= 2019 and self.prov and self.prov in ["GA", "MC", "NC", "PV", "VC"]: self[date(year, MAR, 19)] = "San José" - elif 2020 <= year <= 2025 and self.prov and self.prov in \ - ['CM', 'GA', 'MC', 'NC', 'PV', 'VC']: + elif ( + 2020 <= year <= 2025 + and self.prov + and self.prov in ["CM", "GA", "MC", "NC", "PV", "VC"] + ): self[date(year, MAR, 19)] = "San José" - if self.prov and self.prov not in ['CT', 'VC']: + if self.prov and self.prov not in ["CT", "VC"]: self[easter(year) + rd(weeks=-1, weekday=TH)] = "Jueves Santo" self[easter(year) + rd(weeks=-1, weekday=FR)] = "Viernes Santo" - if self.prov and self.prov in \ - ['CT', 'PV', 'NC', 'VC', 'IB', 'CM']: + if self.prov and self.prov in ["CT", "PV", "NC", "VC", "IB", "CM"]: self[easter(year) + rd(weekday=MO)] = "Lunes de Pascua" self[date(year, MAY, 1)] = "Día del Trabajador" - if self.prov and self.prov in ['CT', 'GA', 'VC']: + if self.prov and self.prov in ["CT", "GA", "VC"]: self[date(year, JUN, 24)] = "San Juan" self[date(year, AUG, 15)] = "Asunción de la Virgen" self[date(year, OCT, 12)] = "Día de la Hispanidad" @@ -66,43 +86,43 @@ def _populate(self, year): self[date(year, DEC, 6)] = "Día de la constitución Española" self[date(year, DEC, 8)] = "La Inmaculada Concepción" self[date(year, DEC, 25)] = "Navidad" - if self.prov and self.prov in ['CT', 'IB']: + if self.prov and self.prov in ["CT", "IB"]: self[date(year, DEC, 26)] = "San Esteban" # Provinces festive day if self.prov: - if self.prov == 'AN': + if self.prov == "AN": self[date(year, FEB, 28)] = "Día de Andalucia" - elif self.prov == 'AR': + elif self.prov == "AR": self[date(year, APR, 23)] = "Día de San Jorge" - elif self.prov == 'AS': + elif self.prov == "AS": self[date(year, SEP, 8)] = "Día de Asturias" - elif self.prov == 'CB': + elif self.prov == "CB": self[date(year, FEB, 28)] = "Día de la Montaña" - elif self.prov == 'CM': + elif self.prov == "CM": self[date(year, FEB, 28)] = "Día de Castilla - La Mancha" - elif self.prov == 'CL': + elif self.prov == "CL": self[date(year, APR, 23)] = "Día de Castilla y Leon" - elif self.prov == 'CT': + elif self.prov == "CT": self[date(year, SEP, 11)] = "Día Nacional de Catalunya" - elif self.prov == 'VC': + elif self.prov == "VC": self[date(year, OCT, 9)] = "Día de la Comunidad Valenciana" - elif self.prov == 'EX': + elif self.prov == "EX": self[date(year, SEP, 8)] = "Día de Extremadura" - elif self.prov == 'GA': + elif self.prov == "GA": self[date(year, JUL, 25)] = "Día Nacional de Galicia" - elif self.prov == 'IB': + elif self.prov == "IB": self[date(year, MAR, 1)] = "Día de las Islas Baleares" - elif self.prov == 'CN': + elif self.prov == "CN": self[date(year, MAY, 30)] = "Día de Canarias" - elif self.prov == 'MD': + elif self.prov == "MD": self[date(year, MAY, 2)] = "Día de Comunidad De Madrid" - elif self.prov == 'MC': + elif self.prov == "MC": self[date(year, JUN, 9)] = "Día de la Región de Murcia" - elif self.prov == 'NC': + elif self.prov == "NC": self[date(year, SEP, 27)] = "Día de Navarra" - elif self.prov == 'PV': + elif self.prov == "PV": self[date(year, OCT, 25)] = "Día del Páis Vasco" - elif self.prov == 'RI': + elif self.prov == "RI": self[date(year, JUN, 9)] = "Día de La Rioja" diff --git a/holidays/countries/sweden.py b/holidays/countries/sweden.py index 0411be7df..ea41f179a 100644 --- a/holidays/countries/sweden.py +++ b/holidays/countries/sweden.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, FR, SA -from holidays.constants import JAN, MAR, MAY, JUN, OCT, \ - DEC +from holidays.constants import JAN, MAR, MAY, JUN, OCT, DEC from holidays.constants import MON, THU, FRI, SAT, SUN from holidays.holiday_base import HolidayBase @@ -50,9 +49,7 @@ def _populate(self, year): # Add all the sundays of the year before adding the "real" holidays if self.include_sundays: first_day_of_year = date(year, JAN, 1) - first_sunday_of_year = \ - first_day_of_year + \ - rd(days=SUN - first_day_of_year.weekday()) + first_sunday_of_year = first_day_of_year + rd(days=SUN - first_day_of_year.weekday()) cur_date = first_sunday_of_year while cur_date < date(year + 1, 1, 1): diff --git a/holidays/countries/switzerland.py b/holidays/countries/switzerland.py index 39aa972cd..0efff53d5 100644 --- a/holidays/countries/switzerland.py +++ b/holidays/countries/switzerland.py @@ -21,105 +21,160 @@ class Switzerland(HolidayBase): - PROVINCES = ['AG', 'AR', 'AI', 'BL', 'BS', 'BE', 'FR', 'GE', 'GL', - 'GR', 'JU', 'LU', 'NE', 'NW', 'OW', 'SG', 'SH', 'SZ', - 'SO', 'TG', 'TI', 'UR', 'VD', 'VS', 'ZG', 'ZH'] + PROVINCES = [ + "AG", + "AR", + "AI", + "BL", + "BS", + "BE", + "FR", + "GE", + "GL", + "GR", + "JU", + "LU", + "NE", + "NW", + "OW", + "SG", + "SH", + "SZ", + "SO", + "TG", + "TI", + "UR", + "VD", + "VS", + "ZG", + "ZH", + ] def __init__(self, **kwargs): - self.country = 'CH' + self.country = "CH" HolidayBase.__init__(self, **kwargs) def _populate(self, year): # public holidays - self[date(year, JAN, 1)] = 'Neujahrestag' - - if self.prov in ('AG', 'BE', 'FR', 'GL', 'GR', 'JU', 'LU', - 'NE', 'OW', 'SH', 'SO', 'TG', 'VD', 'ZG', 'ZH'): - self[date(year, JAN, 2)] = 'Berchtoldstag' - - if self.prov in ('SZ', 'TI', 'UR'): - self[date(year, JAN, 6)] = 'Heilige Drei Könige' - - if self.prov == 'NE': - self[date(year, MAR, 1)] = 'Jahrestag der Ausrufung der Republik' - - if self.prov in ('NW', 'SZ', 'TI', 'UR', 'VS'): - self[date(year, MAR, 19)] = 'Josefstag' + self[date(year, JAN, 1)] = "Neujahrestag" + + if self.prov in ( + "AG", + "BE", + "FR", + "GL", + "GR", + "JU", + "LU", + "NE", + "OW", + "SH", + "SO", + "TG", + "VD", + "ZG", + "ZH", + ): + self[date(year, JAN, 2)] = "Berchtoldstag" + + if self.prov in ("SZ", "TI", "UR"): + self[date(year, JAN, 6)] = "Heilige Drei Könige" + + if self.prov == "NE": + self[date(year, MAR, 1)] = "Jahrestag der Ausrufung der Republik" + + if self.prov in ("NW", "SZ", "TI", "UR", "VS"): + self[date(year, MAR, 19)] = "Josefstag" # Näfelser Fahrt (first Thursday in April but not in Holy Week) - if self.prov == 'GL' and year >= 1835: - if ((date(year, APR, 1) + rd(weekday=FR)) != - (easter(year) - rd(days=2))): - self[date(year, APR, 1) + rd(weekday=TH)] = 'Näfelser Fahrt' + if self.prov == "GL" and year >= 1835: + if (date(year, APR, 1) + rd(weekday=FR)) != (easter(year) - rd(days=2)): + self[date(year, APR, 1) + rd(weekday=TH)] = "Näfelser Fahrt" else: - self[date(year, APR, 8) + rd(weekday=TH)] = 'Näfelser Fahrt' + self[date(year, APR, 8) + rd(weekday=TH)] = "Näfelser Fahrt" # it's a Holiday on a Sunday - self[easter(year)] = 'Ostern' + self[easter(year)] = "Ostern" # VS don't have easter - if self.prov != 'VS': - self[easter(year) - rd(days=2)] = 'Karfreitag' - self[easter(year) + rd(weekday=MO)] = 'Ostermontag' + if self.prov != "VS": + self[easter(year) - rd(days=2)] = "Karfreitag" + self[easter(year) + rd(weekday=MO)] = "Ostermontag" - if self.prov in ('BL', 'BS', 'JU', 'NE', 'SH', 'SO', 'TG', 'TI', - 'ZH'): - self[date(year, MAY, 1)] = 'Tag der Arbeit' + if self.prov in ("BL", "BS", "JU", "NE", "SH", "SO", "TG", "TI", "ZH"): + self[date(year, MAY, 1)] = "Tag der Arbeit" - self[easter(year) + rd(days=39)] = 'Auffahrt' + self[easter(year) + rd(days=39)] = "Auffahrt" # it's a Holiday on a Sunday - self[easter(year) + rd(days=49)] = 'Pfingsten' + self[easter(year) + rd(days=49)] = "Pfingsten" - self[easter(year) + rd(days=50)] = 'Pfingstmontag' + self[easter(year) + rd(days=50)] = "Pfingstmontag" - if self.prov in ('AI', 'JU', 'LU', 'NW', 'OW', 'SZ', 'TI', 'UR', - 'VS', 'ZG'): - self[easter(year) + rd(days=60)] = 'Fronleichnam' + if self.prov in ("AI", "JU", "LU", "NW", "OW", "SZ", "TI", "UR", "VS", "ZG"): + self[easter(year) + rd(days=60)] = "Fronleichnam" - if self.prov == 'JU': - self[date(year, JUN, 23)] = 'Fest der Unabhängigkeit' + if self.prov == "JU": + self[date(year, JUN, 23)] = "Fest der Unabhängigkeit" - if self.prov == 'TI': - self[date(year, JUN, 29)] = 'Peter und Paul' + if self.prov == "TI": + self[date(year, JUN, 29)] = "Peter und Paul" if year >= 1291: - self[date(year, AUG, 1)] = 'Nationalfeiertag' + self[date(year, AUG, 1)] = "Nationalfeiertag" - if self.prov in ('AI', 'JU', 'LU', 'NW', 'OW', 'SZ', 'TI', 'UR', - 'VS', 'ZG'): - self[date(year, AUG, 15)] = 'Mariä Himmelfahrt' + if self.prov in ("AI", "JU", "LU", "NW", "OW", "SZ", "TI", "UR", "VS", "ZG"): + self[date(year, AUG, 15)] = "Mariä Himmelfahrt" - if self.prov == 'VD': + if self.prov == "VD": # Monday after the third Sunday of September dt = date(year, SEP, 1) + rd(weekday=SU(+3)) + rd(weekday=MO) - self[dt] = 'Lundi du Jeûne' + self[dt] = "Lundi du Jeûne" - if self.prov == 'GE': + if self.prov == "GE": # Thursday after the first Sunday of September dt = date(year, SEP, 1) + rd(weekday=SU) + rd(weekday=TH) - self[dt] = 'Jeûne genevois' - - if self.prov == 'OW': - self[date(year, SEP, 25)] = 'Bruder Klaus' - - if self.prov in ('AI', 'GL', 'JU', 'LU', 'NW', 'OW', 'SG', 'SZ', - 'TI', 'UR', 'VS', 'ZG'): - self[date(year, NOV, 1)] = 'Allerheiligen' - - if self.prov in ('AI', 'LU', 'NW', 'OW', 'SZ', 'TI', 'UR', 'VS', - 'ZG'): - self[date(year, DEC, 8)] = 'Mariä Empfängnis' - - self[date(year, DEC, 25)] = 'Weihnachten' - - if self.prov in ('AG', 'AR', 'AI', 'BL', 'BS', 'BE', 'FR', 'GL', - 'GR', 'LU', 'NE', 'NW', 'OW', 'SG', 'SH', 'SZ', - 'SO', 'TG', 'TI', 'UR', 'ZG', 'ZH'): - self[date(year, DEC, 26)] = 'Stephanstag' - - if self.prov == 'GE': - self[date(year, DEC, 31)] = 'Wiederherstellung der Republik' + self[dt] = "Jeûne genevois" + + if self.prov == "OW": + self[date(year, SEP, 25)] = "Bruder Klaus" + + if self.prov in ("AI", "GL", "JU", "LU", "NW", "OW", "SG", "SZ", "TI", "UR", "VS", "ZG"): + self[date(year, NOV, 1)] = "Allerheiligen" + + if self.prov in ("AI", "LU", "NW", "OW", "SZ", "TI", "UR", "VS", "ZG"): + self[date(year, DEC, 8)] = "Mariä Empfängnis" + + self[date(year, DEC, 25)] = "Weihnachten" + + if self.prov in ( + "AG", + "AR", + "AI", + "BL", + "BS", + "BE", + "FR", + "GL", + "GR", + "LU", + "NE", + "NW", + "OW", + "SG", + "SH", + "SZ", + "SO", + "TG", + "TI", + "UR", + "ZG", + "ZH", + ): + self[date(year, DEC, 26)] = "Stephanstag" + + if self.prov == "GE": + self[date(year, DEC, 31)] = "Wiederherstellung der Republik" class CH(Switzerland): diff --git a/holidays/countries/turkey.py b/holidays/countries/turkey.py index 621fec921..d6d9f5d70 100644 --- a/holidays/countries/turkey.py +++ b/holidays/countries/turkey.py @@ -23,7 +23,7 @@ class Turkey(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Turkey def __init__(self, **kwargs): - self.country = 'TR' + self.country = "TR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -38,8 +38,7 @@ def _populate(self, year): self[date(year, MAY, 1)] = "Labour Day" # 19th of May - self[date(year, MAY, 19)] = "Commemoration of Ataturk, Youth and "\ - "Sports Day" + self[date(year, MAY, 19)] = "Commemoration of Ataturk, Youth and " "Sports Day" # 15th of Jul # Became a national holiday after 15 Jul 2016 coup d'etat attempt. diff --git a/holidays/countries/ukraine.py b/holidays/countries/ukraine.py index 47a3b24f2..d1c904fc2 100644 --- a/holidays/countries/ukraine.py +++ b/holidays/countries/ukraine.py @@ -16,8 +16,7 @@ from dateutil.easter import easter, EASTER_ORTHODOX from dateutil.relativedelta import relativedelta as rd -from holidays.constants import JAN, MAR, MAY, JUN, JUL, AUG, SEP, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.holiday_base import HolidayBase @@ -42,8 +41,7 @@ def _populate(self, year): # Christmas Day (Orthodox) if year >= 1991: - self[date(year, JAN, 7)] = "Різдво Христове" \ - " (православне)" + self[date(year, JAN, 7)] = "Різдво Христове" " (православне)" # Women's Day if year > 1965: @@ -51,8 +49,7 @@ def _populate(self, year): # Easter if year >= 1991: - self[easter(year, method=EASTER_ORTHODOX)] = "Пасха" \ - " (Великдень)" + self[easter(year, method=EASTER_ORTHODOX)] = "Пасха" " (Великдень)" # Holy trinity if year >= 1991: @@ -102,8 +99,7 @@ def _populate(self, year): # October Revolution if 1917 < year < 2000: if year <= 1991: - name = "Річниця Великої Жовтневої" \ - " соціалістичної революції" + name = "Річниця Великої Жовтневої" " соціалістичної революції" else: name = "Річниця жовтневого перевороту" self[date(year, NOV, 7)] = name @@ -111,8 +107,7 @@ def _populate(self, year): # Christmas Day (Catholic) if year >= 2017: - self[date(year, DEC, 25)] = "Різдво Христове" \ - " (католицьке)" + self[date(year, DEC, 25)] = "Різдво Христове" " (католицьке)" # USSR holidays # Bloody_Sunday_(1905) if 1917 <= year < 1951: diff --git a/holidays/countries/united_kingdom.py b/holidays/countries/united_kingdom.py index 4054b559d..7e2319120 100644 --- a/holidays/countries/united_kingdom.py +++ b/holidays/countries/united_kingdom.py @@ -16,8 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, FR -from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, OCT, \ - NOV, DEC +from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, OCT, NOV, DEC from holidays.constants import MON, TUE, WED, THU, FRI, SAT, SUN, WEEKEND from holidays.holiday_base import HolidayBase @@ -26,7 +25,7 @@ class UnitedKingdom(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_the_United_Kingdom def __init__(self, **kwargs): - self.country = 'UK' + self.country = "UK" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -36,51 +35,45 @@ def _populate(self, year): name = "New Year's Day" self[date(year, JAN, 1)] = name if self.observed and date(year, JAN, 1).weekday() == SUN: - self[date(year, JAN, 1) + rd(days=+1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, JAN, 1).weekday() == SAT: - self[date(year, JAN, 1) + rd(days=+2)] = name + \ - " (Observed)" + self[date(year, JAN, 1) + rd(days=+1)] = name + " (Observed)" + elif self.observed and date(year, JAN, 1).weekday() == SAT: + self[date(year, JAN, 1) + rd(days=+2)] = name + " (Observed)" # New Year Holiday - if self.country in ('UK', 'Scotland'): + if self.country in ("UK", "Scotland"): name = "New Year Holiday" - if self.country == 'UK': + if self.country == "UK": name += " [Scotland]" self[date(year, JAN, 2)] = name if self.observed and date(year, JAN, 2).weekday() in WEEKEND: - self[date(year, JAN, 2) + rd(days=+2)] = name + \ - " (Observed)" + self[date(year, JAN, 2) + rd(days=+2)] = name + " (Observed)" elif self.observed and date(year, JAN, 2).weekday() == MON: - self[date(year, JAN, 2) + rd(days=+1)] = name + \ - " (Observed)" + self[date(year, JAN, 2) + rd(days=+1)] = name + " (Observed)" # St. Patrick's Day - if self.country in ('UK', 'Northern Ireland', 'Ireland'): + if self.country in ("UK", "Northern Ireland", "Ireland"): name = "St. Patrick's Day" - if self.country == 'UK': + if self.country == "UK": name += " [Northern Ireland]" self[date(year, MAR, 17)] = name if self.observed and date(year, MAR, 17).weekday() in WEEKEND: - self[date(year, MAR, 17) + rd(weekday=MO)] = name + \ - " (Observed)" + self[date(year, MAR, 17) + rd(weekday=MO)] = name + " (Observed)" # Good Friday - if self.country != 'Ireland': + if self.country != "Ireland": self[easter(year) + rd(weekday=FR(-1))] = "Good Friday" # Easter Monday - if self.country != 'Scotland': + if self.country != "Scotland": name = "Easter Monday" - if self.country == 'UK': + if self.country == "UK": name += " [England, Wales, Northern Ireland]" self[easter(year) + rd(weekday=MO)] = name # May Day bank holiday (first Monday in May) if year >= 1978: name = "May Day" - if year == 2020 and self.country != 'Ireland': + if year == 2020 and self.country != "Ireland": # Moved to Friday to mark 75th anniversary of VE Day. self[date(year, MAY, 8)] = name else: @@ -104,7 +97,7 @@ def _populate(self, year): self[dt + rd(days=+1)] = name # Spring bank holiday (last Monday in May) - if self.country != 'Ireland': + if self.country != "Ireland": name = "Spring Bank Holiday" if year == 2012: self[date(year, JUN, 4)] = name @@ -112,47 +105,47 @@ def _populate(self, year): self[date(year, MAY, 31) + rd(weekday=MO(-1))] = name # June bank holiday (first Monday in June) - if self.country == 'Ireland': + if self.country == "Ireland": self[date(year, JUN, 1) + rd(weekday=MO)] = "June Bank Holiday" # TT bank holiday (first Friday in June) - if self.country == 'Isle of Man': + if self.country == "Isle of Man": self[date(year, JUN, 1) + rd(weekday=FR)] = "TT Bank Holiday" # Tynwald Day - if self.country == 'Isle of Man': + if self.country == "Isle of Man": self[date(year, JUL, 5)] = "Tynwald Day" # Battle of the Boyne - if self.country in ('UK', 'Northern Ireland'): + if self.country in ("UK", "Northern Ireland"): name = "Battle of the Boyne" - if self.country == 'UK': + if self.country == "UK": name += " [Northern Ireland]" self[date(year, JUL, 12)] = name # Summer bank holiday (first Monday in August) - if self.country in ('UK', 'Scotland', 'Ireland'): + if self.country in ("UK", "Scotland", "Ireland"): name = "Summer Bank Holiday" - if self.country == 'UK': + if self.country == "UK": name += " [Scotland]" self[date(year, AUG, 1) + rd(weekday=MO)] = name # Late Summer bank holiday (last Monday in August) - if self.country not in ('Scotland', 'Ireland') and year >= 1971: + if self.country not in ("Scotland", "Ireland") and year >= 1971: name = "Late Summer Bank Holiday" - if self.country == 'UK': + if self.country == "UK": name += " [England, Wales, Northern Ireland]" self[date(year, AUG, 31) + rd(weekday=MO(-1))] = name # October Bank Holiday (last Monday in October) - if self.country == 'Ireland': + if self.country == "Ireland": name = "October Bank Holiday" self[date(year, OCT, 31) + rd(weekday=MO(-1))] = name # St. Andrew's Day - if self.country in ('UK', 'Scotland'): + if self.country in ("UK", "Scotland"): name = "St. Andrew's Day" - if self.country == 'UK': + if self.country == "UK": name += " [Scotland]" self[date(year, NOV, 30)] = name @@ -173,7 +166,7 @@ def _populate(self, year): self[date(year, DEC, 28)] = name + " (Observed)" # Special holidays - if self.country != 'Ireland': + if self.country != "Ireland": if year == 1977: self[date(year, JUN, 7)] = "Silver Jubilee of Elizabeth II" elif year == 1981: @@ -183,8 +176,7 @@ def _populate(self, year): elif year == 2002: self[date(year, JUN, 3)] = "Golden Jubilee of Elizabeth II" elif year == 2011: - self[date(year, APR, 29)] = "Wedding of William and" \ - " Catherine" + self[date(year, APR, 29)] = "Wedding of William and" " Catherine" elif year == 2012: self[date(year, JUN, 5)] = "Diamond Jubilee of Elizabeth II" @@ -202,35 +194,30 @@ class GBR(UnitedKingdom): class England(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'England' + self.country = "England" HolidayBase.__init__(self, **kwargs) class Wales(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Wales' + self.country = "Wales" HolidayBase.__init__(self, **kwargs) class Scotland(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Scotland' + self.country = "Scotland" HolidayBase.__init__(self, **kwargs) class IsleOfMan(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Isle of Man' + self.country = "Isle of Man" HolidayBase.__init__(self, **kwargs) class NorthernIreland(UnitedKingdom): - def __init__(self, **kwargs): - self.country = 'Northern Ireland' + self.country = "Northern Ireland" HolidayBase.__init__(self, **kwargs) diff --git a/holidays/countries/united_states.py b/holidays/countries/united_states.py index 595005e57..760d6d6d9 100644 --- a/holidays/countries/united_states.py +++ b/holidays/countries/united_states.py @@ -16,9 +16,7 @@ from dateutil.easter import easter from dateutil.relativedelta import relativedelta as rd, MO, FR, TH, TU -from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, \ - OCT, \ - NOV, DEC +from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC from holidays.constants import MON, WED, FRI, SAT, SUN, WEEKEND from holidays.holiday_base import HolidayBase @@ -26,15 +24,70 @@ class UnitedStates(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_the_United_States - STATES = ['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', - 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', - 'MD', 'MH', 'MA', 'MI', 'FM', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', - 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', - 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'VI', - 'WA', 'WV', 'WI', 'WY'] + STATES = [ + "AL", + "AK", + "AS", + "AZ", + "AR", + "CA", + "CO", + "CT", + "DE", + "DC", + "FL", + "GA", + "GU", + "HI", + "ID", + "IL", + "IN", + "IA", + "KS", + "KY", + "LA", + "ME", + "MD", + "MH", + "MA", + "MI", + "FM", + "MN", + "MS", + "MO", + "MT", + "NE", + "NV", + "NH", + "NJ", + "NM", + "NY", + "NC", + "ND", + "MP", + "OH", + "OK", + "OR", + "PW", + "PA", + "PR", + "RI", + "SC", + "SD", + "TN", + "TX", + "UT", + "VT", + "VA", + "VI", + "WA", + "WV", + "WI", + "WY", + ] def __init__(self, **kwargs): - self.country = 'US' + self.country = "US" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -43,16 +96,13 @@ def _populate(self, year): name = "New Year's Day" self[date(year, JAN, 1)] = name if self.observed and date(year, JAN, 1).weekday() == SUN: - self[date(year, JAN, 1) + rd(days=+1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, JAN, 1).weekday() == SAT: + self[date(year, JAN, 1) + rd(days=+1)] = name + " (Observed)" + elif self.observed and date(year, JAN, 1).weekday() == SAT: # Add Dec 31st from the previous year without triggering # the entire year to be added expand = self.expand self.expand = False - self[date(year, JAN, 1) + rd(days=-1)] = name + \ - " (Observed)" + self[date(year, JAN, 1) + rd(days=-1)] = name + " (Observed)" self.expand = expand # The next year's observed New Year's Day can be in this year # when it falls on a Friday (Jan 1st is a Saturday) @@ -60,26 +110,25 @@ def _populate(self, year): self[date(year, DEC, 31)] = name + " (Observed)" # Epiphany - if self.state == 'PR': + if self.state == "PR": self[date(year, JAN, 6)] = "Epiphany" # Three King's Day - if self.state == 'VI': + if self.state == "VI": self[date(year, JAN, 6)] = "Three King's Day" # Lee Jackson Day name = "Lee Jackson Day" - if self.state == 'VA' and year >= 2000: - dt = date(year, JAN, 1) + rd(weekday=MO(+3)) + rd( - weekday=FR(-1)) + if self.state == "VA" and year >= 2000: + dt = date(year, JAN, 1) + rd(weekday=MO(+3)) + rd(weekday=FR(-1)) self[dt] = name - elif self.state == 'VA' and year >= 1983: + elif self.state == "VA" and year >= 1983: self[date(year, JAN, 1) + rd(weekday=MO(+3))] = name - elif self.state == 'VA' and year >= 1889: + elif self.state == "VA" and year >= 1889: self[date(year, JAN, 19)] = name # Inauguration Day - if self.state in ('DC', 'LA', 'MD', 'VA') and year >= 1789: + if self.state in ("DC", "LA", "MD", "VA") and year >= 1789: name = "Inauguration Day" if (year - 1789) % 4 == 0 and year >= 1937: self[date(year, JAN, 20)] = name @@ -93,15 +142,13 @@ def _populate(self, year): # Martin Luther King Jr. Day if year >= 1986: name = "Martin Luther King Jr. Day" - if self.state == 'AL': + if self.state == "AL": name = "Robert E. Lee/Martin Luther King Birthday" - elif (self.state == 'MS') or ((self.state == 'AR') and - (year <= 2017)): - name = ("Dr. Martin Luther King Jr. " - "and Robert E. Lee's Birthdays") - elif self.state in ('AZ', 'NH'): + elif (self.state == "MS") or ((self.state == "AR") and (year <= 2017)): + name = "Dr. Martin Luther King Jr. " "and Robert E. Lee's Birthdays" + elif self.state in ("AZ", "NH"): name = "Dr. Martin Luther King Jr./Civil Rights Day" - elif self.state == 'GA' and year < 2012: + elif self.state == "GA" and year < 2012: name = "Robert E. Lee's Birthday" elif self.state == 'ID' and year >= 2006: name = "Martin Luther King Jr. - Idaho Human Rights Day" @@ -109,80 +156,80 @@ def _populate(self, year): # Lincoln's Birthday name = "Lincoln's Birthday" - if (self.state in ('CT', 'IL', 'IA', 'NJ', 'NY') and year >= 1971) \ - or (self.state == 'CA' and 1971 <= year <= 2009): + if (self.state in ("CT", "IL", "IA", "NJ", "NY") and year >= 1971) or ( + self.state == "CA" and 1971 <= year <= 2009 + ): self[date(year, FEB, 12)] = name - if self.observed \ - and date(year, FEB, 12).weekday() == SAT: + if self.observed and date(year, FEB, 12).weekday() == SAT: self[date(year, FEB, 11)] = name + " (Observed)" - elif self.observed \ - and date(year, FEB, 12).weekday() == SUN: + elif self.observed and date(year, FEB, 12).weekday() == SUN: self[date(year, FEB, 13)] = name + " (Observed)" # Susan B. Anthony Day - if (self.state == 'CA' and year >= 2014) \ - or (self.state == 'FL' and year >= 2011) \ - or (self.state == 'NY' and year >= 2004) \ - or (self.state == 'WI' and year >= 1976): + if ( + (self.state == "CA" and year >= 2014) + or (self.state == "FL" and year >= 2011) + or (self.state == "NY" and year >= 2004) + or (self.state == "WI" and year >= 1976) + ): self[date(year, FEB, 15)] = "Susan B. Anthony Day" # Washington's Birthday name = "Washington's Birthday" - if self.state == 'AL': + if self.state == "AL": name = "George Washington/Thomas Jefferson Birthday" - elif self.state == 'AR': + elif self.state == "AR": name = "George Washington's Birthday and Daisy Gatson Bates Day" - elif self.state in ('PR', 'VI'): + elif self.state in ("PR", "VI"): name = "Presidents' Day" - if self.state not in ('DE', 'FL', 'GA', 'NM', 'PR'): + if self.state not in ("DE", "FL", "GA", "NM", "PR"): if year > 1970: self[date(year, FEB, 1) + rd(weekday=MO(+3))] = name elif year >= 1879: self[date(year, FEB, 22)] = name - elif self.state == 'GA': + elif self.state == "GA": if date(year, DEC, 24).weekday() != WED: self[date(year, DEC, 24)] = name else: self[date(year, DEC, 26)] = name - elif self.state in ('PR', 'VI'): + elif self.state in ("PR", "VI"): self[date(year, FEB, 1) + rd(weekday=MO(+3))] = name # Mardi Gras - if self.state == 'LA' and year >= 1857: + if self.state == "LA" and year >= 1857: self[easter(year) + rd(days=-47)] = "Mardi Gras" # Guam Discovery Day - if self.state == 'GU' and year >= 1970: + if self.state == "GU" and year >= 1970: self[date(year, MAR, 1) + rd(weekday=MO)] = "Guam Discovery Day" # Casimir Pulaski Day - if self.state == 'IL' and year >= 1978: + if self.state == "IL" and year >= 1978: self[date(year, MAR, 1) + rd(weekday=MO)] = "Casimir Pulaski Day" # Texas Independence Day - if self.state == 'TX' and year >= 1874: + if self.state == "TX" and year >= 1874: self[date(year, MAR, 2)] = "Texas Independence Day" # Town Meeting Day - if self.state == 'VT' and year >= 1800: + if self.state == "VT" and year >= 1800: self[date(year, MAR, 1) + rd(weekday=TU)] = "Town Meeting Day" # Evacuation Day - if self.state == 'MA' and year >= 1901: + if self.state == "MA" and year >= 1901: name = "Evacuation Day" self[date(year, MAR, 17)] = name if date(year, MAR, 17).weekday() in WEEKEND: - self[date(year, MAR, 17) + rd(weekday=MO)] = name + \ - " (Observed)" + self[date(year, MAR, 17) + rd(weekday=MO)] = name + " (Observed)" # Emancipation Day - if self.state == 'PR': + if self.state == "PR": self[date(year, MAR, 22)] = "Emancipation Day" if self.observed and date(year, MAR, 22).weekday() == SUN: self[date(year, MAR, 23)] = "Emancipation Day (Observed)" # Prince Jonah Kuhio Kalanianaole Day - if self.state == 'HI' and year >= 1949: + if self.state == "HI" and year >= 1949: name = "Prince Jonah Kuhio Kalanianaole Day" self[date(year, MAR, 26)] = name if self.observed and date(year, MAR, 26).weekday() == SAT: @@ -192,26 +239,26 @@ def _populate(self, year): # Steward's Day name = "Steward's Day" - if self.state == 'AK' and year >= 1955: + if self.state == "AK" and year >= 1955: self[date(year, APR, 1) + rd(days=-1, weekday=MO(-1))] = name - elif self.state == 'AK' and year >= 1918: + elif self.state == "AK" and year >= 1918: self[date(year, MAR, 30)] = name # César Chávez Day name = "César Chávez Day" - if self.state == 'CA' and year >= 1995: + if self.state == "CA" and year >= 1995: self[date(year, MAR, 31)] = name if self.observed and date(year, MAR, 31).weekday() == SUN: self[date(year, APR, 1)] = name + " (Observed)" - elif self.state == 'TX' and year >= 2000: + elif self.state == "TX" and year >= 2000: self[date(year, MAR, 31)] = name # Transfer Day - if self.state == 'VI': + if self.state == "VI": self[date(year, MAR, 31)] = "Transfer Day" # Emancipation Day - if self.state == 'DC' and year >= 2005: + if self.state == "DC" and year >= 2005: name = "Emancipation Day" self[date(year, APR, 16)] = name if self.observed and date(year, APR, 16).weekday() == SAT: @@ -220,54 +267,52 @@ def _populate(self, year): self[date(year, APR, 17)] = name + " (Observed)" # Patriots' Day - if self.state in ('ME', 'MA') and year >= 1969: + if self.state in ("ME", "MA") and year >= 1969: self[date(year, APR, 1) + rd(weekday=MO(+3))] = "Patriots' Day" - elif self.state in ('ME', 'MA') and year >= 1894: + elif self.state in ("ME", "MA") and year >= 1894: self[date(year, APR, 19)] = "Patriots' Day" # Holy Thursday - if self.state == 'VI': + if self.state == "VI": self[easter(year) + rd(weekday=TH(-1))] = "Holy Thursday" # Good Friday - if self.state in ('CT', 'DE', 'GU', 'IN', 'KY', 'LA', - 'NJ', 'NC', 'PR', 'TN', 'TX', 'VI'): + if self.state in ("CT", "DE", "GU", "IN", "KY", "LA", "NJ", "NC", "PR", "TN", "TX", "VI"): self[easter(year) + rd(weekday=FR(-1))] = "Good Friday" # Easter Monday - if self.state == 'VI': + if self.state == "VI": self[easter(year) + rd(weekday=MO)] = "Easter Monday" # Confederate Memorial Day name = "Confederate Memorial Day" - if self.state in ('AL', 'GA', 'MS', 'SC') and year >= 1866: - if self.state == 'GA' and year >= 2016: + if self.state in ("AL", "GA", "MS", "SC") and year >= 1866: + if self.state == "GA" and year >= 2016: name = "State Holiday" - if self.state == 'GA' and year == 2020: + if self.state == "GA" and year == 2020: self[date(year, APR, 10)] = name else: self[date(year, APR, 1) + rd(weekday=MO(+4))] = name - elif self.state == 'TX' and year >= 1931: + elif self.state == "TX" and year >= 1931: self[date(year, JAN, 19)] = name # San Jacinto Day - if self.state == 'TX' and year >= 1875: + if self.state == "TX" and year >= 1875: self[date(year, APR, 21)] = "San Jacinto Day" # Arbor Day - if self.state == 'NE' and year >= 1989: + if self.state == "NE" and year >= 1989: self[date(year, APR, 30) + rd(weekday=FR(-1))] = "Arbor Day" - elif self.state == 'NE' and year >= 1875: + elif self.state == "NE" and year >= 1875: self[date(year, APR, 22)] = "Arbor Day" # Primary Election Day - if self.state == 'IN' and \ - ((year >= 2006 and year % 2 == 0) or year >= 2015): + if self.state == "IN" and ((year >= 2006 and year % 2 == 0) or year >= 2015): dt = date(year, MAY, 1) + rd(weekday=MO) self[dt + rd(days=+1)] = "Primary Election Day" # Truman Day - if self.state == 'MO' and year >= 1949: + if self.state == "MO" and year >= 1949: name = "Truman Day" self[date(year, MAY, 8)] = name if self.observed and date(year, MAY, 8).weekday() == SAT: @@ -283,11 +328,11 @@ def _populate(self, year): # Jefferson Davis Birthday name = "Jefferson Davis Birthday" - if self.state == 'AL' and year >= 1890: + if self.state == "AL" and year >= 1890: self[date(year, JUN, 1) + rd(weekday=MO)] = name # Kamehameha Day - if self.state == 'HI' and year >= 1872: + if self.state == "HI" and year >= 1872: self[date(year, JUN, 11)] = "Kamehameha Day" if self.observed and year >= 2011: if date(year, JUN, 11).weekday() == SAT: @@ -296,12 +341,12 @@ def _populate(self, year): self[date(year, JUN, 12)] = "Kamehameha Day (Observed)" # Emancipation Day In Texas - if self.state == 'TX' and year >= 1980: + if self.state == "TX" and year >= 1980: self[date(year, JUN, 19)] = "Emancipation Day In Texas" # West Virginia Day name = "West Virginia Day" - if self.state == 'WV' and year >= 1927: + if self.state == "WV" and year >= 1927: self[date(year, JUN, 20)] = name if self.observed and date(year, JUN, 20).weekday() == SAT: self[date(year, JUN, 19)] = name + " (Observed)" @@ -309,7 +354,7 @@ def _populate(self, year): self[date(year, JUN, 21)] = name + " (Observed)" # Emancipation Day in US Virgin Islands - if self.state == 'VI': + if self.state == "VI": self[date(year, JUL, 3)] = "Emancipation Day" # Independence Day @@ -322,11 +367,11 @@ def _populate(self, year): self[date(year, JUL, 4) + rd(days=+1)] = name + " (Observed)" # Liberation Day (Guam) - if self.state == 'GU' and year >= 1945: + if self.state == "GU" and year >= 1945: self[date(year, JUL, 21)] = "Liberation Day (Guam)" # Pioneer Day - if self.state == 'UT' and year >= 1849: + if self.state == "UT" and year >= 1849: name = "Pioneer Day" self[date(year, JUL, 24)] = name if self.observed and date(year, JUL, 24).weekday() == SAT: @@ -335,21 +380,21 @@ def _populate(self, year): self[date(year, JUL, 24) + rd(days=+1)] = name + " (Observed)" # Constitution Day - if self.state == 'PR': + if self.state == "PR": self[date(year, JUL, 25)] = "Constitution Day" if self.observed and date(year, JUL, 25).weekday() == SUN: self[date(year, JUL, 26)] = "Constitution Day (Observed)" # Victory Day - if self.state == 'RI' and year >= 1948: + if self.state == "RI" and year >= 1948: self[date(year, AUG, 1) + rd(weekday=MO(+2))] = "Victory Day" # Statehood Day (Hawaii) - if self.state == 'HI' and year >= 1959: + if self.state == "HI" and year >= 1959: self[date(year, AUG, 1) + rd(weekday=FR(+3))] = "Statehood Day" # Bennington Battle Day - if self.state == 'VT' and year >= 1778: + if self.state == "VT" and year >= 1778: name = "Bennington Battle Day" self[date(year, AUG, 16)] = name if self.observed and date(year, AUG, 16).weekday() == SAT: @@ -358,7 +403,7 @@ def _populate(self, year): self[date(year, AUG, 17)] = name + " (Observed)" # Lyndon Baines Johnson Day - if self.state == 'TX' and year >= 1973: + if self.state == "TX" and year >= 1973: self[date(year, AUG, 27)] = "Lyndon Baines Johnson Day" # Labor Day @@ -366,10 +411,10 @@ def _populate(self, year): self[date(year, SEP, 1) + rd(weekday=MO)] = "Labor Day" # Columbus Day - if self.state not in ('AK', 'AR', 'DE', 'FL', 'HI', 'NV'): - if self.state == 'SD': + if self.state not in ("AK", "AR", "DE", "FL", "HI", "NV"): + if self.state == "SD": name = "Native American Day" - elif self.state == 'VI': + elif self.state == "VI": name = "Columbus Day and Puerto Rico Friendship Day" else: name = "Columbus Day" @@ -379,20 +424,16 @@ def _populate(self, year): self[date(year, OCT, 12)] = name # Alaska Day - if self.state == 'AK' and year >= 1867: + if self.state == "AK" and year >= 1867: name = "Alaska Day" self[date(year, OCT, 18)] = name - if self.observed \ - and date(year, OCT, 18).weekday() == SAT: - self[date(year, OCT, 18) + rd(days=-1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, OCT, 18).weekday() == SUN: - self[date(year, OCT, 18) + rd(days=+1)] = name + \ - " (Observed)" + if self.observed and date(year, OCT, 18).weekday() == SAT: + self[date(year, OCT, 18) + rd(days=-1)] = name + " (Observed)" + elif self.observed and date(year, OCT, 18).weekday() == SUN: + self[date(year, OCT, 18) + rd(days=+1)] = name + " (Observed)" # Nevada Day - if self.state == 'NV' and year >= 1933: + if self.state == "NV" and year >= 1933: dt = date(year, OCT, 31) if year >= 2000: dt += rd(weekday=FR(-1)) @@ -403,19 +444,20 @@ def _populate(self, year): self[dt + rd(days=+1)] = "Nevada Day (Observed)" # Liberty Day - if self.state == 'VI': + if self.state == "VI": self[date(year, NOV, 1)] = "Liberty Day" # Election Day - if (self.state in ('DE', 'HI', 'IL', 'IN', 'LA', - 'MT', 'NH', 'NJ', 'NY', 'WV') and - year >= 2008 and year % 2 == 0) \ - or (self.state in ('IN', 'NY') and year >= 2015): + if ( + self.state in ("DE", "HI", "IL", "IN", "LA", "MT", "NH", "NJ", "NY", "WV") + and year >= 2008 + and year % 2 == 0 + ) or (self.state in ("IN", "NY") and year >= 2015): dt = date(year, NOV, 1) + rd(weekday=MO) self[dt + rd(days=+1)] = "Election Day" # All Souls' Day - if self.state == 'GU': + if self.state == "GU": self[date(year, NOV, 2)] = "All Souls' Day" # Veterans Day @@ -427,17 +469,13 @@ def _populate(self, year): self[date(year, OCT, 1) + rd(weekday=MO(+4))] = name elif year >= 1938: self[date(year, NOV, 11)] = name - if self.observed \ - and date(year, NOV, 11).weekday() == SAT: - self[date(year, NOV, 11) + rd(days=-1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, NOV, 11).weekday() == SUN: - self[date(year, NOV, 11) + rd(days=+1)] = name + \ - " (Observed)" + if self.observed and date(year, NOV, 11).weekday() == SAT: + self[date(year, NOV, 11) + rd(days=-1)] = name + " (Observed)" + elif self.observed and date(year, NOV, 11).weekday() == SUN: + self[date(year, NOV, 11) + rd(days=+1)] = name + " (Observed)" # Discovery Day - if self.state == 'PR': + if self.state == "PR": self[date(year, NOV, 19)] = "Discovery Day" if self.observed and date(year, NOV, 19).weekday() == SUN: self[date(year, NOV, 20)] = "Discovery Day (Observed)" @@ -452,28 +490,29 @@ def _populate(self, year): # American Indian Heritage Day # Family Day # New Mexico Presidents' Day - if (self.state in ('DE', 'FL', 'NH', 'NC', 'OK', 'TX', 'WV') and - year >= 1975) \ - or (self.state == 'IN' and year >= 2010) \ - or (self.state == 'MD' and year >= 2008) \ - or self.state in ('NV', 'NM'): - if self.state in ('DE', 'NH', 'NC', 'OK', 'WV'): + if ( + (self.state in ("DE", "FL", "NH", "NC", "OK", "TX", "WV") and year >= 1975) + or (self.state == "IN" and year >= 2010) + or (self.state == "MD" and year >= 2008) + or self.state in ("NV", "NM") + ): + if self.state in ("DE", "NH", "NC", "OK", "WV"): name = "Day After Thanksgiving" - elif self.state in ('FL', 'TX'): + elif self.state in ("FL", "TX"): name = "Friday After Thanksgiving" - elif self.state == 'IN': + elif self.state == "IN": name = "Lincoln's Birthday" - elif self.state == 'MD' and year >= 2008: + elif self.state == "MD" and year >= 2008: name = "American Indian Heritage Day" - elif self.state == 'NV': + elif self.state == "NV": name = "Family Day" - elif self.state == 'NM': + elif self.state == "NM": name = "Presidents' Day" dt = date(year, NOV, 1) + rd(weekday=TH(+4)) self[dt + rd(days=+1)] = name # Robert E. Lee's Birthday - if self.state == 'GA' and year >= 1986: + if self.state == "GA" and year >= 1986: if year >= 2016: name = "State Holiday" else: @@ -481,14 +520,16 @@ def _populate(self, year): self[date(year, NOV, 29) + rd(weekday=FR(-1))] = name # Lady of Camarin Day - if self.state == 'GU': + if self.state == "GU": self[date(year, DEC, 8)] = "Lady of Camarin Day" # Christmas Eve - if self.state == 'AS' or \ - (self.state in ('KS', 'MI', 'NC') and year >= 2013) or \ - (self.state == 'TX' and year >= 1981) or \ - (self.state == 'WI' and year >= 2012): + if ( + self.state == "AS" + or (self.state in ("KS", "MI", "NC") and year >= 2013) + or (self.state == "TX" and year >= 1981) + or (self.state == "WI" and year >= 2012) + ): name = "Christmas Eve" self[date(year, DEC, 24)] = name name = name + " (Observed)" @@ -496,25 +537,20 @@ def _populate(self, year): if self.observed and date(year, DEC, 24).weekday() == FRI: self[date(year, DEC, 24) + rd(days=-1)] = name # If on Saturday or Sunday, observed on Friday - elif self.observed \ - and date(year, DEC, 24).weekday() in WEEKEND: + elif self.observed and date(year, DEC, 24).weekday() in WEEKEND: self[date(year, DEC, 24) + rd(weekday=FR(-1))] = name # Christmas Day if year > 1870: name = "Christmas Day" self[date(year, DEC, 25)] = "Christmas Day" - if self.observed \ - and date(year, DEC, 25).weekday() == SAT: - self[date(year, DEC, 25) + rd(days=-1)] = name + \ - " (Observed)" - elif self.observed \ - and date(year, DEC, 25).weekday() == SUN: - self[date(year, DEC, 25) + rd(days=+1)] = name + \ - " (Observed)" + if self.observed and date(year, DEC, 25).weekday() == SAT: + self[date(year, DEC, 25) + rd(days=-1)] = name + " (Observed)" + elif self.observed and date(year, DEC, 25).weekday() == SUN: + self[date(year, DEC, 25) + rd(days=+1)] = name + " (Observed)" # Day After Christmas - if self.state == 'NC' and year >= 2013: + if self.state == "NC" and year >= 2013: name = "Day After Christmas" self[date(year, DEC, 26)] = name name = name + " (Observed)" @@ -522,21 +558,18 @@ def _populate(self, year): if self.observed and date(year, DEC, 26).weekday() in WEEKEND: self[date(year, DEC, 26) + rd(weekday=MO)] = name # If on Monday, observed on Tuesday - elif self.observed \ - and date(year, DEC, 26).weekday() == MON: + elif self.observed and date(year, DEC, 26).weekday() == MON: self[date(year, DEC, 26) + rd(days=+1)] = name - elif self.state == 'TX' and year >= 1981: + elif self.state == "TX" and year >= 1981: self[date(year, DEC, 26)] = "Day After Christmas" - elif self.state == 'VI': + elif self.state == "VI": self[date(year, DEC, 26)] = "Christmas Second Day" # New Year's Eve - if (self.state in ('KY', 'MI') and year >= 2013) or \ - (self.state == 'WI' and year >= 2012): + if (self.state in ("KY", "MI") and year >= 2013) or (self.state == "WI" and year >= 2012): name = "New Year's Eve" self[date(year, DEC, 31)] = name - if self.observed \ - and date(year, DEC, 31).weekday() == SAT: + if self.observed and date(year, DEC, 31).weekday() == SAT: self[date(year, DEC, 30)] = name + " (Observed)" diff --git a/holidays/countries/vietnam.py b/holidays/countries/vietnam.py index ab6c86c9a..95aa266a6 100644 --- a/holidays/countries/vietnam.py +++ b/holidays/countries/vietnam.py @@ -49,13 +49,14 @@ def _populate(self, year): self[first_date + rd(days=+1)] = name + " observed" # Lunar New Year - name = ["Vietnamese New Year", # index: 0 - "The second day of Tet Holiday", # index: 1 - "The third day of Tet Holiday", # index: 2 - "The forth day of Tet Holiday", # index: 3 - "The fifth day of Tet Holiday", # index: 4 - "Vietnamese New Year's Eve", # index: -1 - ] + name = [ + "Vietnamese New Year", # index: 0 + "The second day of Tet Holiday", # index: 1 + "The third day of Tet Holiday", # index: 2 + "The forth day of Tet Holiday", # index: 3 + "The fifth day of Tet Holiday", # index: 4 + "Vietnamese New Year's Eve", # index: -1 + ] dt = self.get_solar_date(year, 1, 1) new_year_date = date(dt.year, dt.month, dt.day) if self.observed: @@ -91,8 +92,9 @@ def _populate(self, year): # convert lunar calendar date to solar def get_solar_date(self, year, month, day): self.korean_cal.setLunarDate(year, month, day, False) - return date(self.korean_cal.solarYear, self.korean_cal.solarMonth, - self.korean_cal.solarDay) + return date( + self.korean_cal.solarYear, self.korean_cal.solarMonth, self.korean_cal.solarDay + ) class VN(Vietnam): diff --git a/holidays/holiday_base.py b/holidays/holiday_base.py index 813d51802..0e6f88054 100644 --- a/holidays/holiday_base.py +++ b/holidays/holiday_base.py @@ -20,21 +20,22 @@ class HolidayBase(dict): PROVINCES = [] - def __init__(self, years=[], expand=True, observed=True, - prov=None, state=None): + def __init__(self, years=[], expand=True, observed=True, prov=None, state=None): self.observed = observed self.expand = expand if isinstance(years, int): - years = [years, ] + years = [ + years, + ] self.years = set(years) - if not getattr(self, 'prov', False): + if not getattr(self, "prov", False): self.prov = prov self.state = state for year in list(self.years): self._populate(year) def __setattr__(self, key, value): - if key == 'observed' and len(self) > 0: + if key == "observed" and len(self) > 0: dict.__setattr__(self, key, value) if value is True: # Add (Observed) dates @@ -89,12 +90,10 @@ def __getitem__(self, key): elif isinstance(key.step, int): step = key.step else: - raise TypeError( - "Cannot convert type '%s' to int." % type(key.step) - ) + raise TypeError("Cannot convert type '%s' to int." % type(key.step)) if step == 0: - raise ValueError('Step value must not be zero.') + raise ValueError("Step value must not be zero.") date_diff = stop - start if date_diff.days < 0 <= step or date_diff.days >= 0 > step: @@ -104,10 +103,7 @@ def __getitem__(self, key): for delta_days in range(0, date_diff.days, step): day = start + timedelta(days=delta_days) try: - dict.__getitem__( - self, - day - ) + dict.__getitem__(self, day) days_in_range.append(day) except KeyError: pass @@ -116,8 +112,7 @@ def __getitem__(self, key): def __setitem__(self, key, value): if key in self: - if self.get(key).find(value) < 0 \ - and value.find(self.get(key)) < 0: + if self.get(key).find(value) < 0 and value.find(self.get(key)) < 0: value = "%s, %s" % (value, self.get(key)) else: value = self.get(key) @@ -176,8 +171,7 @@ def __add__(self, other): elif not isinstance(other, HolidayBase): raise TypeError() HolidaySum = createHolidaySum(self, other) - country = (getattr(self, 'country', None) or - getattr(other, 'country', None)) + country = getattr(self, "country", None) or getattr(other, "country", None) if self.country and other.country and self.country != other.country: c1 = self.country if not isinstance(c1, list): @@ -186,15 +180,18 @@ def __add__(self, other): if not isinstance(c2, list): c2 = [c2] country = c1 + c2 - prov = getattr(self, 'prov', None) or getattr(other, 'prov', None) + prov = getattr(self, "prov", None) or getattr(other, "prov", None) if self.prov and other.prov and self.prov != other.prov: p1 = self.prov if isinstance(self.prov, list) else [self.prov] p2 = other.prov if isinstance(other.prov, list) else [other.prov] prov = p1 + p2 - return HolidaySum(years=(self.years | other.years), - expand=(self.expand or other.expand), - observed=(self.observed or other.observed), - country=country, prov=prov) + return HolidaySum( + years=(self.years | other.years), + expand=(self.expand or other.expand), + observed=(self.observed or other.observed), + country=country, + prov=prov, + ) def __radd__(self, other): return self.__add__(other) @@ -205,16 +202,15 @@ def _populate(self, year): def createHolidaySum(h1, h2): class HolidaySum(HolidayBase): - def __init__(self, country, **kwargs): self.country = country self.holidays = [] - if getattr(h1, 'holidays', False): + if getattr(h1, "holidays", False): for h in h1.holidays: self.holidays.append(h) else: self.holidays.append(h1) - if getattr(h2, 'holidays', False): + if getattr(h2, "holidays", False): for h in h2.holidays: self.holidays.append(h) else: diff --git a/holidays/utils.py b/holidays/utils.py index 591b7d3c7..39ce4814d 100755 --- a/holidays/utils.py +++ b/holidays/utils.py @@ -5,18 +5,16 @@ def list_supported_countries(): """List all supported countries incl. their abbreviation.""" - return [name for name, obj in - inspect.getmembers(holidays.countries, inspect.isclass)] + return [name for name, obj in inspect.getmembers(holidays.countries, inspect.isclass)] -def CountryHoliday(country, years=[], prov=None, state=None, expand=True, - observed=True): +def CountryHoliday(country, years=[], prov=None, state=None, expand=True, observed=True): try: - country_classes = inspect.getmembers(holidays.countries, - inspect.isclass) + country_classes = inspect.getmembers(holidays.countries, inspect.isclass) country = next(obj for name, obj in country_classes if name == country) - country_holiday = country(years=years, prov=prov, state=state, - expand=expand, observed=observed) + country_holiday = country( + years=years, prov=prov, state=state, expand=expand, observed=observed + ) except StopIteration: raise KeyError("Country %s not available" % country) return country_holiday @@ -35,12 +33,13 @@ def get_gre_date(year, Hmonth, Hday): except ImportError: import warnings - def warning_on_one_line(message, category, filename, lineno, - file=None, line=None): - return filename + ': ' + str(message) + '\n' + def warning_on_one_line(message, category, filename, lineno, file=None, line=None): + return filename + ": " + str(message) + "\n" + warnings.formatwarning = warning_on_one_line - warnings.warn("Error estimating Islamic Holidays." + - "To estimate, install hijri-converter library") + warnings.warn( + "Error estimating Islamic Holidays." + "To estimate, install hijri-converter library" + ) warnings.warn("pip install -U hijri-converter") warnings.warn("(see https://hijri-converter.readthedocs.io/ )") return [] diff --git a/setup.py b/setup.py index e4e09a30b..e3792b266 100644 --- a/setup.py +++ b/setup.py @@ -14,47 +14,47 @@ from setuptools import setup, find_packages install_requirements = [ - 'python-dateutil', - 'six', - 'convertdate', - 'korean_lunar_calendar', + "python-dateutil", + "six", + "convertdate", + "korean_lunar_calendar", ] if sys.version_info >= (3, 6): - install_requirements.append('hijri_converter') + install_requirements.append("hijri_converter") setup( - name='holidays', - version='0.10.3', - author='ryanss', - author_email='ryanssdev@icloud.com', - maintainer='dr-prodigy', - maintainer_email='maurizio.montel@gmail.com', - url='https://github.com/dr-prodigy/python-holidays', - packages=find_packages(include=['holidays']), - license='MIT', - description='Generate and work with holidays in Python', - long_description=codecs.open('README.rst', encoding='utf-8').read(), - long_description_content_type='text/x-rst', + name="holidays", + version="0.10.3", + author="ryanss", + author_email="ryanssdev@icloud.com", + maintainer="dr-prodigy", + maintainer_email="maurizio.montel@gmail.com", + url="https://github.com/dr-prodigy/python-holidays", + packages=find_packages(include=["holidays"]), + license="MIT", + description="Generate and work with holidays in Python", + long_description=codecs.open("README.rst", encoding="utf-8").read(), + long_description_content_type="text/x-rst", install_requires=install_requirements, - platforms='any', + platforms="any", classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: Implementation :: CPython', - 'Programming Language :: Python :: Implementation :: PyPy', - 'Topic :: Office/Business :: Scheduling', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Software Development :: Localization', + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Office/Business :: Scheduling", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: Localization", ], ) diff --git a/tests/countries/test_australia.py b/tests/countries/test_australia.py index f565892e4..718284e0b 100644 --- a/tests/countries/test_australia.py +++ b/tests/countries/test_australia.py @@ -9,17 +9,14 @@ class TestAU(unittest.TestCase): def setUp(self): self.holidays = holidays.AU(observed=True) self.state_hols = { - state: holidays.AU(observed=True, prov=state) - for state in holidays.AU.PROVINCES + state: holidays.AU(observed=True, prov=state) for state in holidays.AU.PROVINCES } def test_new_years(self): for year in range(1900, 2100): dt = date(year, 1, 1) self.assertIn(dt, self.holidays) - for year, day in enumerate( - [3, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1], 2011 # 2011-15 # 2016-21 - ): + for year, day in enumerate([3, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1], 2011): # 2011-15 # 2016-21 dt = date(year, 1, day) for state, hols in self.state_hols.items(): self.assertIn(dt, hols, (state, dt)) @@ -124,7 +121,18 @@ def test_bank_holiday(self): self.assertEqual(self.state_hols["NSW"][dt], "Bank Holiday") def test_labour_day(self): - for year, day in enumerate([7, 5, 4, 3, 2, 7, 6,], 2011): + for year, day in enumerate( + [ + 7, + 5, + 4, + 3, + 2, + 7, + 6, + ], + 2011, + ): dt = date(year, 3, day) self.assertIn(dt, self.state_hols["WA"], dt) self.assertEqual(self.state_hols["WA"][dt], "Labour Day") @@ -259,9 +267,7 @@ def test_christmas_day(self): self.assertIn(dt, self.holidays) self.assertNotIn(dt + relativedelta(days=-1), self.holidays) self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotEqual( - self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" - ) + self.assertNotEqual(self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)") self.holidays.observed = True self.assertEqual(self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)") for year, day in enumerate( @@ -336,9 +342,7 @@ def test_boxing_day(self): self.assertEqual(self.holidays[dt][:6], "Boxing") def test_all_holidays(self): - au = sum( - holidays.AU(years=[1957, 2012, 2015], prov=p) for p in holidays.AU.PROVINCES - ) + au = sum(holidays.AU(years=[1957, 2012, 2015], prov=p) for p in holidays.AU.PROVINCES) holidays_found = sum((au.get_list(key) for key in au), []) all_holidays = [ "New Year's Day", diff --git a/tests/countries/test_brazil.py b/tests/countries/test_brazil.py index bf959c145..d3ec6c15c 100644 --- a/tests/countries/test_brazil.py +++ b/tests/countries/test_brazil.py @@ -48,9 +48,7 @@ def test_AC_holidays(self): self.assertIn("2018-09-05", ac_holidays) self.assertEqual(ac_holidays[date(2018, 9, 5)], "Dia da Amazônia") self.assertIn("2018-11-17", ac_holidays) - self.assertEqual( - ac_holidays[date(2018, 11, 17)], "Assinatura do Tratado de Petrópolis" - ) + self.assertEqual(ac_holidays[date(2018, 11, 17)], "Assinatura do Tratado de Petrópolis") def test_AL_holidays(self): al_holidays = holidays.BR(state="AL") @@ -59,9 +57,7 @@ def test_AL_holidays(self): self.assertIn("2018-06-29", al_holidays) self.assertEqual(al_holidays[date(2018, 6, 29)], "São Pedro") self.assertIn("2018-09-16", al_holidays) - self.assertEqual( - al_holidays[date(2018, 9, 16)], "Emancipação política de Alagoas" - ) + self.assertEqual(al_holidays[date(2018, 9, 16)], "Emancipação política de Alagoas") self.assertIn("2018-11-20", al_holidays) self.assertEqual(al_holidays[date(2018, 11, 20)], "Consciência Negra") @@ -86,9 +82,7 @@ def test_AM_holidays(self): self.assertIn("2018-11-20", am_holidays) self.assertEqual(am_holidays[date(2018, 11, 20)], "Consciência Negra") self.assertIn("2018-12-08", am_holidays) - self.assertEqual( - am_holidays[date(2018, 12, 8)], "Dia de Nossa Senhora da Conceição" - ) + self.assertEqual(am_holidays[date(2018, 12, 8)], "Dia de Nossa Senhora da Conceição") def test_BA_holidays(self): ba_holidays = holidays.BR(state="BA") @@ -105,9 +99,7 @@ def test_CE_holidays(self): def test_DF_holidays(self): df_holidays = holidays.BR(state="DF") self.assertIn("2018-04-21", df_holidays) - self.assertEqual( - df_holidays[date(2018, 4, 21)], "Fundação de Brasília, Tiradentes" - ) + self.assertEqual(df_holidays[date(2018, 4, 21)], "Fundação de Brasília, Tiradentes") self.assertIn("2018-11-30", df_holidays) self.assertEqual(df_holidays[date(2018, 11, 30)], "Dia do Evangélico") @@ -129,9 +121,7 @@ def test_MA_holidays(self): "Adesão do Maranhão à independência do Brasil", ) self.assertIn("2018-12-08", ma_holidays) - self.assertEqual( - ma_holidays[date(2018, 12, 8)], "Dia de Nossa Senhora da Conceição" - ) + self.assertEqual(ma_holidays[date(2018, 12, 8)], "Dia de Nossa Senhora da Conceição") def test_MT_holidays(self): mt_holidays = holidays.BR(state="MT") @@ -164,9 +154,7 @@ def test_PB_holidays(self): def test_PE_holidays(self): pe_holidays = holidays.BR(state="PE") self.assertIn("2018-03-06", pe_holidays) - self.assertEqual( - pe_holidays[date(2018, 3, 6)], "Revolução Pernambucana (Data Magna)" - ) + self.assertEqual(pe_holidays[date(2018, 3, 6)], "Revolução Pernambucana (Data Magna)") self.assertIn("2018-06-24", pe_holidays) self.assertEqual(pe_holidays[date(2018, 6, 24)], "São João") @@ -225,9 +213,7 @@ def test_SC_holidays(self): def test_SP_holidays(self): sp_holidays = holidays.BR(state="SP") self.assertIn("2018-07-09", sp_holidays) - self.assertEqual( - sp_holidays[date(2018, 7, 9)], "Revolução Constitucionalista de 1932" - ) + self.assertEqual(sp_holidays[date(2018, 7, 9)], "Revolução Constitucionalista de 1932") def test_SE_holidays(self): se_holidays = holidays.BR(state="SE") @@ -237,9 +223,7 @@ def test_SE_holidays(self): def test_TO_holidays(self): to_holidays = holidays.BR(state="TO") self.assertIn("2018-01-01", to_holidays) - self.assertEqual( - to_holidays[date(2018, 1, 1)], "Instalação de Tocantins, Ano novo" - ) + self.assertEqual(to_holidays[date(2018, 1, 1)], "Instalação de Tocantins, Ano novo") self.assertIn("2018-09-08", to_holidays) self.assertEqual(to_holidays[date(2018, 9, 8)], "Nossa Senhora da Natividade") self.assertIn("2018-10-05", to_holidays) diff --git a/tests/countries/test_burundi.py b/tests/countries/test_burundi.py index 8cf4d8a7c..7438048c3 100644 --- a/tests/countries/test_burundi.py +++ b/tests/countries/test_burundi.py @@ -23,18 +23,14 @@ def test_labour_day(self): def test_rwagasore_day(self): self.assertIn("Prince Louis Rwagasore Day", self.holidays[date(2017, 10, 13)]) - self.assertIn( - "Prince Louis Rwagasore Day (Observed)", self.holidays[date(2024, 10, 14)] - ) + self.assertIn("Prince Louis Rwagasore Day (Observed)", self.holidays[date(2024, 10, 14)]) def test_ntaryamira_day(self): self.assertIn("President Ntaryamira Day", self.holidays[date(2017, 4, 6)]) def test_ndadaye_day(self): self.assertIn("President Ndadaye's Day", self.holidays[date(2017, 10, 21)]) - self.assertIn( - "President Ndadaye's Day (Observed)", self.holidays[date(2018, 10, 22)] - ) + self.assertIn("President Ndadaye's Day (Observed)", self.holidays[date(2018, 10, 22)]) def test_independence_day(self): for year in range(1962, 2050): diff --git a/tests/countries/test_canada.py b/tests/countries/test_canada.py index e72d38923..d732e6c00 100644 --- a/tests/countries/test_canada.py +++ b/tests/countries/test_canada.py @@ -321,9 +321,7 @@ def test_christmas_day(self): self.assertIn(dt, self.holidays) self.assertNotIn(dt + relativedelta(days=-1), self.holidays) self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotEqual( - self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" - ) + self.assertNotEqual(self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)") self.holidays.observed = True self.assertIn(date(2010, 12, 24), self.holidays) self.assertEqual(self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)") diff --git a/tests/countries/test_estonia.py b/tests/countries/test_estonia.py index 7314c8aba..03945a3c0 100644 --- a/tests/countries/test_estonia.py +++ b/tests/countries/test_estonia.py @@ -8,9 +8,7 @@ class TestES(unittest.TestCase): def setUp(self): self.holidays = holidays.ES() - self.prov_holidays = { - prov: holidays.ES(prov=prov) for prov in holidays.ES.PROVINCES - } + self.prov_holidays = {prov: holidays.ES(prov=prov) for prov in holidays.ES.PROVINCES} def test_fixed_holidays(self): fixed_days_whole_country = ( @@ -29,12 +27,8 @@ def test_fixed_holidays(self): def test_variable_days_in_2016(self): for prov, prov_holidays in self.prov_holidays.items(): - self.assertEqual( - date(2016, 3, 24) in prov_holidays, prov not in ["CT", "VC"] - ) - self.assertEqual( - date(2016, 3, 25) in prov_holidays, prov not in ["CT", "VC"] - ) + self.assertEqual(date(2016, 3, 24) in prov_holidays, prov not in ["CT", "VC"]) + self.assertEqual(date(2016, 3, 25) in prov_holidays, prov not in ["CT", "VC"]) self.assertEqual( date(2016, 3, 28) in prov_holidays, prov in ["CT", "PV", "NC", "VC", "IB", "CM"], @@ -57,9 +51,7 @@ def test_province_specific_days(self): } for prov, prov_holidays in self.prov_holidays.items(): for year in range(2010, 2025): - self.assertEqual( - date(year, 12, 26) in prov_holidays, prov in ["CT", "IB"] - ) + self.assertEqual(date(year, 12, 26) in prov_holidays, prov in ["CT", "IB"]) if year < 2015: self.assertEqual( date(year, 3, 19) in prov_holidays, @@ -100,13 +92,9 @@ def test_province_specific_days(self): date(year, 3, 19) in prov_holidays, prov in ["CM", "GA", "MC", "NC", "PV", "VC"], ) - self.assertEqual( - date(year, 6, 24) in prov_holidays, prov in ["CT", "GA", "VC"] - ) + self.assertEqual(date(year, 6, 24) in prov_holidays, prov in ["CT", "GA", "VC"]) for fest_day, fest_prov in province_days.items(): - self.assertEqual( - date(year, *fest_day) in prov_holidays, prov in fest_prov - ) + self.assertEqual(date(year, *fest_day) in prov_holidays, prov in fest_prov) class TestEstonia(unittest.TestCase): diff --git a/tests/countries/test_germany.py b/tests/countries/test_germany.py index 490ebe156..bb904c60f 100644 --- a/tests/countries/test_germany.py +++ b/tests/countries/test_germany.py @@ -8,9 +8,7 @@ class TestDE(unittest.TestCase): def setUp(self): self.holidays = holidays.DE() - self.prov_hols = { - prov: holidays.DE(prov=prov) for prov in holidays.DE.PROVINCES - } + self.prov_hols = {prov: holidays.DE(prov=prov) for prov in holidays.DE.PROVINCES} def test_no_data_before_1990(self): de_1989 = sum(holidays.DE(years=[1989], prov=p) for p in holidays.DE.PROVINCES) diff --git a/tests/countries/test_hongkong.py b/tests/countries/test_hongkong.py index 71160a306..d3ff50d14 100644 --- a/tests/countries/test_hongkong.py +++ b/tests/countries/test_hongkong.py @@ -12,9 +12,7 @@ def test_common(self): self.assertTrue(self.holidays.isLeapYear(2000)) self.assertFalse(self.holidays.isLeapYear(2100)) holidaysNoObserved = holidays.HK(observed=False) - self.assertEqual( - holidaysNoObserved[date(2019, 1, 1)], "The first day of January" - ) + self.assertEqual(holidaysNoObserved[date(2019, 1, 1)], "The first day of January") self.assertEqual( self.holidays[date(2015, 9, 3)], "The 70th " @@ -32,9 +30,7 @@ def test_first_day_of_january(self): "The day following the first day of January", ) else: - self.assertEqual( - self.holidays[date(year, 1, 1)], "The first day of January" - ) + self.assertEqual(self.holidays[date(year, 1, 1)], "The first day of January") def test_lunar_new_year(self): for year, month, day in [(2006, 1, 28), (2007, 2, 17), (2010, 2, 13)]: @@ -56,9 +52,7 @@ def test_lunar_new_year(self): (2019, 2, 5), (2020, 1, 25), ]: - self.assertEqual( - self.holidays[date(year, month, day)], "Lunar New Year's Day" - ) + self.assertEqual(self.holidays[date(year, month, day)], "Lunar New Year's Day") for year, month, day in [ (2006, 1, 30), @@ -128,9 +122,7 @@ def test_ching_ming_festival(self): (2019, 4, 5), (2020, 4, 4), ]: - self.assertEqual( - self.holidays[date(year, month, day)], "Ching Ming Festival" - ) + self.assertEqual(self.holidays[date(year, month, day)], "Ching Ming Festival") self.assertEqual( self.holidays[date(2015, 4, 6)], @@ -238,9 +230,7 @@ def test_tuen_ng_festival(self): (2019, 6, 7), (2020, 6, 25), ]: - self.assertEqual( - self.holidays[date(year, month, day)], "Tuen " + "Ng Festival" - ) + self.assertEqual(self.holidays[date(year, month, day)], "Tuen " + "Ng Festival") self.assertEqual( self.holidays[date(2008, 6, 9)], "The day " + "following Tuen Ng Festival" @@ -266,10 +256,7 @@ def test_hksar_day(self): "Hong Kong " + "Special Administrative Region Establishment " + "Day", ) - name = ( - "The day following Hong Kong Special Administrative Region " - + "Establishment Day" - ) + name = "The day following Hong Kong Special Administrative Region " + "Establishment Day" self.assertEqual(self.holidays[date(2007, 7, 2)], name) self.assertEqual(self.holidays[date(2012, 7, 2)], name) self.assertEqual(self.holidays[date(2018, 7, 2)], name) @@ -296,9 +283,7 @@ def test_mid_autumn_festival(self): "The " + "day following the Chinese Mid-Autumn Festival", ) - self.assertEqual( - self.holidays[date(2009, 10, 3)], "Chinese " + "Mid-Autumn Festival" - ) + self.assertEqual(self.holidays[date(2009, 10, 3)], "Chinese " + "Mid-Autumn Festival") def test_national_day(self): for year in [ @@ -337,9 +322,7 @@ def test_chung_yeung_festival(self): (2018, 10, 17), (2019, 10, 7), ]: - self.assertEqual( - self.holidays[date(year, month, day)], "Chung " + "Yeung Festival" - ) + self.assertEqual(self.holidays[date(year, month, day)], "Chung " + "Yeung Festival") name = "The day following Chung Yeung Festival" self.assertEqual(self.holidays[date(2013, 10, 14)], name) diff --git a/tests/countries/test_hungary.py b/tests/countries/test_hungary.py index a18842fba..66a806883 100644 --- a/tests/countries/test_hungary.py +++ b/tests/countries/test_hungary.py @@ -58,9 +58,7 @@ def test_all_saints_day_since_1999(self): self.assertIn(date(year, 11, 1), self.holidays) def test_additional_day_off(self): - observed_days_off = holidays.HU( - observed=True, years=range(2010, self.next_year) - ) + observed_days_off = holidays.HU(observed=True, years=range(2010, self.next_year)) for day in [ date(2010, 12, 24), date(2011, 3, 14), diff --git a/tests/countries/test_iceland.py b/tests/countries/test_iceland.py index 6e79210ad..7420e9288 100644 --- a/tests/countries/test_iceland.py +++ b/tests/countries/test_iceland.py @@ -1,4 +1,3 @@ - from datetime import date, datetime import unittest diff --git a/tests/countries/test_ireland.py b/tests/countries/test_ireland.py index fd74c30cc..f5bddf348 100644 --- a/tests/countries/test_ireland.py +++ b/tests/countries/test_ireland.py @@ -62,4 +62,3 @@ def test_christmas_period(self): self.assertIn("2017-12-26", self.irish_holidays) self.assertIn("2018-12-25", self.irish_holidays) self.assertIn("2018-12-26", self.irish_holidays) - diff --git a/tests/countries/test_japan.py b/tests/countries/test_japan.py index b54882569..e2c072b2a 100644 --- a/tests/countries/test_japan.py +++ b/tests/countries/test_japan.py @@ -131,10 +131,5 @@ def test_reiwa_emperor_holidays(self): self.assertIn(date(2019, 10, 22), self.holidays) def test_invalid_years(self): - self.assertRaises( - NotImplementedError, lambda: date(1948, 1, 1) in self.holidays - ) - self.assertRaises( - NotImplementedError, lambda: date(2100, 1, 1) in self.holidays - ) - + self.assertRaises(NotImplementedError, lambda: date(1948, 1, 1) in self.holidays) + self.assertRaises(NotImplementedError, lambda: date(2100, 1, 1) in self.holidays) diff --git a/tests/countries/test_korea.py b/tests/countries/test_korea.py index 554a93354..a1f0ae985 100644 --- a/tests/countries/test_korea.py +++ b/tests/countries/test_korea.py @@ -53,9 +53,7 @@ def test_lunar_new_year(self): (2027, 2, 7), (2028, 1, 27), ]: - self.assertEqual( - self.holidays[date(year, month, day)], "Lunar New Year's Day" - ) + self.assertEqual(self.holidays[date(year, month, day)], "Lunar New Year's Day") for year, month, day in [ (2006, 1, 30), @@ -103,9 +101,7 @@ def test_independence_movement_day(self): (2019, 3, 1), (2020, 3, 1), ]: - self.assertEqual( - self.holidays[date(year, month, day)], "Independence Movement Day" - ) + self.assertEqual(self.holidays[date(year, month, day)], "Independence Movement Day") self.assertEqual( self.holidays[date(2020, 3, 2)], @@ -175,9 +171,7 @@ def test_birthday_of_buddha(self): self.assertEqual(self.holidays[date(year, month, day)], name) for year, month, day in [(2001, 5, 1)]: - self.assertIn( - "Birthday of the Buddha", self.holidays[date(year, month, day)] - ) + self.assertIn("Birthday of the Buddha", self.holidays[date(year, month, day)]) def test_labour_day(self): for year in [ @@ -248,14 +242,10 @@ def test_chuseok(self): (2029, 9, 21), (2030, 9, 11), ]: - self.assertEqual( - self.holidays[date(year, month, day)], "The day preceding of Chuseok" - ) + self.assertEqual(self.holidays[date(year, month, day)], "The day preceding of Chuseok") for year, month, day in [(2017, 10, 3)]: - self.assertIn( - "The day preceding of Chuseok", self.holidays[date(year, month, day)] - ) + self.assertIn("The day preceding of Chuseok", self.holidays[date(year, month, day)]) for year, month, day in [ (1942, 9, 25), @@ -310,9 +300,7 @@ def test_chuseok(self): (2029, 9, 23), (2030, 9, 13), ]: - self.assertEqual( - self.holidays[date(year, month, day)], "The second day of Chuseok" - ) + self.assertEqual(self.holidays[date(year, month, day)], "The second day of Chuseok") for year, month, day in [ (2014, 9, 10), @@ -329,13 +317,9 @@ def test_chuseok(self): def test_national_foundation_day(self): for year in range(1948, 2050): if year in [1952, 1963, 1971, 1990, 2009, 2017, 2028, 2036, 2039, 2047]: - self.assertIn( - "National Foundation Day", self.holidays[date(year, 10, 3)] - ) + self.assertIn("National Foundation Day", self.holidays[date(year, 10, 3)]) else: - self.assertEqual( - self.holidays[date(year, 10, 3)], "National Foundation Day" - ) + self.assertEqual(self.holidays[date(year, 10, 3)], "National Foundation Day") def test_hangeul_day(self): for year in range(1948, 2007): diff --git a/tests/countries/test_morocco.py b/tests/countries/test_morocco.py index 610fba15f..f8ea585c0 100644 --- a/tests/countries/test_morocco.py +++ b/tests/countries/test_morocco.py @@ -4,6 +4,7 @@ import holidays + class TestMorocco(unittest.TestCase): def setUp(self): self.holidays = holidays.Morocco() diff --git a/tests/countries/test_new_zealand.py b/tests/countries/test_new_zealand.py index d4a97dddf..60b09fb5d 100644 --- a/tests/countries/test_new_zealand.py +++ b/tests/countries/test_new_zealand.py @@ -273,9 +273,7 @@ def test_christmas_day(self): self.assertIn(dt, self.holidays) self.assertNotIn(dt + relativedelta(days=-1), self.holidays) self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotEqual( - self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" - ) + self.assertNotEqual(self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)") self.holidays.observed = True self.assertEqual(self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)") for year, day in enumerate( diff --git a/tests/countries/test_spain.py b/tests/countries/test_spain.py index 87b7023d2..e484dda33 100644 --- a/tests/countries/test_spain.py +++ b/tests/countries/test_spain.py @@ -1,4 +1,3 @@ - from itertools import product from datetime import date, datetime, timedelta from dateutil.relativedelta import relativedelta, MO @@ -6,4 +5,4 @@ import warnings import sys -import holidays \ No newline at end of file +import holidays diff --git a/tests/countries/test_switzerland.py b/tests/countries/test_switzerland.py index aba0867a5..777673ecb 100644 --- a/tests/countries/test_switzerland.py +++ b/tests/countries/test_switzerland.py @@ -8,9 +8,7 @@ class TestSwitzerland(unittest.TestCase): def setUp(self): self.holidays = holidays.CH() - self.prov_hols = dict( - (prov, holidays.CH(prov=prov)) for prov in holidays.CH.PROVINCES - ) + self.prov_hols = dict((prov, holidays.CH(prov=prov)) for prov in holidays.CH.PROVINCES) def test_all_holidays_present(self): ch_2018 = sum(holidays.CH(years=[2018], prov=p) for p in holidays.CH.PROVINCES) diff --git a/tests/countries/test_united_kingdom.py b/tests/countries/test_united_kingdom.py index c3bc67124..7421519c4 100644 --- a/tests/countries/test_united_kingdom.py +++ b/tests/countries/test_united_kingdom.py @@ -100,9 +100,7 @@ def test_christmas_day(self): self.assertIn(dt, self.holidays) self.assertNotIn(dt + relativedelta(days=-1), self.holidays) self.assertNotIn(date(2010, 12, 24), self.holidays) - self.assertNotEqual( - self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" - ) + self.assertNotEqual(self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)") self.holidays.observed = True self.assertEqual(self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)") for year, day in enumerate( diff --git a/tests/countries/test_united_states.py b/tests/countries/test_united_states.py index 8738dffbb..ed6e6f48a 100644 --- a/tests/countries/test_united_states.py +++ b/tests/countries/test_united_states.py @@ -97,9 +97,7 @@ def test_martin_luther(self): self.assertIn(dt, self.holidays) self.assertNotIn(dt + relativedelta(days=-1), self.holidays) self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - self.assertNotIn( - "Martin Luther King Jr. Day", holidays.US(years=[1985]).values() - ) + self.assertNotIn("Martin Luther King Jr. Day", holidays.US(years=[1985]).values()) self.assertIn("Martin Luther King Jr. Day", holidays.US(years=[1986]).values()) self.assertEqual( holidays.US(state="AL").get("2015-01-19"), @@ -129,9 +127,7 @@ def test_martin_luther(self): holidays.US(state="ID").get("2000-01-17"), "Martin Luther King Jr. - Idaho Human Rights Day", ) - self.assertEqual( - holidays.US(state="GA").get("2011-01-17"), "Robert E. Lee's Birthday" - ) + self.assertEqual(holidays.US(state="GA").get("2011-01-17"), "Robert E. Lee's Birthday") def test_lincolns_birthday(self): ca_holidays = holidays.US(state="CA") @@ -376,9 +372,7 @@ def test_prince_jonah_kuhio_kalanianaole_day(self): for dt in [date(1949, 3, 25), date(2016, 3, 25), date(2017, 3, 27)]: self.assertNotIn(dt, self.holidays) self.assertIn(dt, hi_holidays) - self.assertEqual( - hi_holidays.get(dt), "Prince Jonah Kuhio Kalanianaole Day (Observed)" - ) + self.assertEqual(hi_holidays.get(dt), "Prince Jonah Kuhio Kalanianaole Day (Observed)") hi_holidays.observed = False for dt in [date(1949, 3, 25), date(2016, 3, 25), date(2017, 3, 27)]: self.assertNotIn(dt, hi_holidays) @@ -744,15 +738,11 @@ def test_bennington_battle_day(self): "Bennington Battle Day (Observed)", vt_holidays.get_list(date(1997, 8, 15)) ) vt_holidays.observed = True - self.assertIn( - "Bennington Battle Day (Observed)", vt_holidays.get_list(date(1997, 8, 15)) - ) + self.assertIn("Bennington Battle Day (Observed)", vt_holidays.get_list(date(1997, 8, 15))) self.assertNotIn( "Bennington Battle Day (Observed)", vt_holidays.get_list(date(1997, 8, 17)) ) - self.assertIn( - "Bennington Battle Day (Observed)", vt_holidays.get_list(date(1998, 8, 17)) - ) + self.assertIn("Bennington Battle Day (Observed)", vt_holidays.get_list(date(1998, 8, 17))) self.assertNotIn( "Bennington Battle Day (Observed)", vt_holidays.get_list(date(1999, 8, 15)) ) @@ -809,9 +799,7 @@ def test_columbus_day(self): self.assertNotIn(dt + relativedelta(days=-1), self.holidays) self.assertNotIn(dt + relativedelta(days=+1), self.holidays) self.assertEqual(sd_holidays.get(dt), "Native American Day") - self.assertEqual( - vi_holidays.get(dt), "Columbus Day and Puerto Rico Friendship Day" - ) + self.assertEqual(vi_holidays.get(dt), "Columbus Day and Puerto Rico Friendship Day") self.assertNotIn(date(1936, 10, 12), self.holidays) def test_alaska_day(self): @@ -842,12 +830,8 @@ def test_nevada_day(self): self.assertIn("Nevada Day (Observed)", nv_holidays.get_list(date(1998, 10, 30))) self.assertIn("Nevada Day (Observed)", nv_holidays.get_list(date(1999, 11, 1))) nv_holidays.observed = False - self.assertNotIn( - "Nevada Day (Observed)", nv_holidays.get_list(date(1998, 10, 30)) - ) - self.assertNotIn( - "Nevada Day (Observed)", nv_holidays.get_list(date(1999, 11, 1)) - ) + self.assertNotIn("Nevada Day (Observed)", nv_holidays.get_list(date(1998, 10, 30))) + self.assertNotIn("Nevada Day (Observed)", nv_holidays.get_list(date(1999, 11, 1))) def test_liberty_day(self): vi_holidays = holidays.US(state="VI") @@ -995,18 +979,14 @@ def test_thanksgiving_day(self): "Friday After Thanksgiving", ) self.assertEqual(nv_holidays.get(dt + relativedelta(days=+1)), "Family Day") - self.assertEqual( - nm_holidays.get(dt + relativedelta(days=+1)), "Presidents' Day" - ) + self.assertEqual(nm_holidays.get(dt + relativedelta(days=+1)), "Presidents' Day") if dt.year >= 2008: self.assertEqual( md_holidays.get(dt + relativedelta(days=1)), "American Indian Heritage Day", ) if dt.year >= 2010: - self.assertEqual( - in_holidays.get(dt + relativedelta(days=1)), "Lincoln's Birthday" - ) + self.assertEqual(in_holidays.get(dt + relativedelta(days=1)), "Lincoln's Birthday") else: self.assertNotEqual( in_holidays.get(dt + relativedelta(days=1)), "Lincoln's Birthday" @@ -1076,24 +1056,12 @@ def test_christmas_eve(self): self.assertIn(date(2016, 12, 23), nc_holidays) self.assertIn(date(2016, 12, 23), tx_holidays) self.assertIn(date(2016, 12, 23), wi_holidays) - self.assertIn( - "Christmas Eve (Observed)", as_holidays.get_list(date(2017, 12, 22)) - ) - self.assertIn( - "Christmas Eve (Observed)", ks_holidays.get_list(date(2017, 12, 22)) - ) - self.assertIn( - "Christmas Eve (Observed)", mi_holidays.get_list(date(2017, 12, 22)) - ) - self.assertIn( - "Christmas Eve (Observed)", nc_holidays.get_list(date(2017, 12, 22)) - ) - self.assertIn( - "Christmas Eve (Observed)", tx_holidays.get_list(date(2017, 12, 22)) - ) - self.assertIn( - "Christmas Eve (Observed)", wi_holidays.get_list(date(2017, 12, 22)) - ) + self.assertIn("Christmas Eve (Observed)", as_holidays.get_list(date(2017, 12, 22))) + self.assertIn("Christmas Eve (Observed)", ks_holidays.get_list(date(2017, 12, 22))) + self.assertIn("Christmas Eve (Observed)", mi_holidays.get_list(date(2017, 12, 22))) + self.assertIn("Christmas Eve (Observed)", nc_holidays.get_list(date(2017, 12, 22))) + self.assertIn("Christmas Eve (Observed)", tx_holidays.get_list(date(2017, 12, 22))) + self.assertIn("Christmas Eve (Observed)", wi_holidays.get_list(date(2017, 12, 22))) def test_christmas_day(self): for year in range(1900, 2100): @@ -1115,12 +1083,8 @@ def test_day_after_christmas(self): self.assertNotIn(date(2015, 12, 28), tx_holidays) self.assertNotIn(date(2016, 12, 27), tx_holidays) nc_holidays.observed = True - self.assertIn( - "Day After Christmas (Observed)", nc_holidays.get_list(date(2015, 12, 28)) - ) - self.assertIn( - "Day After Christmas (Observed)", nc_holidays.get_list(date(2016, 12, 27)) - ) + self.assertIn("Day After Christmas (Observed)", nc_holidays.get_list(date(2015, 12, 28))) + self.assertIn("Day After Christmas (Observed)", nc_holidays.get_list(date(2016, 12, 27))) tx_holidays.observed = True self.assertNotIn( "Day After Christmas (Observed)", tx_holidays.get_list(date(2015, 12, 28)) diff --git a/tests/countries/test_vietnam.py b/tests/countries/test_vietnam.py index 270597c7d..472c1ce80 100644 --- a/tests/countries/test_vietnam.py +++ b/tests/countries/test_vietnam.py @@ -10,15 +10,11 @@ def setUp(self): self.holidays = holidays.VN() def test_common(self): - self.assertEqual( - self.holidays[date(2020, 1, 1)], "International New Year's Day" - ) + self.assertEqual(self.holidays[date(2020, 1, 1)], "International New Year's Day") def test_first_day_of_january(self): for year in range(1979, 2050): - self.assertIn( - "International New Year's Day", self.holidays[date(year, 1, 1)] - ) + self.assertIn("International New Year's Day", self.holidays[date(year, 1, 1)]) def test_lunar_new_year(self): lunar_new_year_list = [ @@ -66,15 +62,11 @@ def test_lunar_new_year(self): def test_king_hung_day(self): for year, month, day in [(2020, 4, 2), (2021, 4, 21), (2022, 4, 10)]: - self.assertEqual( - self.holidays[date(year, month, day)], "Hung Kings Commemoration Day" - ) + self.assertEqual(self.holidays[date(year, month, day)], "Hung Kings Commemoration Day") def test_liberation_day(self): for year in range(1979, 2050): - self.assertIn( - "Liberation Day/Reunification Day", self.holidays[date(year, 4, 30)] - ) + self.assertIn("Liberation Day/Reunification Day", self.holidays[date(year, 4, 30)]) def test_international_labor_day(self): for year in range(1979, 2050): @@ -87,7 +79,4 @@ def test_independence_day(self): def test_years_range(self): self.holidays = holidays.VN(years=range(1979, 2050)) for year in range(1979, 2050): - self.assertIn( - "International New Year's Day", self.holidays[date(year, 1, 1)] - ) - + self.assertIn("International New Year's Day", self.holidays[date(year, 1, 1)]) diff --git a/tests/test_holiday_base.py b/tests/test_holiday_base.py index e14232667..0a019a03c 100644 --- a/tests/test_holiday_base.py +++ b/tests/test_holiday_base.py @@ -51,9 +51,7 @@ def test_getitem(self): self.holidays[date(2014, 1, 1) : date(2013, 12, 24) : 7], [date(2014, 1, 1), date(2013, 12, 25)], ) - self.assertListEqual( - self.holidays[date(2013, 12, 31) : date(2014, 1, 2) : -3], [] - ) + self.assertListEqual(self.holidays[date(2013, 12, 31) : date(2014, 1, 2) : -3], []) self.assertListEqual( self.holidays[date(2014, 1, 1) : date(2013, 12, 24) : timedelta(days=3)], [date(2014, 1, 1)], @@ -106,7 +104,10 @@ def test_setitem(self): def test_update(self): h = holidays.HolidayBase() h.update( - {date(2015, 1, 1): "New Year's Day", "2015-12-25": "Christmas Day",} + { + date(2015, 1, 1): "New Year's Day", + "2015-12-25": "Christmas Day", + } ) self.assertIn("2015-01-01", h) self.assertIn(date(2015, 12, 25), h) @@ -114,7 +115,10 @@ def test_update(self): def test_append(self): h = holidays.HolidayBase() h.update( - {date(2015, 1, 1): "New Year's Day", "2015-12-25": "Christmas Day",} + { + date(2015, 1, 1): "New Year's Day", + "2015-12-25": "Christmas Day", + } ) h.append([date(2015, 4, 1), "2015-04-03"]) h.append(date(2015, 4, 6)) @@ -201,9 +205,7 @@ def test_add(self): self.assertIn("2014-02-10", na) self.assertIn("2014-02-17", na) self.assertIn("2014-07-04", na) - provs = holidays.CA(prov="ON", years=[2014]) + holidays.CA( - prov="BC", years=[2015] - ) + provs = holidays.CA(prov="ON", years=[2014]) + holidays.CA(prov="BC", years=[2015]) self.assertIn("2015-02-09", provs) self.assertIn("2015-02-16", provs) self.assertEqual(provs.prov, ["ON", "BC"]) @@ -216,13 +218,9 @@ def test_add(self): self.assertIn(date(1969, 12, 25), na) self.assertEqual(na.get(date(1969, 7, 1)), "Dominion Day") self.assertEqual(na.get(date(1983, 7, 1)), "Canada Day") - self.assertEqual( - na.get(date(1969, 12, 25)), "Christmas Day, Navidad [Christmas]" - ) + self.assertEqual(na.get(date(1969, 12, 25)), "Christmas Day, Navidad [Christmas]") na = holidays.MX() + holidays.CA() + holidays.US() - self.assertEqual( - na.get(date(1969, 12, 25)), "Navidad [Christmas], Christmas Day" - ) + self.assertEqual(na.get(date(1969, 12, 25)), "Navidad [Christmas], Christmas Day") def test_get_list(self): westland = holidays.NZ(prov="WTL") @@ -238,22 +236,16 @@ def test_get_list(self): ["Westland Anniversary Day", "Chatham Islands Anniversary Day"], ) self.assertEqual(wild.get_list(date(1969, 1, 1)), ["New Year's Day"]) - self.assertEqual( - westland.get_list(date(1969, 12, 1)), ["Westland Anniversary Day"] - ) + self.assertEqual(westland.get_list(date(1969, 12, 1)), ["Westland Anniversary Day"]) self.assertEqual(westland.get_list(date(1969, 1, 1)), ["New Year's Day"]) - self.assertEqual( - chathams.get_list(date(1969, 12, 1)), ["Chatham Islands Anniversary Day"] - ) + self.assertEqual(chathams.get_list(date(1969, 12, 1)), ["Chatham Islands Anniversary Day"]) self.assertEqual(chathams.get_list(date(1969, 1, 1)), ["New Year's Day"]) ca = holidays.CA() us = holidays.US() mx = holidays.MX() na = ca + us + mx self.assertIn(date(1969, 12, 25), na) - self.assertEqual( - na.get_list(date(1969, 12, 25)), ["Christmas Day", "Navidad [Christmas]"] - ) + self.assertEqual(na.get_list(date(1969, 12, 25)), ["Christmas Day", "Navidad [Christmas]"]) self.assertEqual(na.get_list(date(1969, 7, 1)), ["Dominion Day"]) self.assertEqual(na.get_list(date(1969, 1, 3)), []) @@ -440,9 +432,7 @@ def test_strings(self): def test_exceptions(self): self.assertRaises((TypeError, ValueError), lambda: "abc" in self.holidays) self.assertRaises((TypeError, ValueError), lambda: self.holidays.get("abc123")) - self.assertRaises( - (TypeError, ValueError), self.holidays.__setitem__, "abc", "Test" - ) + self.assertRaises((TypeError, ValueError), self.holidays.__setitem__, "abc", "Test") self.assertRaises((TypeError, ValueError), lambda: {} in self.holidays)