From dc0d9fc726aa5e9d1da87b0af0127991635ee178 Mon Sep 17 00:00:00 2001 From: s-weigand Date: Fri, 4 Dec 2020 16:27:38 +0100 Subject: [PATCH] Formatted all files with black --- holidays/__init__.py | 18 +- holidays/constants.py | 3 +- holidays/countries/__init__.py | 13 +- holidays/countries/angola.py | 3 +- holidays/countries/argentina.py | 56 +-- holidays/countries/aruba.py | 21 +- holidays/countries/australia.py | 71 ++-- holidays/countries/austria.py | 9 +- holidays/countries/bangladesh.py | 7 +- holidays/countries/belarus.py | 15 +- holidays/countries/brazil.py | 128 ++++-- holidays/countries/bulgaria.py | 32 +- holidays/countries/burundi.py | 4 +- holidays/countries/canada.py | 156 ++++---- holidays/countries/chile.py | 79 ++-- holidays/countries/colombia.py | 27 +- holidays/countries/czechia.py | 34 +- holidays/countries/denmark.py | 2 +- holidays/countries/djibouti.py | 2 +- holidays/countries/dominican_republic.py | 13 +- holidays/countries/egypt.py | 2 +- holidays/countries/european_central_bank.py | 2 +- holidays/countries/finland.py | 3 +- holidays/countries/france.py | 98 +++-- holidays/countries/germany.py | 89 +++-- holidays/countries/greece.py | 12 +- holidays/countries/honduras.py | 23 +- holidays/countries/hongkong.py | 296 +++++++++++--- holidays/countries/hungary.py | 55 ++- holidays/countries/iceland.py | 8 +- holidays/countries/india.py | 76 ++-- holidays/countries/ireland.py | 3 +- holidays/countries/israel.py | 37 +- holidays/countries/italy.py | 168 +++++--- holidays/countries/japan.py | 163 ++++++-- holidays/countries/kenya.py | 3 +- holidays/countries/korea.py | 12 +- holidays/countries/latvia.py | 9 +- holidays/countries/lithuania.py | 21 +- holidays/countries/luxembourg.py | 2 +- holidays/countries/malawi.py | 3 +- holidays/countries/mexico.py | 12 +- holidays/countries/morocco.py | 13 +- holidays/countries/netherlands.py | 1 - holidays/countries/new_zealand.py | 51 ++- holidays/countries/nicaragua.py | 23 +- holidays/countries/nigeria.py | 3 +- holidays/countries/norway.py | 6 +- holidays/countries/paraguay.py | 7 +- holidays/countries/peru.py | 21 +- holidays/countries/poland.py | 33 +- holidays/countries/portugal.py | 5 +- holidays/countries/romania.py | 2 +- holidays/countries/serbia.py | 17 +- holidays/countries/singapore.py | 414 ++++++++++++++++---- holidays/countries/slovakia.py | 28 +- holidays/countries/slovenia.py | 5 +- holidays/countries/south_africa.py | 3 +- holidays/countries/spain.py | 187 ++++++--- holidays/countries/sweden.py | 9 +- holidays/countries/switzerland.py | 242 ++++++++---- holidays/countries/turkey.py | 7 +- holidays/countries/ukraine.py | 15 +- holidays/countries/united_arab_emirates.py | 75 ++-- holidays/countries/united_kingdom.py | 89 ++--- holidays/countries/united_states.py | 386 ++++++++++-------- holidays/countries/vietnam.py | 22 +- holidays/holiday_base.py | 46 +-- holidays/utils.py | 62 ++- pyproject.toml | 2 +- setup.py | 76 ++-- tests/countries/__init__.py | 2 - tests/countries/test_argentina.py | 1 - tests/countries/test_australia.py | 46 ++- tests/countries/test_bangladesh.py | 1 - tests/countries/test_belgium.py | 1 - tests/countries/test_brazil.py | 76 +++- tests/countries/test_bulgaria.py | 1 - tests/countries/test_burundi.py | 27 +- tests/countries/test_canada.py | 4 +- tests/countries/test_chile.py | 1 - tests/countries/test_egypt.py | 1 - tests/countries/test_estonia.py | 15 +- tests/countries/test_finland.py | 1 - tests/countries/test_france.py | 4 +- tests/countries/test_germany.py | 12 +- tests/countries/test_greece.py | 17 +- tests/countries/test_hongkong.py | 31 +- tests/countries/test_hungary.py | 4 +- tests/countries/test_iceland.py | 4 +- tests/countries/test_israel.py | 28 +- tests/countries/test_korea.py | 52 ++- tests/countries/test_latvia.py | 1 - tests/countries/test_lithuania.py | 1 - tests/countries/test_malawi.py | 1 - tests/countries/test_mexico.py | 2 - tests/countries/test_netherlands.py | 1 - tests/countries/test_new_zealand.py | 44 ++- tests/countries/test_norway.py | 1 - tests/countries/test_russia.py | 1 - tests/countries/test_serbia.py | 1 - tests/countries/test_spain.py | 2 - tests/countries/test_sweden.py | 1 - tests/countries/test_switzerland.py | 4 +- tests/countries/test_united_kingdom.py | 4 +- tests/countries/test_united_states.py | 110 ++++-- tests/countries/test_vietnam.py | 10 +- tests/test_holiday_base.py | 84 ++-- 108 files changed, 2798 insertions(+), 1439 deletions(-) diff --git a/holidays/__init__.py b/holidays/__init__.py index 439f79f83..82e541df1 100644 --- a/holidays/__init__.py +++ b/holidays/__init__.py @@ -12,9 +12,21 @@ # 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 -__version__ = '0.10.4' +__version__ = "0.10.4" 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/__init__.py b/holidays/countries/__init__.py index 0a5d78a24..a17472766 100644 --- a/holidays/countries/__init__.py +++ b/holidays/countries/__init__.py @@ -74,7 +74,16 @@ from .turkey import Turkey, TR, TUR from .ukraine import Ukraine, UA, UKR from .united_arab_emirates import UnitedArabEmirates, AE, ARE -from .united_kingdom import UnitedKingdom, UK, GB, England, Wales, Scotland,\ - IsleOfMan, NorthernIreland, GBR +from .united_kingdom import ( + UnitedKingdom, + UK, + GB, + England, + Wales, + Scotland, + IsleOfMan, + NorthernIreland, + GBR, +) from .united_states import UnitedStates, US, USA from .vietnam import Vietnam, VN, VNM diff --git a/holidays/countries/angola.py b/holidays/countries/angola.py index 6199c4ef2..72382c15d 100644 --- a/holidays/countries/angola.py +++ b/holidays/countries/angola.py @@ -23,11 +23,10 @@ class Angola(HolidayBase): - def __init__(self, **kwargs): # https://www.officeholidays.com/countries/angola/ # https://www.timeanddate.com/holidays/angola/ - self.country = 'AO' + self.country = "AO" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/argentina.py b/holidays/countries/argentina.py index a1afa4ca0..0c00373d9 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,9 @@ 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..24117f7e9 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,19 @@ 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 +125,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 +134,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 +146,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 +203,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,13 +223,14 @@ 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 else: - self[date(year, AUG, 5) + rd(weekday=FR) + rd(weekday=WE)] = \ - name + self[ + date(year, AUG, 5) + rd(weekday=FR) + rd(weekday=WE) + ] = name # Christmas Day name = "Christmas Day" @@ -235,7 +240,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/bangladesh.py b/holidays/countries/bangladesh.py index 652348a10..b2a933022 100644 --- a/holidays/countries/bangladesh.py +++ b/holidays/countries/bangladesh.py @@ -19,7 +19,7 @@ class Bangladesh(HolidayBase): # https://en.wikipedia.org/wiki/Public_holidays_in_Bangladesh def __init__(self, **kwargs): - self.country = 'TR' + self.country = "TR" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -28,8 +28,9 @@ def _populate(self, year): self[date(year, FEB, 21)] = "International Mother's language Day" # 17th March - self[date(year, MAR, 17)] = "Sheikh Mujibur Rahman's Birthday " \ - "and Children's Day" + self[date(year, MAR, 17)] = ( + "Sheikh Mujibur Rahman's Birthday " "and Children's Day" + ) # 26th March self[date(year, MAR, 26)] = "Independence Day" diff --git a/holidays/countries/belarus.py b/holidays/countries/belarus.py index 471722614..1cb5d33c4 100644 --- a/holidays/countries/belarus.py +++ b/holidays/countries/belarus.py @@ -46,8 +46,9 @@ 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 +63,17 @@ 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..a9643cbe2 100644 --- a/holidays/countries/brazil.py +++ b/holidays/countries/brazil.py @@ -16,8 +16,19 @@ 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 +37,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 +101,115 @@ 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..af8a54609 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,24 @@ 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 +86,12 @@ 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..5d43001dc 100644 --- a/holidays/countries/canada.py +++ b/holidays/countries/canada.py @@ -17,19 +17,43 @@ 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 +62,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 +77,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 +108,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 +119,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 +142,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 +168,60 @@ 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 +230,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 +253,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 d66b71b49..d5591d267 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, MO, FR, SA -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 TUE, THU, FRI, SAT, SUN from holidays.holiday_base import HolidayBase @@ -28,11 +27,27 @@ class Chile(HolidayBase): # https://es.wikipedia.org/wiki/Anexo:D%C3%ADas_feriados_en_Chile # ISO 3166-2 codes for the principal subdivisions, called regions - STATES = ['AI', 'AN', 'AP', 'AR', 'AT', 'BI', 'CO', 'LI', 'LL', 'LR', - 'MA', 'ML', 'NB', 'RM', 'TA', 'VS'] + STATES = [ + "AI", + "AN", + "AP", + "AR", + "AT", + "BI", + "CO", + "LI", + "LL", + "LR", + "MA", + "ML", + "NB", + "RM", + "TA", + "VS", + ] def __init__(self, **kwargs): - self.country = 'CL' + self.country = "CL" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -45,7 +60,7 @@ def _populate(self, year): # Holy Week (Law 2.977) name_fri = "Semana Santa (Viernes Santo) [Good Friday)]" name_sat = "Semana Santa (Sábado Santo) [Good Saturday)]" - 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) + rd(weekday=SA(-1))] = name_sat @@ -66,8 +81,10 @@ def _populate(self, year): else: # floating Monday holiday (Law 19.668) if date(year, JUN, 29).weekday() <= THU: - self[date(year, JUN, 29) + rd(date(year, JUN, 29), - weekday=MO(-1))] = name + self[ + date(year, JUN, 29) + + rd(date(year, JUN, 29), weekday=MO(-1)) + ] = name elif date(year, JUN, 29).weekday() == FRI: self[date(year, JUN, 29) + rd(weekday=MO)] = name else: @@ -106,15 +123,19 @@ def _populate(self, year): if year < 2010: self[date(year, OCT, 12)] = "Día de la Raza [Columbus day]" elif year < 2020: - 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]" + ) else: # floating Monday holiday (Law 19.668) - name = ("Día del Descubrimiento de dos Mundos [Columbus Day]") + name = "Día del Descubrimiento de dos Mundos [Columbus Day]" if date(year, OCT, 12).weekday() <= THU: - self[date(year, OCT, 12) + rd(date(year, OCT, 12), - weekday=MO(-1))] = name + self[ + date(year, OCT, 12) + + rd(date(year, OCT, 12), weekday=MO(-1)) + ] = name elif date(year, OCT, 12).weekday() == FRI: self[date(year, OCT, 12) + rd(weekday=MO)] = name else: @@ -122,8 +143,10 @@ def _populate(self, year): # National Day of the Evangelical and Protestant Churches (Law 20.299) if year > 2007: - name = ("Día Nacional de las Iglesias Evangélicas y Protestantes " - " [Reformation Day]") + name = ( + "Día Nacional de las Iglesias Evangélicas y Protestantes " + " [Reformation Day]" + ) self[date(year, OCT, 31)] = name # All Saints Day (Law 2.977) @@ -131,25 +154,29 @@ def _populate(self, year): self[date(year, NOV, 1)] = name # Immaculate Conception (Law 2.977) - self[date(year, DEC, 8)] = "La Inmaculada Concepción" \ - " [Immaculate Conception]" + self[date(year, DEC, 8)] = ( + "La Inmaculada Concepción" " [Immaculate Conception]" + ) # Christmas (Law 2.977) self[date(year, DEC, 25)] = "Navidad [Christmas]" # región de Arica y Parinacota - if self.state == 'AP' and year >= 2020: + if self.state == "AP" and year >= 2020: # Law 20.663 - self[date(year, JUN, 7)] = ("Asalto y Toma del Morro de Arica" - " [Assault and Capture of Cape Arica]") + self[date(year, JUN, 7)] = ( + "Asalto y Toma del Morro de Arica" + " [Assault and Capture of Cape Arica]" + ) # región de Ñuble - if self.state == 'NB' and year >= 2014: + if self.state == "NB" and year >= 2014: # Law 20.678 - self[date(year, AUG, 20)] =\ - ("Nacimiento del Prócer de la Independencia" - " (Chillán y Chillán Viejo)" - " [Nativity of Bernardo O'Higgins]") + self[date(year, AUG, 20)] = ( + "Nacimiento del Prócer de la Independencia" + " (Chillán y Chillán Viejo)" + " [Nativity of Bernardo O'Higgins]" + ) class CL(Chile): diff --git a/holidays/countries/colombia.py b/holidays/countries/colombia.py index f36a93e26..f1d408c84 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,9 @@ 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 +100,31 @@ 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/czechia.py b/holidays/countries/czechia.py index e7baa0d73..cad2316e4 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,15 @@ 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 +45,20 @@ 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 +79,7 @@ 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/djibouti.py b/holidays/countries/djibouti.py index 45094d83c..adc2a6205 100644 --- a/holidays/countries/djibouti.py +++ b/holidays/countries/djibouti.py @@ -43,7 +43,7 @@ class Djibouti(HolidayBase): # is_weekend function is there, however not activated for accuracy. def __init__(self, **kwargs): - self.country = 'DJ' + self.country = "DJ" 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 66d995341..b22d06949 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..ef5d52a75 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,9 @@ 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 +63,9 @@ 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..e8bd7c7fc 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,22 @@ 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 +76,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..06dea1049 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,9 @@ 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 +86,9 @@ 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 +106,20 @@ 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)] = \ + 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 +170,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 +185,9 @@ 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 +196,10 @@ 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 +257,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 +465,18 @@ 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..008341218 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 @@ -44,19 +43,22 @@ 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") + 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) @@ -81,7 +83,8 @@ def _populate(self, year): # International Workers' Day if 1946 <= year: self._add_with_observed_day_off( - date(year, MAY, 1), "A Munka ünnepe") + date(year, MAY, 1), "A Munka ünnepe" + ) if 1950 <= year <= 1953: self[date(year, MAY, 2)] = "A Munka ünnepe" @@ -90,22 +93,28 @@ def _populate(self, year): 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") + 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") + date(year, OCT, 23), "Nemzeti ünnep" + ) # All Saints' Day if 1999 <= year: self._add_with_observed_day_off( - date(year, NOV, 1), "Mindenszentek") + 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 +123,24 @@ 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..bf4001c42 100644 --- a/holidays/countries/iceland.py +++ b/holidays/countries/iceland.py @@ -34,16 +34,16 @@ 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..a1b4137fb 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,72 @@ 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" - - if self.prov in ('OD', 'AP', 'BR', 'WB', 'KL', - 'HR', 'MH', 'UP', 'UK', 'TN'): + self[date(year, APR, 15)] = ( + "Maha Vishuva Sankranti / Pana" " Sankranti" + ) + + 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..1f27316c8 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,14 @@ 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)] = \ + self[date(year, month, day) + rd(days=observed_delta + 1)] = ( name + " (Observed)" + ) # Independence Day name = "Independence Day" @@ -66,8 +66,9 @@ 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)] = \ + self[date(year, month, day) + rd(days=observed_delta + 1)] = ( name + " (Observed)" + ) # Lag Baomer name = "Lag B'Omer" @@ -90,39 +91,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..c3dda603f 100644 --- a/holidays/countries/italy.py +++ b/holidays/countries/italy.py @@ -16,28 +16,86 @@ 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 +116,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 a836bdc33..0d0685d28 100644 --- a/holidays/countries/japan.py +++ b/holidays/countries/japan.py @@ -15,8 +15,20 @@ 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 @@ -24,7 +36,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 +57,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)] = "春分の日" @@ -128,9 +140,9 @@ def _populate(self, year): self[date(year, JUN, 9)] = "結婚の儀" elif 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) @@ -175,8 +187,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): @@ -186,25 +213,85 @@ 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, 9, (2021,)), (8, 12, (2019, 2024, 2030, 2041, 2047)), @@ -212,10 +299,40 @@ def _add_substitute_holidays(self, year): (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 fae9cea64..66e542964 100644 --- a/holidays/countries/korea.py +++ b/holidays/countries/korea.py @@ -45,8 +45,9 @@ 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 @@ -186,8 +187,11 @@ 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..9e77b6c46 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,9 @@ 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..97a10cec0 100644 --- a/holidays/countries/lithuania.py +++ b/holidays/countries/lithuania.py @@ -34,14 +34,14 @@ 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 +66,16 @@ 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/malawi.py b/holidays/countries/malawi.py index 299c63f14..22442d2d2 100644 --- a/holidays/countries/malawi.py +++ b/holidays/countries/malawi.py @@ -22,11 +22,10 @@ class Malawi(HolidayBase): - def __init__(self, **kwargs): # https://www.officeholidays.com/countries/malawi # https://www.timeanddate.com/holidays/malawi/ - self.country = 'MW' + self.country = "MW" HolidayBase.__init__(self, **kwargs) def _populate(self, year): diff --git a/holidays/countries/mexico.py b/holidays/countries/mexico.py index e283fdb34..8994371dd 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,9 @@ 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))] = \ + self[date(year, FEB, 1) + rd(weekday=MO(+1))] = ( name + " (Observed)" + ) if year >= 1917: self[date(year, FEB, 5)] = name @@ -49,8 +49,9 @@ 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))] = \ + self[date(year, MAR, 1) + rd(weekday=MO(+3))] = ( name + " (Observed)" + ) if year >= 1917: self[date(year, MAR, 21)] = name @@ -75,8 +76,9 @@ 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))] = \ + 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..6bec2a7ca 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,10 @@ 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 +85,9 @@ 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..b5cb2a7ea 100644 --- a/holidays/countries/nicaragua.py +++ b/holidays/countries/nicaragua.py @@ -21,19 +21,20 @@ 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 +43,13 @@ 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 +57,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..380f00f9b 100644 --- a/holidays/countries/norway.py +++ b/holidays/countries/norway.py @@ -52,9 +52,9 @@ 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..ab949e484 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,22 @@ 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..a6881bdca 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,7 @@ 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..a73eed28a 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,16 @@ 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 95aa3a78b..40f8a8a32 100644 --- a/holidays/countries/singapore.py +++ b/holidays/countries/singapore.py @@ -16,8 +16,19 @@ 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 @@ -61,14 +72,29 @@ def _populate(self, year): # 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) @@ -86,20 +112,36 @@ def _populate(self, year): # Second day of Hari Raya Puasa (up to and including 1968) if year <= 1968: hol_date += rd(days=+1) - self[hol_date] = ("Second day of Hari Raya Puasa*" - " (*estimated)") + self[hol_date] = ( + "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) @@ -126,14 +168,29 @@ def _populate(self, year): # 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]) self[hol_date] = "Vesak Day" @@ -147,14 +204,29 @@ def _populate(self, year): # 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]) self[hol_date] = "Deepavali" @@ -170,8 +242,13 @@ def _populate(self, year): 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" @@ -187,11 +264,11 @@ def _populate(self, year): # is declared a public holiday in Singapore." for (hol_date, hol_name) in list(self.items()): if hol_date.weekday() == SUN: - self[hol_date] += ' [Sunday]' + self[hol_date] += " [Sunday]" in_lieu_date = hol_date + rd(days=+1) while in_lieu_date in self: in_lieu_date += rd(days=+1) - self[in_lieu_date] = hol_name + '[In lieu]' + self[in_lieu_date] = hol_name + "[In lieu]" # The below is used to calculate lunar new year (i.e. Chinese new year) # Code borrowed from Hong Kong entry as of 16-Nov-19 @@ -203,46 +280,205 @@ def _populate(self, year): # 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) @@ -252,12 +488,18 @@ def _populate(self, year): 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 @@ -287,7 +529,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): @@ -298,7 +540,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..3bba9d5df 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,16 @@ 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 +48,17 @@ 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 +81,7 @@ 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 25effdb0f..bbae2d763 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 8ac7bb8c5..58f9c5d33 100644 --- a/holidays/countries/spain.py +++ b/holidays/countries/spain.py @@ -15,19 +15,49 @@ 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.constants import SUN 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 _is_observed(self, date_holiday, name_holiday): @@ -40,86 +70,123 @@ def _populate(self, year): self._is_observed(date(year, JAN, 1), "Año nuevo") self._is_observed(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._is_observed(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._is_observed(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._is_observed(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._is_observed(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._is_observed(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._is_observed(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._is_observed(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._is_observed(date(year, JUN, 24), "San Juan") self._is_observed(date(year, AUG, 15), "Asunción de la Virgen") self._is_observed(date(year, OCT, 12), "Día de la Hispanidad") self._is_observed(date(year, NOV, 1), "Todos los Santos") - self._is_observed(date(year, DEC, 6), "Día de la Constitución " - "Española") + self._is_observed( + date(year, DEC, 6), "Día de la Constitución " "Española" + ) self._is_observed(date(year, DEC, 8), "La Inmaculada Concepción") self._is_observed(date(year, DEC, 25), "Navidad") - if self.prov and self.prov in ['CT', 'IB']: + if self.prov and self.prov in ["CT", "IB"]: self._is_observed(date(year, DEC, 26), "San Esteban") # Provinces festive day if self.prov: - if self.prov == 'AN': + if self.prov == "AN": self._is_observed(date(year, FEB, 28), "Día de Andalucia") - elif self.prov == 'AR': + elif self.prov == "AR": self._is_observed(date(year, APR, 23), "Día de San Jorge") - elif self.prov == 'AS': + elif self.prov == "AS": self._is_observed(date(year, SEP, 8), "Día de Asturias") - elif self.prov == 'CB': - self._is_observed(date(year, JUL, 28), "Día de las Instituci" - "ones de Cantabria") - elif self.prov == 'CM': - self._is_observed(date(year, MAY, 31), "Día de Castilla " - "La Mancha") - elif self.prov == 'CL': - self._is_observed(date(year, APR, 23), "Día de Castilla y " - "Leon") - elif self.prov == 'CT': - self._is_observed(date(year, SEP, 11), "Día Nacional de " - "Catalunya") - elif self.prov == 'VC': - self._is_observed(date(year, OCT, 9), "Día de la Comunidad " - "Valenciana") - elif self.prov == 'EX': + elif self.prov == "CB": + self._is_observed( + date(year, JUL, 28), + "Día de las Instituci" "ones de Cantabria", + ) + elif self.prov == "CM": + self._is_observed( + date(year, MAY, 31), "Día de Castilla " "La Mancha" + ) + elif self.prov == "CL": + self._is_observed( + date(year, APR, 23), "Día de Castilla y " "Leon" + ) + elif self.prov == "CT": + self._is_observed( + date(year, SEP, 11), "Día Nacional de " "Catalunya" + ) + elif self.prov == "VC": + self._is_observed( + date(year, OCT, 9), "Día de la Comunidad " "Valenciana" + ) + elif self.prov == "EX": self._is_observed(date(year, SEP, 8), "Día de Extremadura") - elif self.prov == 'GA': - self._is_observed(date(year, JUL, 25), "Día Nacional de " - "Galicia") - elif self.prov == 'IB': - self._is_observed(date(year, MAR, 1), "Día de las Islas " - "Baleares") - elif self.prov == 'CN': + elif self.prov == "GA": + self._is_observed( + date(year, JUL, 25), "Día Nacional de " "Galicia" + ) + elif self.prov == "IB": + self._is_observed( + date(year, MAR, 1), "Día de las Islas " "Baleares" + ) + elif self.prov == "CN": self._is_observed(date(year, MAY, 30), "Día de Canarias") - elif self.prov == 'MD': - self._is_observed(date(year, MAY, 2), "Día de Comunidad de " - "Madrid") - elif self.prov == 'MC': - self._is_observed(date(year, JUN, 9), "Día de la Región de " - "Murcia") - elif self.prov == 'NC': + elif self.prov == "MD": + self._is_observed( + date(year, MAY, 2), "Día de Comunidad de " "Madrid" + ) + elif self.prov == "MC": + self._is_observed( + date(year, JUN, 9), "Día de la Región de " "Murcia" + ) + elif self.prov == "NC": self._is_observed(date(year, SEP, 27), "Día de Navarra") - elif self.prov == 'PV': + elif self.prov == "PV": self._is_observed(date(year, OCT, 25), "Día del Páis Vasco") - elif self.prov == 'RI': + elif self.prov == "RI": self._is_observed(date(year, JUN, 9), "Día de La Rioja") diff --git a/holidays/countries/sweden.py b/holidays/countries/sweden.py index 0411be7df..9c9a116b6 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,9 @@ 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..754b41b8d 100644 --- a/holidays/countries/switzerland.py +++ b/holidays/countries/switzerland.py @@ -21,105 +21,197 @@ 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=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 == 'JU': - self[date(year, JUN, 23)] = 'Fest der Unabhängigkeit' - - if self.prov == 'TI': - self[date(year, JUN, 29)] = 'Peter und Paul' + self[easter(year) + rd(days=49)] = "Pfingsten" + + 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 == "JU": + self[date(year, JUN, 23)] = "Fest der Unabhängigkeit" + + if self.prov == "TI": + self[date(year, JUN, 29)] = "Peter und Paul" if year >= 1291: - 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 == 'VD': + 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 == "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..f6b2e1329 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,9 @@ 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_arab_emirates.py b/holidays/countries/united_arab_emirates.py index ba68223b5..74e978af4 100644 --- a/holidays/countries/united_arab_emirates.py +++ b/holidays/countries/united_arab_emirates.py @@ -48,7 +48,7 @@ class UnitedArabEmirates(HolidayBase): # Python >= 3.6 def __init__(self, **kwargs): - self.country = 'AE' + self.country = "AE" HolidayBase.__init__(self, **kwargs) def _populate(self, year): @@ -57,7 +57,7 @@ def _populate(self, year): self[date(year, JAN, 1)] = "New Year's Day" # Commemoration Day, since 2015. - if (year >= 2015 and year < 2019): + if year >= 2015 and year < 2019: self[date(year, NOV, 30)] = "Commemoration Day" elif year >= 2019: self[date(year, DEC, 1)] = "Commemoration Day" @@ -72,27 +72,37 @@ def _populate(self, year): # Date is announced each year. Usually stretches along 3 or 4 days, # in some instances prepending/appending a day or two # before/after the official holiday. - dates_obs = {2017: [(JUN, 25)], 2018: [(JUN, 14)], 2019: [(JUN, 3)], - 2020: [(MAY, 24)]} + dates_obs = { + 2017: [(JUN, 25)], + 2018: [(JUN, 14)], + 2019: [(JUN, 3)], + 2020: [(MAY, 24)], + } fitr = "Eid al-Fitr" if year in dates_obs: for date_obs in dates_obs[year]: hol_date = date(year, *date_obs) self[hol_date] = fitr - self[hol_date + rd(days=1)] = '{} Holiday'.format(fitr) - self[hol_date + rd(days=2)] = '{} Holiday'.format(fitr) + self[hol_date + rd(days=1)] = "{} Holiday".format(fitr) + self[hol_date + rd(days=2)] = "{} Holiday".format(fitr) else: for date_obs in get_gre_date(year, 10, 1): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(fitr) - self[hol_date + rd(days=1)] =\ - '{} Holiday* (*estimated)'.format(fitr) - self[hol_date + rd(days=2)] =\ - '{} Holiday* (*estimated)'.format(fitr) + self[hol_date] = "{}* (*estimated)".format(fitr) + self[ + hol_date + rd(days=1) + ] = "{} Holiday* (*estimated)".format(fitr) + self[ + hol_date + rd(days=2) + ] = "{} Holiday* (*estimated)".format(fitr) # Arafat Day & Eid al-Adha - dates_obs = {2017: [(AUG, 31)], 2018: [(AUG, 20)], 2019: [(AUG, 10)], - 2020: [(JUL, 30)]} + dates_obs = { + 2017: [(AUG, 31)], + 2018: [(AUG, 20)], + 2019: [(AUG, 10)], + 2020: [(JUL, 30)], + } hajj = "Arafat (Hajj) Day" adha = "Eid al-Adha" if year in dates_obs: @@ -100,21 +110,27 @@ def _populate(self, year): hol_date = date(year, *date_obs) self[hol_date] = hajj self[hol_date + rd(days=1)] = adha - self[hol_date + rd(days=2)] = '{} Holiday'.format(adha) - self[hol_date + rd(days=3)] = '{} Holiday'.format(adha) + self[hol_date + rd(days=2)] = "{} Holiday".format(adha) + self[hol_date + rd(days=3)] = "{} Holiday".format(adha) else: for date_obs in get_gre_date(year, 12, 9): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(hajj) - self[hol_date + rd(days=1)] = '{}* (*estimated)'.format(adha) - self[hol_date + rd(days=2)] =\ - '{}* Holiday* (*estimated)'.format(adha) - self[hol_date + rd(days=3)] =\ - '{} Holiday* (*estimated)'.format(adha) + self[hol_date] = "{}* (*estimated)".format(hajj) + self[hol_date + rd(days=1)] = "{}* (*estimated)".format(adha) + self[ + hol_date + rd(days=2) + ] = "{}* Holiday* (*estimated)".format(adha) + self[ + hol_date + rd(days=3) + ] = "{} Holiday* (*estimated)".format(adha) # Islamic New Year - (hijari_year, 1, 1) - dates_obs = {2017: [(SEP, 22)], 2018: [(SEP, 11)], 2019: [(AUG, 31)], - 2020: [(AUG, 23)]} + dates_obs = { + 2017: [(SEP, 22)], + 2018: [(SEP, 11)], + 2019: [(AUG, 31)], + 2020: [(AUG, 23)], + } new_hijri_year = "Al Hijra - Islamic New Year" if year in dates_obs: for date_obs in dates_obs[year]: @@ -123,7 +139,7 @@ def _populate(self, year): else: for date_obs in get_gre_date(year, 1, 1): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(new_hijri_year) + self[hol_date] = "{}* (*estimated)".format(new_hijri_year) # Leilat al-Miraj - The Prophet's ascension (hijari_year, 7, 27) if year <= 2018: # starting from 2019 the UAE government removed this @@ -136,12 +152,15 @@ def _populate(self, year): else: for date_obs in get_gre_date(year, 7, 27): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(ascension) + self[hol_date] = "{}* (*estimated)".format(ascension) # Prophet Muhammad's Birthday - (hijari_year, 3, 12) if year <= 2019: # starting from 2020 the UAE government removed this - dates_obs = {2017: [(NOV, 30)], 2018: [(NOV, 19)], - 2019: [(NOV, 9)]} + dates_obs = { + 2017: [(NOV, 30)], + 2018: [(NOV, 19)], + 2019: [(NOV, 9)], + } mawlud = "Mawlud al-Nabi - Prophet Mohammad's Birthday" if year in dates_obs: for date_obs in dates_obs[year]: @@ -150,7 +169,7 @@ def _populate(self, year): else: for date_obs in get_gre_date(year, 3, 12): hol_date = date_obs - self[hol_date] = '{}* (*estimated)'.format(mawlud) + self[hol_date] = "{}* (*estimated)".format(mawlud) class AE(UnitedArabEmirates): diff --git a/holidays/countries/united_kingdom.py b/holidays/countries/united_kingdom.py index f5ad78015..1982160b9 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,47 @@ 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 +99,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 +107,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 @@ -175,7 +170,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: @@ -185,8 +180,9 @@ 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" elif year == 2022: @@ -206,35 +202,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 428eac781..173c92dcc 100644 --- a/holidays/countries/united_states.py +++ b/holidays/countries/united_states.py @@ -16,9 +16,20 @@ 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 +37,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 +109,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 +123,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,96 +155,101 @@ 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: + elif self.state == "ID" and year >= 2006: name = "Martin Luther King Jr. - Idaho Human Rights Day" self[date(year, JAN, 1) + rd(weekday=MO(+3))] = name # 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 +259,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 +287,67 @@ 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 +363,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 +376,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 +389,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 +402,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 +415,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 +438,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 +446,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 +459,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 +479,21 @@ 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 +505,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 +526,32 @@ def _populate(self, year): # American Indian Heritage Day # Family Day # New Mexico Presidents' Day - if (self.state in ('CA', '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 ('CA', 'DE', 'NH', 'NC', 'OK', 'WV'): + if ( + ( + self.state in ("CA", "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 ("CA", "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 +559,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 +576,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 +597,20 @@ 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..67dbb67eb 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,11 @@ 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 8143e4eb4..1c7081d58 100644 --- a/holidays/holiday_base.py +++ b/holidays/holiday_base.py @@ -20,21 +20,24 @@ 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 @@ -94,7 +97,7 @@ def __getitem__(self, key): ) 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 +107,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 +116,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) @@ -177,8 +176,9 @@ 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): @@ -187,15 +187,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) @@ -206,16 +209,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 9f6df874f..22c4c25db 100755 --- a/holidays/utils.py +++ b/holidays/utils.py @@ -5,18 +5,29 @@ 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 @@ -34,27 +45,36 @@ def get_gre_date(year, Hmonth, Hday): from hijri_converter import convert Hyear = convert.Gregorian(year, 1, 1).to_hijri().datetuple()[0] - gres = [convert.Hijri(y, Hmonth, Hday).to_gregorian() - for y in range(Hyear - 1, Hyear + 2)] - gre_dates = [date(*gre.datetuple()) - for gre in gres if gre.year == year] + gres = [ + convert.Hijri(y, Hmonth, Hday).to_gregorian() + for y in range(Hyear - 1, Hyear + 2) + ] + gre_dates = [ + date(*gre.datetuple()) for gre in gres if gre.year == year + ] return gre_dates except ImportError: import warnings from convertdate import islamic - 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("Islamic Holidays estimated using 'convertdate'" - " package.") - warnings.warn("For higher precision, install 'hijri-converter'" - " package: pip install -U hijri-converter") + warnings.warn( + "Islamic Holidays estimated using 'convertdate'" " package." + ) + warnings.warn( + "For higher precision, install 'hijri-converter'" + " package: pip install -U hijri-converter" + ) warnings.warn("(see https://hijri-converter.readthedocs.io/ )") Hyear = islamic.from_gregorian(year, 1, 1)[0] - gres = [islamic.to_gregorian(y, Hmonth, Hmonth) - for y in range(Hyear - 1, Hyear + 2)] + gres = [ + islamic.to_gregorian(y, Hmonth, Hmonth) + for y in range(Hyear - 1, Hyear + 2) + ] gre_dates = [date(*gre) for gre in gres if gre[0] == year] return gre_dates diff --git a/pyproject.toml b/pyproject.toml index 845901a54..6adc87b01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 79 -target-version = ['py27', 'py35', 'py36', 'py37', 'py38', 'py39'] +target-version = ['py27', 'py35', 'py36', 'py37', 'py38'] exclude = ''' /( \.eggs diff --git a/setup.py b/setup.py index 620e00290..85b5a29b9 100644 --- a/setup.py +++ b/setup.py @@ -11,52 +11,58 @@ import codecs import re + try: from setuptools import setup except ImportError: from distutils.core import setup -with codecs.open('holidays/__init__.py', 'r', 'utf-8') as fd: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with codecs.open("holidays/__init__.py", "r", "utf-8") as fd: + version = re.search( + r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE + ).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") setup( - name='holidays', + name="holidays", version=version, - 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=['holidays', 'holidays/countries'], - license='MIT', - description='Generate and work with holidays in Python', - long_description=codecs.open('README.rst', encoding='utf-8').read(), - install_requires=['python-dateutil', 'six', 'convertdate<=2.2.0', - 'korean_lunar_calendar'], - platforms='any', + 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=["holidays", "holidays/countries"], + license="MIT", + description="Generate and work with holidays in Python", + long_description=codecs.open("README.rst", encoding="utf-8").read(), + install_requires=[ + "python-dateutil", + "six", + "convertdate<=2.2.0", + "korean_lunar_calendar", + ], + 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 :: 3.9', - '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 :: 3.9", + "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/__init__.py b/tests/countries/__init__.py index 238a51ec6..d1e52689e 100644 --- a/tests/countries/__init__.py +++ b/tests/countries/__init__.py @@ -23,5 +23,3 @@ from flake8.api import legacy as flake8 import holidays - - diff --git a/tests/countries/test_argentina.py b/tests/countries/test_argentina.py index 168572d0c..c3cc2e0e1 100644 --- a/tests/countries/test_argentina.py +++ b/tests/countries/test_argentina.py @@ -175,4 +175,3 @@ def test_christmas(self): self.assertIn(dt, self.holidays) self.assertNotIn(dt + relativedelta(days=-1), self.holidays) self.assertNotIn(dt + relativedelta(days=+1), self.holidays) - diff --git a/tests/countries/test_australia.py b/tests/countries/test_australia.py index a4dbd274a..3f3b0f348 100644 --- a/tests/countries/test_australia.py +++ b/tests/countries/test_australia.py @@ -47,7 +47,8 @@ def test_new_years(self): def test_australia_day(self): for year, day in enumerate( - [26, 26, 28, 27, 26, 26, 26, 26, 28, 27, 26], 2011 # 2011-15 # 2016-21 + [26, 26, 28, 27, 26, 26, 26, 26, 28, 27, 26], + 2011, # 2011-15 # 2016-21 ): jan26 = date(year, 1, 26) dt = date(year, 1, day) @@ -57,7 +58,9 @@ def test_australia_day(self): self.assertEqual(self.holidays[dt][:10], "Australia ") for state in holidays.AU.PROVINCES: self.assertIn(jan26, self.state_hols[state], (state, dt)) - self.assertEqual(self.state_hols[state][jan26], "Australia Day") + self.assertEqual( + self.state_hols[state][jan26], "Australia Day" + ) self.assertIn(dt, self.state_hols[state], (state, dt)) self.assertEqual(self.state_hols[state][dt][:10], "Australia ") self.assertNotIn(date(2016, 1, 27), self.holidays) @@ -144,7 +147,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") @@ -183,7 +197,9 @@ def test_western_australia_day(self): for year, day in enumerate([1, 6, 5], 2015): dt = date(year, 6, day) self.assertIn(dt, self.state_hols["WA"], dt) - self.assertEqual(self.state_hols["WA"][dt], "Western Australia Day") + self.assertEqual( + self.state_hols["WA"][dt], "Western Australia Day" + ) def test_adelaide_cup(self): for dt in [date(2015, 3, 9), date(2016, 3, 14), date(2017, 3, 13)]: @@ -222,7 +238,12 @@ def test_queens_birthday(self): qld_dates = other_states[:-3] qld_dates.remove(date(2012, 6, 11)) qld_dates.extend( - [date(2012, 10, 1), date(2016, 10, 3), date(2017, 10, 2), date(2018, 10, 1)] + [ + date(2012, 10, 1), + date(2016, 10, 3), + date(2017, 10, 2), + date(2018, 10, 1), + ] ) for dt in qld_dates: self.assertIn(dt, self.state_hols["QLD"], dt) @@ -249,7 +270,9 @@ def test_family_and_community_day(self): date(2017, 9, 25), ]: self.assertIn(dt, self.state_hols["ACT"], dt) - self.assertEqual(self.state_hols["ACT"][dt], "Family & Community Day") + self.assertEqual( + self.state_hols["ACT"][dt], "Family & Community Day" + ) def test_reconciliation_day(self): for dt in [date(2018, 5, 28), date(2019, 5, 27), date(2020, 6, 1)]: @@ -275,7 +298,9 @@ def test_royal_queensland_show(self): for year, day in enumerate([15, 14, 14, 11, 10, 16], 2018): dt = date(year, 8, day) self.assertIn(dt, self.state_hols["QLD"], dt) - self.assertEqual(self.state_hols["QLD"][dt], "The Royal Queensland Show") + self.assertEqual( + self.state_hols["QLD"][dt], "The Royal Queensland Show" + ) def test_christmas_day(self): self.holidays.observed = False @@ -288,7 +313,9 @@ def test_christmas_day(self): self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" ) self.holidays.observed = True - self.assertEqual(self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)") + self.assertEqual( + self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)" + ) for year, day in enumerate( [ 25, @@ -362,7 +389,8 @@ def test_boxing_day(self): def test_all_holidays(self): au = sum( - holidays.AU(years=[1957, 2012, 2015], prov=p) for p in holidays.AU.PROVINCES + 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 = [ diff --git a/tests/countries/test_bangladesh.py b/tests/countries/test_bangladesh.py index c4593f00d..c5ef678dd 100644 --- a/tests/countries/test_bangladesh.py +++ b/tests/countries/test_bangladesh.py @@ -37,4 +37,3 @@ def test_2020(self): self.assertIn(date(2020, 5, 1), self.holidays) self.assertIn(date(2020, 8, 15), self.holidays) self.assertIn(date(2020, 12, 16), self.holidays) - diff --git a/tests/countries/test_belgium.py b/tests/countries/test_belgium.py index 09891460b..0b131673d 100644 --- a/tests/countries/test_belgium.py +++ b/tests/countries/test_belgium.py @@ -43,4 +43,3 @@ def test_2017(self): self.assertIn(date(2017, 11, 1), self.holidays) self.assertIn(date(2017, 11, 11), self.holidays) self.assertIn(date(2017, 12, 25), self.holidays) - diff --git a/tests/countries/test_brazil.py b/tests/countries/test_brazil.py index d55d30db6..d968868a9 100644 --- a/tests/countries/test_brazil.py +++ b/tests/countries/test_brazil.py @@ -46,17 +46,25 @@ def test_BR_holidays(self): self.assertIn("2018-04-21", self.holidays) self.assertEqual(self.holidays[date(2018, 4, 21)], "Tiradentes") self.assertIn("2018-05-01", self.holidays) - self.assertEqual(self.holidays[date(2018, 5, 1)], "Dia Mundial do Trabalho") + self.assertEqual( + self.holidays[date(2018, 5, 1)], "Dia Mundial do Trabalho" + ) self.assertIn("2018-05-31", self.holidays) self.assertEqual(self.holidays[date(2018, 5, 31)], "Corpus Christi") self.assertIn("2018-09-07", self.holidays) - self.assertEqual(self.holidays[date(2018, 9, 7)], "Independência do Brasil") + self.assertEqual( + self.holidays[date(2018, 9, 7)], "Independência do Brasil" + ) self.assertIn("2018-10-12", self.holidays) - self.assertEqual(self.holidays[date(2018, 10, 12)], "Nossa Senhora Aparecida") + self.assertEqual( + self.holidays[date(2018, 10, 12)], "Nossa Senhora Aparecida" + ) self.assertIn("2018-11-02", self.holidays) self.assertEqual(self.holidays[date(2018, 11, 2)], "Finados") self.assertIn("2018-11-15", self.holidays) - self.assertEqual(self.holidays[date(2018, 11, 15)], "Proclamação da República") + self.assertEqual( + self.holidays[date(2018, 11, 15)], "Proclamação da República" + ) self.assertIn("2018-12-25", self.holidays) self.assertEqual(self.holidays[date(2018, 12, 25)], "Natal") @@ -70,7 +78,8 @@ def test_AC_holidays(self): 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" + ac_holidays[date(2018, 11, 17)], + "Assinatura do Tratado de Petrópolis", ) def test_AL_holidays(self): @@ -114,7 +123,9 @@ def test_AM_holidays(self): def test_BA_holidays(self): ba_holidays = holidays.BR(state="BA") self.assertIn("2018-07-02", ba_holidays) - self.assertEqual(ba_holidays[date(2018, 7, 2)], "Independência da Bahia") + self.assertEqual( + ba_holidays[date(2018, 7, 2)], "Independência da Bahia" + ) def test_CE_holidays(self): ce_holidays = holidays.BR(state="CE") @@ -135,12 +146,16 @@ def test_DF_holidays(self): def test_ES_holidays(self): es_holidays = holidays.BR(state="ES") self.assertIn("2018-10-28", es_holidays) - self.assertEqual(es_holidays[date(2018, 10, 28)], "Dia do Servidor Público") + self.assertEqual( + es_holidays[date(2018, 10, 28)], "Dia do Servidor Público" + ) def test_GO_holidays(self): go_holidays = holidays.BR(state="GO") self.assertIn("2018-10-28", go_holidays) - self.assertEqual(go_holidays[date(2018, 10, 28)], "Dia do Servidor Público") + self.assertEqual( + go_holidays[date(2018, 10, 28)], "Dia do Servidor Público" + ) def test_MA_holidays(self): ma_holidays = holidays.BR(state="MA") @@ -167,7 +182,9 @@ def test_MS_holidays(self): def test_MG_holidays(self): mg_holidays = holidays.BR(state="MG") self.assertIn("2018-04-21", mg_holidays) - self.assertEqual(mg_holidays[date(2018, 4, 21)], "Data Magna de MG, Tiradentes") + self.assertEqual( + mg_holidays[date(2018, 4, 21)], "Data Magna de MG, Tiradentes" + ) def test_PA_holidays(self): pa_holidays = holidays.BR(state="PA") @@ -186,7 +203,8 @@ 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)" + 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") @@ -194,21 +212,27 @@ def test_PE_holidays(self): def test_PI_holidays(self): pi_holidays = holidays.BR(state="PI") self.assertIn("2018-03-13", pi_holidays) - self.assertEqual(pi_holidays[date(2018, 3, 13)], "Dia da Batalha do Jenipapo") + self.assertEqual( + pi_holidays[date(2018, 3, 13)], "Dia da Batalha do Jenipapo" + ) self.assertIn("2018-10-19", pi_holidays) self.assertEqual(pi_holidays[date(2018, 10, 19)], "Dia do Piauí") def test_PR_holidays(self): pr_holidays = holidays.BR(state="PR") self.assertIn("2018-12-19", pr_holidays) - self.assertEqual(pr_holidays[date(2018, 12, 19)], "Emancipação do Paraná") + self.assertEqual( + pr_holidays[date(2018, 12, 19)], "Emancipação do Paraná" + ) def test_RJ_holidays(self): rj_holidays = holidays.BR(state="RJ") self.assertIn("2018-04-23", rj_holidays) self.assertEqual(rj_holidays[date(2018, 4, 23)], "Dia de São Jorge") self.assertIn("2018-10-28", rj_holidays) - self.assertEqual(rj_holidays[date(2018, 10, 28)], "Dia do Funcionário Público") + self.assertEqual( + rj_holidays[date(2018, 10, 28)], "Dia do Funcionário Público" + ) self.assertIn("2018-11-20", rj_holidays) self.assertEqual(rj_holidays[date(2018, 11, 20)], "Zumbi dos Palmares") @@ -217,12 +241,16 @@ def test_RN_holidays(self): self.assertIn("2018-06-29", rn_holidays) self.assertEqual(rn_holidays[date(2018, 6, 29)], "Dia de São Pedro") self.assertIn("2018-10-03", rn_holidays) - self.assertEqual(rn_holidays[date(2018, 10, 3)], "Mártires de Cunhaú e Uruaçuu") + self.assertEqual( + rn_holidays[date(2018, 10, 3)], "Mártires de Cunhaú e Uruaçuu" + ) def test_RS_holidays(self): rs_holidays = holidays.BR(state="RS") self.assertIn("2018-09-20", rs_holidays) - self.assertEqual(rs_holidays[date(2018, 9, 20)], "Revolução Farroupilha") + self.assertEqual( + rs_holidays[date(2018, 9, 20)], "Revolução Farroupilha" + ) def test_RO_holidays(self): ro_holidays = holidays.BR(state="RO") @@ -240,20 +268,24 @@ def test_SC_holidays(self): sc_holidays = holidays.BR(state="SC") self.assertIn("2018-08-11", sc_holidays) self.assertEqual( - sc_holidays[date(2018, 8, 11)], "Criação da capitania, separando-se de SP" + sc_holidays[date(2018, 8, 11)], + "Criação da capitania, separando-se de SP", ) 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" + sp_holidays[date(2018, 7, 9)], + "Revolução Constitucionalista de 1932", ) def test_SE_holidays(self): se_holidays = holidays.BR(state="SE") self.assertIn("2018-07-08", se_holidays) - self.assertEqual(se_holidays[date(2018, 7, 8)], "Autonomia política de Sergipe") + self.assertEqual( + se_holidays[date(2018, 7, 8)], "Autonomia política de Sergipe" + ) def test_TO_holidays(self): to_holidays = holidays.BR(state="TO") @@ -262,6 +294,10 @@ def test_TO_holidays(self): 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.assertEqual( + to_holidays[date(2018, 9, 8)], "Nossa Senhora da Natividade" + ) self.assertIn("2018-10-05", to_holidays) - self.assertEqual(to_holidays[date(2018, 10, 5)], "Criação de Tocantins") + self.assertEqual( + to_holidays[date(2018, 10, 5)], "Criação de Tocantins" + ) diff --git a/tests/countries/test_bulgaria.py b/tests/countries/test_bulgaria.py index 9e62f1047..e14005c44 100644 --- a/tests/countries/test_bulgaria.py +++ b/tests/countries/test_bulgaria.py @@ -25,7 +25,6 @@ import holidays - class TestBulgaria(unittest.TestCase): def setUp(self): self.holidays = holidays.Bulgaria() diff --git a/tests/countries/test_burundi.py b/tests/countries/test_burundi.py index 91118b40b..127841c17 100644 --- a/tests/countries/test_burundi.py +++ b/tests/countries/test_burundi.py @@ -42,18 +42,26 @@ def test_labour_day(self): self.assertIn("Labour Day (Observed)", self.holidays[date(2022, 5, 2)]) 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)] + "Prince Louis Rwagasore Day", self.holidays[date(2017, 10, 13)] + ) + 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)]) + 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)] + "President Ndadaye's Day", self.holidays[date(2017, 10, 21)] + ) + self.assertIn( + "President Ndadaye's Day (Observed)", + self.holidays[date(2018, 10, 22)], ) def test_independence_day(self): @@ -65,7 +73,9 @@ def test_independence_day(self): # in 1958 it's Eid Al Adha (as estimated by convertdate) self.assertNotIn(date(year, 7, 1), self.holidays) - self.assertIn("Independence Day (Observed)", self.holidays[date(2018, 7, 2)]) + self.assertIn( + "Independence Day (Observed)", self.holidays[date(2018, 7, 2)] + ) def test_ascension_day(self): self.assertIn("Ascension Day", self.holidays[date(2020, 5, 21)]) @@ -75,7 +85,9 @@ def test_assumption_Day(self): def test_all_saints_Day(self): self.assertIn("All Saints' Day", self.holidays[date(2020, 11, 1)]) - self.assertIn("All Saints' Day (Observed)", self.holidays[date(2020, 11, 2)]) + self.assertIn( + "All Saints' Day (Observed)", self.holidays[date(2020, 11, 2)] + ) def test_christmas_Day(self): self.assertIn("Christmas Day", self.holidays[date(2020, 12, 25)]) @@ -90,4 +102,3 @@ def test_eid_al_adha(self): # eid Al Adha self.assertIn(date(2020, 7, 31), self.holidays) self.assertIn(date(2020, 7, 31), self.holidays) - diff --git a/tests/countries/test_canada.py b/tests/countries/test_canada.py index a561518ad..34ebaaeb8 100644 --- a/tests/countries/test_canada.py +++ b/tests/countries/test_canada.py @@ -346,7 +346,9 @@ def test_christmas_day(self): ) self.holidays.observed = True self.assertIn(date(2010, 12, 24), self.holidays) - self.assertEqual(self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)") + self.assertEqual( + self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" + ) def test_boxing_day(self): for year in range(1900, 2100): diff --git a/tests/countries/test_chile.py b/tests/countries/test_chile.py index d17a8e8e7..e3c7b7f1f 100644 --- a/tests/countries/test_chile.py +++ b/tests/countries/test_chile.py @@ -104,4 +104,3 @@ def test_2024(self): def test_2029(self): self.assertIn(date(2029, 7, 2), self.holidays) self.assertIn(date(2029, 10, 15), self.holidays) - diff --git a/tests/countries/test_egypt.py b/tests/countries/test_egypt.py index b33df9369..53960df80 100644 --- a/tests/countries/test_egypt.py +++ b/tests/countries/test_egypt.py @@ -78,4 +78,3 @@ def test_hijri_based(self): self.assertIn(date(2010, 11, 15), self.holidays) # muhammad's birthday self.assertIn(date(2010, 2, 26), self.holidays) - diff --git a/tests/countries/test_estonia.py b/tests/countries/test_estonia.py index 3fe7b1a41..90d6378da 100644 --- a/tests/countries/test_estonia.py +++ b/tests/countries/test_estonia.py @@ -128,7 +128,9 @@ def test_province_specific_days(self): prov in ["ML", "MC", "PV", "VC"], ) elif year == 2017: - self.assertEqual(date(year, 3, 19) in prov_holidays, prov in ["PV"]) + self.assertEqual( + date(year, 3, 19) in prov_holidays, prov in ["PV"] + ) elif 2018 <= year <= 2019: self.assertEqual( date(year, 3, 19) in prov_holidays, @@ -140,11 +142,13 @@ def test_province_specific_days(self): prov in ["CM", "GA", "MC", "NC", "PV", "VC"], ) self.assertEqual( - date(year, 6, 24) in prov_holidays, prov in ["CT", "GA", "VC"] + 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 + date(year, *fest_day) in prov_holidays, + prov in fest_prov, ) @@ -170,7 +174,9 @@ def test_good_friday(self): def test_easter_sunday(self): test_date = date(2019, 4, 21) - self.assertEqual(self.holidays.get(test_date), "ülestõusmispühade 1. püha") + self.assertEqual( + self.holidays.get(test_date), "ülestõusmispühade 1. püha" + ) self.assertIn(test_date, self.holidays) def test_spring_day(self): @@ -212,4 +218,3 @@ def test_boxing_day(self): test_date = date(self.cur_date.year, 12, 26) self.assertEqual(self.holidays.get(test_date), "teine jõulupüha") self.assertIn(test_date, self.holidays) - diff --git a/tests/countries/test_finland.py b/tests/countries/test_finland.py index c647babf8..d52b0a0e1 100644 --- a/tests/countries/test_finland.py +++ b/tests/countries/test_finland.py @@ -72,4 +72,3 @@ def test_Juhannus(self): self.assertIn(date(2018, 6, 22), self.holidays) self.assertEqual(self.holidays[date(2018, 6, 22)], "Juhannusaatto") self.assertEqual(self.holidays[date(2018, 6, 23)], "Juhannuspäivä") - diff --git a/tests/countries/test_france.py b/tests/countries/test_france.py index 94e8a2c83..ffbd1e30f 100644 --- a/tests/countries/test_france.py +++ b/tests/countries/test_france.py @@ -43,7 +43,8 @@ def test_2017(self): def test_others(self): self.assertEqual( - self.holidays[date(1948, 5, 1)], "Fête du Travail et de la Concorde sociale" + self.holidays[date(1948, 5, 1)], + "Fête du Travail et de la Concorde sociale", ) def test_alsace_moselle(self): @@ -88,4 +89,3 @@ def test_saint_barthelemy(self): def test_la_reunion(self): am_holidays = self.prov_holidays["La Réunion"] self.assertIn(date(2017, 12, 20), am_holidays) - diff --git a/tests/countries/test_germany.py b/tests/countries/test_germany.py index b46771098..949171694 100644 --- a/tests/countries/test_germany.py +++ b/tests/countries/test_germany.py @@ -33,11 +33,15 @@ def setUp(self): } def test_no_data_before_1990(self): - de_1989 = sum(holidays.DE(years=[1989], prov=p) for p in holidays.DE.PROVINCES) + de_1989 = sum( + holidays.DE(years=[1989], prov=p) for p in holidays.DE.PROVINCES + ) self.assertEqual(len(de_1989), 0) def test_all_holidays_present(self): - de_2015 = sum(holidays.DE(years=[2015], prov=p) for p in holidays.DE.PROVINCES) + de_2015 = sum( + holidays.DE(years=[2015], prov=p) for p in holidays.DE.PROVINCES + ) in_2015 = sum((de_2015.get_list(key) for key in de_2015), []) all_de = [ "Neujahr", @@ -324,7 +328,9 @@ def test_internationaler_frauentag(self): prov_that_have = {"BE"} prov_that_dont = set(holidays.DE.PROVINCES) - prov_that_have - for province, year in product(holidays.DE.PROVINCES, range(1991, 2018)): + for province, year in product( + holidays.DE.PROVINCES, range(1991, 2018) + ): self.assertNotIn(date(year, 3, 8), self.prov_hols[province]) for province, year in product(prov_that_have, range(2019, 2050)): self.assertIn(date(year, 3, 8), self.prov_hols[province]) diff --git a/tests/countries/test_greece.py b/tests/countries/test_greece.py index b8b33e28f..2c6cd6f68 100644 --- a/tests/countries/test_greece.py +++ b/tests/countries/test_greece.py @@ -35,14 +35,21 @@ def test_fixed_holidays(self): fdays = ( (date(y, 1, 1), "Πρωτοχρονιά [New Year's Day]"), (date(y, 1, 6), "Θεοφάνεια [Epiphany]"), - (date(y, 3, 25), "Εικοστή Πέμπτη Μαρτίου " + "[Independence Day]"), + ( + date(y, 3, 25), + "Εικοστή Πέμπτη Μαρτίου " + "[Independence Day]", + ), (date(y, 5, 1), "Εργατική Πρωτομαγιά [Labour day]"), - (date(y, 8, 15), "Κοίμηση της Θεοτόκου " + "[Assumption of Mary]"), + ( + date(y, 8, 15), + "Κοίμηση της Θεοτόκου " + "[Assumption of Mary]", + ), (date(y, 10, 28), "Ημέρα του Όχι [Ochi Day]"), (date(y, 12, 25), "Χριστούγεννα [Christmas]"), ( date(y, 12, 26), - "Επόμενη ημέρα των Χριστουγέννων " + "[Day after Christmas]", + "Επόμενη ημέρα των Χριστουγέννων " + + "[Day after Christmas]", ), ) @@ -78,7 +85,9 @@ def test_gr_easter_monday(self): for d in checkdates: self.assertIn(d, self.gr_holidays) - self.assertIn("Δευτέρα του Πάσχα [Easter Monday]", self.gr_holidays[d]) + self.assertIn( + "Δευτέρα του Πάσχα [Easter Monday]", self.gr_holidays[d] + ) def test_gr_monday_of_the_holy_spirit(self): checkdates = ( diff --git a/tests/countries/test_hongkong.py b/tests/countries/test_hongkong.py index 21f767572..e04b96b14 100644 --- a/tests/countries/test_hongkong.py +++ b/tests/countries/test_hongkong.py @@ -117,7 +117,8 @@ def test_lunar_new_year(self): (2020, 1, 27), ]: self.assertEqual( - self.holidays[date(year, month, day)], "The third day of Lunar New Year" + self.holidays[date(year, month, day)], + "The third day of Lunar New Year", ) for year, month, day in [ @@ -176,7 +177,9 @@ def test_easter(self): (2019, 4, 19), (2020, 4, 10), ]: - self.assertEqual(self.holidays[date(year, month, day)], "Good Friday") + self.assertEqual( + self.holidays[date(year, month, day)], "Good Friday" + ) for year, month, day in [ (2019, 4, 20), @@ -196,7 +199,8 @@ def test_easter(self): (2014, 4, 19), ]: self.assertEqual( - self.holidays[date(year, month, day)], "The day following Good Friday" + self.holidays[date(year, month, day)], + "The day following Good Friday", ) for year, month, day in [ @@ -214,7 +218,9 @@ def test_easter(self): (2019, 4, 22), (2020, 4, 13), ]: - self.assertEqual(self.holidays[date(year, month, day)], "Easter Monday") + self.assertEqual( + self.holidays[date(year, month, day)], "Easter Monday" + ) name = "The day following Easter Monday" self.assertEqual(self.holidays[date(2010, 4, 6)], name) @@ -264,7 +270,8 @@ def test_tuen_ng_festival(self): ) self.assertEqual( - self.holidays[date(2008, 6, 9)], "The day " + "following Tuen Ng Festival" + self.holidays[date(2008, 6, 9)], + "The day " + "following Tuen Ng Festival", ) def test_hksar_day(self): @@ -284,7 +291,9 @@ def test_hksar_day(self): ]: self.assertEqual( self.holidays[date(year, 7, 1)], - "Hong Kong " + "Special Administrative Region Establishment " + "Day", + "Hong Kong " + + "Special Administrative Region Establishment " + + "Day", ) name = ( @@ -318,7 +327,8 @@ def test_mid_autumn_festival(self): ) self.assertEqual( - self.holidays[date(2009, 10, 3)], "Chinese " + "Mid-Autumn Festival" + self.holidays[date(2009, 10, 3)], + "Chinese " + "Mid-Autumn Festival", ) def test_national_day(self): @@ -359,7 +369,8 @@ def test_chung_yeung_festival(self): (2019, 10, 7), ]: self.assertEqual( - self.holidays[date(year, month, day)], "Chung " + "Yeung Festival" + self.holidays[date(year, month, day)], + "Chung " + "Yeung Festival", ) name = "The day following Chung Yeung Festival" @@ -383,7 +394,9 @@ def test_christmas_day(self): 2019, 2020, ]: - self.assertEqual(self.holidays[date(year, 12, 25)], "Christmas " + "Day") + self.assertEqual( + self.holidays[date(year, 12, 25)], "Christmas " + "Day" + ) name = "The first weekday after Christmas Day" for year in range(2006, 2010): diff --git a/tests/countries/test_hungary.py b/tests/countries/test_hungary.py index 4365eb01f..c3d147813 100644 --- a/tests/countries/test_hungary.py +++ b/tests/countries/test_hungary.py @@ -45,7 +45,9 @@ def test_holidays_during_communism(self): def test_foundation_day_renamed_during_communism(self): for year in range(1950, 1990): - self.assertEqual(self.holidays[date(year, 8, 20)], "A kenyér ünnepe") + self.assertEqual( + self.holidays[date(year, 8, 20)], "A kenyér ünnepe" + ) def test_christian_holidays_2nd_day_was_not_held_in_1955(self): hu_1955 = holidays.Hungary(years=[1955]) diff --git a/tests/countries/test_iceland.py b/tests/countries/test_iceland.py index 1371b192f..676e0b5a9 100644 --- a/tests/countries/test_iceland.py +++ b/tests/countries/test_iceland.py @@ -47,7 +47,9 @@ def test_first_day_of_summer(self): def test_commerce_day(self): test_date = date(2019, 8, 5) - self.assertEqual(self.holidays.get(test_date), "Frídagur verslunarmanna") + self.assertEqual( + self.holidays.get(test_date), "Frídagur verslunarmanna" + ) self.assertIn(test_date, self.holidays) def test_holy_friday(self): diff --git a/tests/countries/test_israel.py b/tests/countries/test_israel.py index 1ce1499e5..d2eb8967d 100644 --- a/tests/countries/test_israel.py +++ b/tests/countries/test_israel.py @@ -37,25 +37,39 @@ def _test_observed_holidays(self, holiday_name): # Postponed il_holidays = holidays.IL(years=[2017], observed=True) - official_memorial_day = date(2017, 4, 30) + relativedelta(days=days_delta) - observed_memorial_day = date(2017, 5, 1) + relativedelta(days=days_delta) + official_memorial_day = date(2017, 4, 30) + relativedelta( + days=days_delta + ) + observed_memorial_day = date(2017, 5, 1) + relativedelta( + days=days_delta + ) self.assertIn(official_memorial_day, il_holidays) self.assertIn(holiday_name, il_holidays[official_memorial_day]) self.assertIn(observed_memorial_day, il_holidays) - self.assertIn(holiday_name + " (Observed)", il_holidays[observed_memorial_day]) + self.assertIn( + holiday_name + " (Observed)", il_holidays[observed_memorial_day] + ) # Earlier il_holidays = holidays.IL(years=[2018], observed=True) - official_memorial_day = date(2018, 4, 19) + relativedelta(days=days_delta) - observed_memorial_day = date(2018, 4, 18) + relativedelta(days=days_delta) + official_memorial_day = date(2018, 4, 19) + relativedelta( + days=days_delta + ) + observed_memorial_day = date(2018, 4, 18) + relativedelta( + days=days_delta + ) self.assertIn(official_memorial_day, il_holidays) self.assertIn(holiday_name, il_holidays[official_memorial_day]) self.assertIn(observed_memorial_day, il_holidays) - self.assertIn(holiday_name + " (Observed)", il_holidays[observed_memorial_day]) + self.assertIn( + holiday_name + " (Observed)", il_holidays[observed_memorial_day] + ) # On time il_holidays = holidays.IL(years=[2020], observed=True) - official_memorial_day = date(2020, 4, 28) + relativedelta(days=days_delta) + official_memorial_day = date(2020, 4, 28) + relativedelta( + days=days_delta + ) self.assertIn(official_memorial_day, il_holidays) self.assertIn(holiday_name, il_holidays[official_memorial_day]) diff --git a/tests/countries/test_korea.py b/tests/countries/test_korea.py index 7578ea87a..e0652767d 100644 --- a/tests/countries/test_korea.py +++ b/tests/countries/test_korea.py @@ -31,7 +31,9 @@ def setUp(self): def test_common(self): holidaysNoObserved = holidays.KR(observed=False) - self.assertEqual(holidaysNoObserved[date(2019, 1, 1)], "New Year's Day") + self.assertEqual( + holidaysNoObserved[date(2019, 1, 1)], "New Year's Day" + ) self.assertNotIn(date(1582, 10, 2), self.holidays) self.assertNotIn(date(1582, 11, 14), self.holidays) @@ -125,7 +127,8 @@ def test_independence_movement_day(self): (2020, 3, 1), ]: self.assertEqual( - self.holidays[date(year, month, day)], "Independence Movement Day" + self.holidays[date(year, month, day)], + "Independence Movement Day", ) def test_tree_planting_day(self): @@ -139,7 +142,9 @@ def test_tree_planting_day(self): (2000, 4, 5), (2007, 4, 5), ]: - self.assertEqual(self.holidays[date(year, month, day)], "Tree Planting Day") + self.assertEqual( + self.holidays[date(year, month, day)], "Tree Planting Day" + ) def test_childrens_day(self): for year, month, day in [ @@ -148,7 +153,9 @@ def test_childrens_day(self): (2017, 5, 5), (2018, 5, 5), ]: - self.assertEqual(self.holidays[date(year, month, day)], "Children's Day") + self.assertEqual( + self.holidays[date(year, month, day)], "Children's Day" + ) for year, month, day in [(2018, 5, 7), (2019, 5, 6)]: self.assertEqual( @@ -232,13 +239,17 @@ def test_memorial_day(self): def test_constitution_day(self): for year in range(1948, 2007): - self.assertEqual(self.holidays[date(year, 7, 17)], "Constitution Day") + self.assertEqual( + self.holidays[date(year, 7, 17)], "Constitution Day" + ) self.assertNotIn(date(2008, 7, 17), self.holidays) self.assertNotIn(date(1947, 7, 17), self.holidays) def test_liberation_day(self): for year in range(1945, 2020): - self.assertEqual(self.holidays[date(year, 8, 15)], "Liberation Day") + self.assertEqual( + self.holidays[date(year, 8, 15)], "Liberation Day" + ) def test_chuseok(self): for year, month, day in [ @@ -264,12 +275,14 @@ def test_chuseok(self): (2030, 9, 11), ]: self.assertEqual( - self.holidays[date(year, month, day)], "The day preceding of Chuseok" + 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)] + "The day preceding of Chuseok", + self.holidays[date(year, month, day)], ) for year, month, day in [ @@ -326,7 +339,8 @@ def test_chuseok(self): (2030, 9, 13), ]: self.assertEqual( - self.holidays[date(year, month, day)], "The second day of Chuseok" + self.holidays[date(year, month, day)], + "The second day of Chuseok", ) for year, month, day in [ @@ -338,12 +352,24 @@ def test_chuseok(self): (2029, 9, 24), ]: self.assertEqual( - self.holidays[date(year, month, day)], "Alternative holiday of Chuseok" + self.holidays[date(year, month, day)], + "Alternative holiday of Chuseok", ) 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]: + if year in [ + 1952, + 1963, + 1971, + 1990, + 2009, + 2017, + 2028, + 2036, + 2039, + 2047, + ]: self.assertIn( "National Foundation Day", self.holidays[date(year, 10, 3)] ) @@ -358,7 +384,9 @@ def test_hangeul_day(self): def test_christmas_day(self): for year in range(1948, 2050): - self.assertEqual(self.holidays[date(year, 12, 25)], "Christmas Day") + self.assertEqual( + self.holidays[date(year, 12, 25)], "Christmas Day" + ) def test_years_range(self): self.holidays = holidays.KR(years=range(2006, 2021)) diff --git a/tests/countries/test_latvia.py b/tests/countries/test_latvia.py index 92009183d..b666b6eb3 100644 --- a/tests/countries/test_latvia.py +++ b/tests/countries/test_latvia.py @@ -45,4 +45,3 @@ def test_2020(self): self.assertIn(date(2020, 12, 25), self.holidays) self.assertIn(date(2020, 12, 26), self.holidays) self.assertIn(date(2020, 12, 31), self.holidays) - diff --git a/tests/countries/test_lithuania.py b/tests/countries/test_lithuania.py index 315a947d3..fdb113adb 100644 --- a/tests/countries/test_lithuania.py +++ b/tests/countries/test_lithuania.py @@ -82,4 +82,3 @@ def test_fathers_day(self): def test_day_of_dew(self): self.assertNotIn(date(2002, 6, 24), self.holidays) self.assertIn(date(2020, 6, 24), self.holidays) - diff --git a/tests/countries/test_malawi.py b/tests/countries/test_malawi.py index 12ab6f5e0..db8e9700b 100644 --- a/tests/countries/test_malawi.py +++ b/tests/countries/test_malawi.py @@ -50,4 +50,3 @@ def test_static(self): def test_not_holiday(self): self.assertNotIn("2016-12-28", self.holidays) self.assertNotIn("2015-03-02", self.holidays) - diff --git a/tests/countries/test_mexico.py b/tests/countries/test_mexico.py index 0699af914..34dd69615 100644 --- a/tests/countries/test_mexico.py +++ b/tests/countries/test_mexico.py @@ -25,8 +25,6 @@ import holidays - - class TestMX(unittest.TestCase): def setUp(self): self.holidays = holidays.MX(observed=False) diff --git a/tests/countries/test_netherlands.py b/tests/countries/test_netherlands.py index 29a4d955a..10184c934 100644 --- a/tests/countries/test_netherlands.py +++ b/tests/countries/test_netherlands.py @@ -25,7 +25,6 @@ import holidays - class TestNetherlands(unittest.TestCase): def setUp(self): self.holidays = holidays.NL() diff --git a/tests/countries/test_new_zealand.py b/tests/countries/test_new_zealand.py index 62f8a273d..fe9eeb07e 100644 --- a/tests/countries/test_new_zealand.py +++ b/tests/countries/test_new_zealand.py @@ -297,7 +297,9 @@ def test_christmas_day(self): self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" ) self.holidays.observed = True - self.assertEqual(self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)") + self.assertEqual( + self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)" + ) for year, day in enumerate( [ 25, @@ -495,7 +497,9 @@ def test_wellington_anniversary_day(self): ): dt = date(year, 1, day) self.assertIn(dt, wgn_holidays, dt) - self.assertEqual(wgn_holidays[dt], "Wellington Anniversary Day", dt) + self.assertEqual( + wgn_holidays[dt], "Wellington Anniversary Day", dt + ) def test_marlborough_anniversary_day(self): mbh_holidays = holidays.NZ(prov="Marlborough") @@ -527,7 +531,9 @@ def test_marlborough_anniversary_day(self): ): dt = date(year, 11 if day < 9 else 10, day) self.assertIn(dt, mbh_holidays, dt) - self.assertEqual(mbh_holidays[dt], "Marlborough Anniversary Day", dt) + self.assertEqual( + mbh_holidays[dt], "Marlborough Anniversary Day", dt + ) def test_nelson_anniversary_day(self): nsn_holidays = holidays.NZ(prov="Nelson") @@ -591,7 +597,9 @@ def test_canterbury_anniversary_day(self): ): dt = date(year, 11, day) self.assertIn(dt, can_holidays, dt) - self.assertEqual(can_holidays[dt], "Canterbury Anniversary Day", dt) + self.assertEqual( + can_holidays[dt], "Canterbury Anniversary Day", dt + ) def test_south_canterbury_anniversary_day(self): stc_holidays = holidays.NZ(prov="South Canterbury") @@ -623,7 +631,9 @@ def test_south_canterbury_anniversary_day(self): ): dt = date(year, 9, day) self.assertIn(dt, stc_holidays, dt) - self.assertEqual(stc_holidays[dt], "South Canterbury Anniversary Day", dt) + self.assertEqual( + stc_holidays[dt], "South Canterbury Anniversary Day", dt + ) def test_westland_anniversary_day(self): wtc_holidays = holidays.NZ(prov="Westland") @@ -692,7 +702,8 @@ def test_otago_anniversary_day(self): def test_southland_anniversary_day(self): stl_holidays = holidays.NZ(prov="Southland") for year, day in enumerate( - [15, 14, 20, 19, 17, 16, 15, 14, 19, 18, 17], 2001 # 2001-05 # 2006-11 + [15, 14, 20, 19, 17, 16, 15, 14, 19, 18, 17], + 2001, # 2001-05 # 2006-11 ): dt = date(year, 1, day) self.assertIn(dt, stl_holidays, dt) @@ -714,7 +725,9 @@ def test_southland_anniversary_day(self): ): dt = date(year, month, day) self.assertIn(dt, stl_holidays, dt) - self.assertEqual(stl_holidays[dt], "Southland Anniversary Day", dt) + self.assertEqual( + stl_holidays[dt], "Southland Anniversary Day", dt + ) def test_chatham_islands_anniversary_day(self): cit_holidays = holidays.NZ(prov="Chatham Islands") @@ -746,14 +759,22 @@ def test_chatham_islands_anniversary_day(self): ): dt = date(year, 12 if day < 9 else 11, day) self.assertIn(dt, cit_holidays, dt) - self.assertEqual(cit_holidays[dt], "Chatham Islands Anniversary Day", dt) + self.assertEqual( + cit_holidays[dt], "Chatham Islands Anniversary Day", dt + ) def test_all_holidays_present(self): - nz_1969 = sum(holidays.NZ(years=[1969], prov=p) for p in holidays.NZ.PROVINCES) + nz_1969 = sum( + holidays.NZ(years=[1969], prov=p) for p in holidays.NZ.PROVINCES + ) holidays_in_1969 = sum((nz_1969.get_list(key) for key in nz_1969), []) - nz_2015 = sum(holidays.NZ(years=[2015], prov=p) for p in holidays.NZ.PROVINCES) + nz_2015 = sum( + holidays.NZ(years=[2015], prov=p) for p in holidays.NZ.PROVINCES + ) holidays_in_2015 = sum((nz_2015.get_list(key) for key in nz_2015), []) - nz_1974 = sum(holidays.NZ(years=[1974], prov=p) for p in holidays.NZ.PROVINCES) + nz_1974 = sum( + holidays.NZ(years=[1974], prov=p) for p in holidays.NZ.PROVINCES + ) holidays_in_1974 = sum((nz_1974.get_list(key) for key in nz_1974), []) all_holidays = [ "New Year's Day", @@ -791,4 +812,3 @@ def test_all_holidays_present(self): for holiday in all_holidays: self.assertIn(holiday, holidays_in_1974, holiday) self.assertNotIn("Waitangi Day", holidays_in_1974) - diff --git a/tests/countries/test_norway.py b/tests/countries/test_norway.py index 2853bb278..2a90a2c8d 100644 --- a/tests/countries/test_norway.py +++ b/tests/countries/test_norway.py @@ -138,4 +138,3 @@ def test_not_holiday(self): self.assertNotIn("2016-12-31", self.holidays_with_sundays) self.assertNotIn("2016-12-27", self.holidays_with_sundays) self.assertNotIn("2016-12-28", self.holidays_with_sundays) - diff --git a/tests/countries/test_russia.py b/tests/countries/test_russia.py index 9381f7469..e0fc27d39 100644 --- a/tests/countries/test_russia.py +++ b/tests/countries/test_russia.py @@ -50,4 +50,3 @@ def test_2018(self): self.assertIn(date(2018, 6, 12), self.holidays) self.assertIn(date(2018, 11, 4), self.holidays) self.assertNotIn(date(2018, 11, 7), self.holidays) - diff --git a/tests/countries/test_serbia.py b/tests/countries/test_serbia.py index 9465fb1a9..9fd4af595 100644 --- a/tests/countries/test_serbia.py +++ b/tests/countries/test_serbia.py @@ -71,4 +71,3 @@ def test_religious_holidays(self): self.assertIn(date(2020, 4, 19), self.holidays) self.assertIn(date(2020, 4, 20), self.holidays) self.assertNotIn(date(2020, 4, 21), self.holidays) - diff --git a/tests/countries/test_spain.py b/tests/countries/test_spain.py index 238a51ec6..d1e52689e 100644 --- a/tests/countries/test_spain.py +++ b/tests/countries/test_spain.py @@ -23,5 +23,3 @@ from flake8.api import legacy as flake8 import holidays - - diff --git a/tests/countries/test_sweden.py b/tests/countries/test_sweden.py index d4cc022e9..88c97b708 100644 --- a/tests/countries/test_sweden.py +++ b/tests/countries/test_sweden.py @@ -126,4 +126,3 @@ def test_not_holiday(self): self.assertNotIn("2017-02-10", self.holidays_with_sundays) self.assertNotIn("2016-12-27", self.holidays_with_sundays) self.assertNotIn("2016-12-28", self.holidays_with_sundays) - diff --git a/tests/countries/test_switzerland.py b/tests/countries/test_switzerland.py index 5fbde218f..03d967809 100644 --- a/tests/countries/test_switzerland.py +++ b/tests/countries/test_switzerland.py @@ -33,7 +33,9 @@ def setUp(self): ) def test_all_holidays_present(self): - ch_2018 = sum(holidays.CH(years=[2018], prov=p) for p in holidays.CH.PROVINCES) + ch_2018 = sum( + holidays.CH(years=[2018], prov=p) for p in holidays.CH.PROVINCES + ) in_2018 = sum((ch_2018.get_list(key) for key in ch_2018), []) all_ch = [ "Neujahrestag", diff --git a/tests/countries/test_united_kingdom.py b/tests/countries/test_united_kingdom.py index 3089fc9bf..308b22ba0 100644 --- a/tests/countries/test_united_kingdom.py +++ b/tests/countries/test_united_kingdom.py @@ -136,7 +136,9 @@ def test_christmas_day(self): self.holidays[date(2011, 12, 26)], "Christmas Day (Observed)" ) self.holidays.observed = True - self.assertEqual(self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)") + self.assertEqual( + self.holidays[date(2011, 12, 27)], "Christmas Day (Observed)" + ) for year, day in enumerate( [ 25, diff --git a/tests/countries/test_united_states.py b/tests/countries/test_united_states.py index db010d67f..747cb7639 100644 --- a/tests/countries/test_united_states.py +++ b/tests/countries/test_united_states.py @@ -25,7 +25,6 @@ import holidays - class TestUS(unittest.TestCase): def setUp(self): self.holidays = holidays.US(observed=False) @@ -59,7 +58,9 @@ def test_lee_jackson_day(self): va_holidays = holidays.US(state="VA") self.assertNotIn(date(1888, 1, 19), va_holidays) self.assertNotIn(date(1983, 1, 19), va_holidays) - self.assertNotIn("Lee Jackson Day", va_holidays.get_list(date(2000, 1, 17))) + self.assertNotIn( + "Lee Jackson Day", va_holidays.get_list(date(2000, 1, 17)) + ) for dt in [ date(1889, 1, 19), date(1982, 1, 19), @@ -121,7 +122,9 @@ def test_martin_luther(self): 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.assertIn( + "Martin Luther King Jr. Day", holidays.US(years=[1986]).values() + ) self.assertEqual( holidays.US(state="AL").get("2015-01-19"), "Robert E. Lee/Martin Luther King Birthday", @@ -151,7 +154,8 @@ def test_martin_luther(self): "Martin Luther King Jr. - Idaho Human Rights Day", ) self.assertEqual( - holidays.US(state="GA").get("2011-01-17"), "Robert E. Lee's Birthday" + holidays.US(state="GA").get("2011-01-17"), + "Robert E. Lee's Birthday", ) def test_lincolns_birthday(self): @@ -298,8 +302,12 @@ def test_washingtons_birthday(self): holidays.US(state="AR").get("2015-02-16"), ("George Washington's Birthday " "and Daisy Gatson Bates Day"), ) - self.assertEqual(holidays.US(state="PR").get("2015-02-16"), "Presidents' Day") - self.assertEqual(holidays.US(state="VI").get("2015-02-16"), "Presidents' Day") + self.assertEqual( + holidays.US(state="PR").get("2015-02-16"), "Presidents' Day" + ) + self.assertEqual( + holidays.US(state="VI").get("2015-02-16"), "Presidents' Day" + ) def test_mardi_gras(self): la_holidays = holidays.US(state="LA") @@ -398,7 +406,8 @@ def test_prince_jonah_kuhio_kalanianaole_day(self): self.assertNotIn(dt, self.holidays) self.assertIn(dt, hi_holidays) self.assertEqual( - hi_holidays.get(dt), "Prince Jonah Kuhio Kalanianaole Day (Observed)" + 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)]: @@ -762,23 +771,29 @@ def test_bennington_battle_day(self): self.assertIn(date(year, 8, 16), vt_holidays) vt_holidays.observed = False self.assertNotIn( - "Bennington Battle Day (Observed)", vt_holidays.get_list(date(1997, 8, 15)) + "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)) + "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)) + "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)) + "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)) + "Bennington Battle Day (Observed)", + vt_holidays.get_list(date(1999, 8, 15)), ) self.assertNotIn( - "Bennington Battle Day (Observed)", vt_holidays.get_list(date(1999, 8, 17)) + "Bennington Battle Day (Observed)", + vt_holidays.get_list(date(1999, 8, 17)), ) def test_lyndon_baines_johnson_day(self): @@ -831,7 +846,8 @@ def test_columbus_day(self): 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" + vi_holidays.get(dt), + "Columbus Day and Puerto Rico Friendship Day", ) self.assertNotIn(date(1936, 10, 12), self.holidays) @@ -860,8 +876,12 @@ def test_nevada_day(self): ]: self.assertNotIn(dt, self.holidays) self.assertIn(dt, nv_holidays) - 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))) + 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)) @@ -992,22 +1012,28 @@ def test_thanksgiving_day(self): self.assertNotIn(dt + relativedelta(days=+1), self.holidays) self.assertIn(dt + relativedelta(days=+1), de_holidays) self.assertEqual( - ca_holidays.get(dt + relativedelta(days=+1)), "Day After Thanksgiving" + ca_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", ) self.assertEqual( - de_holidays.get(dt + relativedelta(days=+1)), "Day After Thanksgiving" + de_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", ) self.assertEqual( - nh_holidays.get(dt + relativedelta(days=+1)), "Day After Thanksgiving" + nh_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", ) self.assertEqual( - nc_holidays.get(dt + relativedelta(days=+1)), "Day After Thanksgiving" + nc_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", ) self.assertEqual( - ok_holidays.get(dt + relativedelta(days=+1)), "Day After Thanksgiving" + ok_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", ) self.assertEqual( - wv_holidays.get(dt + relativedelta(days=+1)), "Day After Thanksgiving" + wv_holidays.get(dt + relativedelta(days=+1)), + "Day After Thanksgiving", ) self.assertIn(dt + relativedelta(days=+1), fl_holidays) self.assertEqual( @@ -1019,7 +1045,9 @@ def test_thanksgiving_day(self): tx_holidays.get(dt + relativedelta(days=+1)), "Friday After Thanksgiving", ) - self.assertEqual(nv_holidays.get(dt + relativedelta(days=+1)), "Family Day") + self.assertEqual( + nv_holidays.get(dt + relativedelta(days=+1)), "Family Day" + ) self.assertEqual( nm_holidays.get(dt + relativedelta(days=+1)), "Presidents' Day" ) @@ -1030,11 +1058,13 @@ def test_thanksgiving_day(self): ) if dt.year >= 2010: self.assertEqual( - in_holidays.get(dt + relativedelta(days=1)), "Lincoln's Birthday" + in_holidays.get(dt + relativedelta(days=1)), + "Lincoln's Birthday", ) else: self.assertNotEqual( - in_holidays.get(dt + relativedelta(days=1)), "Lincoln's Birthday" + in_holidays.get(dt + relativedelta(days=1)), + "Lincoln's Birthday", ) def test_robert_lee_birthday(self): @@ -1102,22 +1132,28 @@ def test_christmas_eve(self): 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)) + "Christmas Eve (Observed)", + as_holidays.get_list(date(2017, 12, 22)), ) self.assertIn( - "Christmas Eve (Observed)", ks_holidays.get_list(date(2017, 12, 22)) + "Christmas Eve (Observed)", + ks_holidays.get_list(date(2017, 12, 22)), ) self.assertIn( - "Christmas Eve (Observed)", mi_holidays.get_list(date(2017, 12, 22)) + "Christmas Eve (Observed)", + mi_holidays.get_list(date(2017, 12, 22)), ) self.assertIn( - "Christmas Eve (Observed)", nc_holidays.get_list(date(2017, 12, 22)) + "Christmas Eve (Observed)", + nc_holidays.get_list(date(2017, 12, 22)), ) self.assertIn( - "Christmas Eve (Observed)", tx_holidays.get_list(date(2017, 12, 22)) + "Christmas Eve (Observed)", + tx_holidays.get_list(date(2017, 12, 22)), ) self.assertIn( - "Christmas Eve (Observed)", wi_holidays.get_list(date(2017, 12, 22)) + "Christmas Eve (Observed)", + wi_holidays.get_list(date(2017, 12, 22)), ) def test_christmas_day(self): @@ -1141,17 +1177,21 @@ def test_day_after_christmas(self): 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)) + "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)) + "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)) + "Day After Christmas (Observed)", + tx_holidays.get_list(date(2015, 12, 28)), ) self.assertNotIn( - "Day After Christmas (Observed)", tx_holidays.get_list(date(2016, 12, 27)) + "Day After Christmas (Observed)", + tx_holidays.get_list(date(2016, 12, 27)), ) def test_new_years_eve(self): diff --git a/tests/countries/test_vietnam.py b/tests/countries/test_vietnam.py index b1c695337..981989498 100644 --- a/tests/countries/test_vietnam.py +++ b/tests/countries/test_vietnam.py @@ -87,18 +87,22 @@ 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.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)] + "Liberation Day/Reunification Day", + self.holidays[date(year, 4, 30)], ) def test_international_labor_day(self): for year in range(1979, 2050): - self.assertIn("International Labor Day", self.holidays[date(year, 5, 1)]) + self.assertIn( + "International Labor Day", self.holidays[date(year, 5, 1)] + ) def test_independence_day(self): for year in range(1979, 2050): diff --git a/tests/test_holiday_base.py b/tests/test_holiday_base.py index 99c21ab3b..98f5af199 100644 --- a/tests/test_holiday_base.py +++ b/tests/test_holiday_base.py @@ -40,7 +40,8 @@ def test_getitem(self): self.assertIsNone(self.holidays.get(date(2014, 1, 2))) self.assertListEqual( - self.holidays[date(2013, 12, 31) : date(2014, 1, 2)], [date(2014, 1, 1)] + self.holidays[date(2013, 12, 31) : date(2014, 1, 2)], + [date(2014, 1, 1)], ) self.assertListEqual( self.holidays[date(2013, 12, 24) : date(2014, 1, 2)], @@ -55,17 +56,20 @@ def test_getitem(self): [date(2013, 12, 25), date(2014, 1, 1)], ) self.assertListEqual( - self.holidays[date(2014, 1, 2) : date(2013, 12, 30)], [date(2014, 1, 1)] + self.holidays[date(2014, 1, 2) : date(2013, 12, 30)], + [date(2014, 1, 1)], ) self.assertListEqual( - self.holidays[date(2014, 1, 2) : date(2013, 12, 25)], [date(2014, 1, 1)] + self.holidays[date(2014, 1, 2) : date(2013, 12, 25)], + [date(2014, 1, 1)], ) self.assertListEqual( self.holidays[date(2014, 1, 2) : date(2013, 12, 24)], [date(2014, 1, 1), date(2013, 12, 25)], ) self.assertListEqual( - self.holidays[date(2014, 1, 1) : date(2013, 12, 24) : 3], [date(2014, 1, 1)] + self.holidays[date(2014, 1, 1) : date(2013, 12, 24) : 3], + [date(2014, 1, 1)], ) self.assertListEqual( self.holidays[date(2014, 1, 1) : date(2013, 12, 24) : 7], @@ -75,23 +79,36 @@ def test_getitem(self): 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)], + self.holidays[ + date(2014, 1, 1) : date(2013, 12, 24) : timedelta(days=3) + ], [date(2014, 1, 1)], ) self.assertListEqual( - self.holidays[date(2014, 1, 1) : date(2013, 12, 24) : timedelta(days=7)], + self.holidays[ + date(2014, 1, 1) : date(2013, 12, 24) : timedelta(days=7) + ], [date(2014, 1, 1), date(2013, 12, 25)], ) self.assertListEqual( - self.holidays[date(2013, 12, 31) : date(2014, 1, 2) : timedelta(days=3)], [] + self.holidays[ + date(2013, 12, 31) : date(2014, 1, 2) : timedelta(days=3) + ], + [], + ) + self.assertRaises( + ValueError, lambda: self.holidays[date(2014, 1, 1) :] ) - self.assertRaises(ValueError, lambda: self.holidays[date(2014, 1, 1) :]) - self.assertRaises(ValueError, lambda: self.holidays[: date(2014, 1, 1)]) self.assertRaises( - TypeError, lambda: self.holidays[date(2014, 1, 1) : date(2014, 1, 2) : ""] + ValueError, lambda: self.holidays[: date(2014, 1, 1)] ) self.assertRaises( - ValueError, lambda: self.holidays[date(2014, 1, 1) : date(2014, 1, 2) : 0] + TypeError, + lambda: self.holidays[date(2014, 1, 1) : date(2014, 1, 2) : ""], + ) + self.assertRaises( + ValueError, + lambda: self.holidays[date(2014, 1, 1) : date(2014, 1, 2) : 0], ) def test_get(self): @@ -113,7 +130,9 @@ def test_pop_named(self): self.assertIn(date(2014, 1, 1), self.holidays) self.holidays.pop_named("New Year's Day") self.assertNotIn(date(2014, 1, 1), self.holidays) - self.assertRaises(KeyError, lambda: self.holidays.pop_named("New Year's Dayz")) + self.assertRaises( + KeyError, lambda: self.holidays.pop_named("New Year's Dayz") + ) def test_setitem(self): self.holidays = holidays.US(years=[2014]) @@ -126,7 +145,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) @@ -134,7 +156,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)) @@ -261,18 +286,24 @@ def test_get_list(self): 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"] + 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, 1, 1)), ["New Year's 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]"] + 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)), []) @@ -431,10 +462,14 @@ def test_dates(self): def test_datetimes(self): self.assertIn(datetime(2014, 1, 1, 13, 45), self.holidays) - self.assertEqual(self.holidays[datetime(2014, 1, 1, 13, 45)], "New Year's Day") + self.assertEqual( + self.holidays[datetime(2014, 1, 1, 13, 45)], "New Year's Day" + ) self.holidays[datetime(2014, 1, 3, 1, 1)] = "Fake Holiday" self.assertIn(datetime(2014, 1, 3, 2, 2), self.holidays) - self.assertEqual(self.holidays.pop(datetime(2014, 1, 3, 4, 4)), "Fake Holiday") + self.assertEqual( + self.holidays.pop(datetime(2014, 1, 3, 4, 4)), "Fake Holiday" + ) self.assertNotIn(datetime(2014, 1, 3, 2, 2), self.holidays) def test_timestamp(self): @@ -458,8 +493,12 @@ def test_strings(self): self.assertNotIn("01/03/2014", self.holidays) 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), lambda: "abc" in self.holidays + ) + self.assertRaises( + (TypeError, ValueError), lambda: self.holidays.get("abc123") + ) self.assertRaises( (TypeError, ValueError), self.holidays.__setitem__, "abc", "Test" ) @@ -487,4 +526,3 @@ def test_country_province(self): def test_exceptions(self): self.assertRaises((KeyError), lambda: holidays.CountryHoliday("XXXX")) -