Skip to content

Commit

Permalink
Standardize custom holiday classes use (#1510)
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r authored Oct 12, 2023
1 parent 6e03890 commit 83c44bf
Show file tree
Hide file tree
Showing 25 changed files with 90 additions and 102 deletions.
8 changes: 4 additions & 4 deletions holidays/calendars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

# flake8: noqa: F401

from holidays.calendars.buddhist import _CustomBuddhistCalendar, _BuddhistLunisolar
from holidays.calendars.chinese import _CustomChineseCalendar, _ChineseLunisolar
from holidays.calendars.buddhist import _CustomBuddhistHolidays, _BuddhistLunisolar
from holidays.calendars.chinese import _CustomChineseHolidays, _ChineseLunisolar
from holidays.calendars.custom import _CustomCalendar
from holidays.calendars.gregorian import GREGORIAN_CALENDAR
from holidays.calendars.hebrew import _HebrewLunisolar
from holidays.calendars.hindu import _HinduLunisolar, _CustomHinduCalendar
from holidays.calendars.islamic import _CustomIslamicCalendar, _IslamicLunar
from holidays.calendars.hindu import _HinduLunisolar, _CustomHinduHolidays
from holidays.calendars.islamic import _CustomIslamicHolidays, _IslamicLunar
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.calendars.julian_revised import JULIAN_REVISED_CALENDAR
from holidays.calendars.persian import _Persian
Expand Down
2 changes: 1 addition & 1 deletion holidays/calendars/buddhist.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,5 +437,5 @@ def vesak_may_date(self, year: int) -> Tuple[Optional[date], bool]:
return self._get_holiday(VESAK_MAY, year)


class _CustomBuddhistCalendar(_CustomCalendar, _BuddhistLunisolar):
class _CustomBuddhistHolidays(_CustomCalendar, _BuddhistLunisolar):
pass
2 changes: 1 addition & 1 deletion holidays/calendars/chinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,5 +1261,5 @@ def mid_autumn_date(self, year: int) -> Tuple[Optional[date], bool]:
return self._get_holiday(MID_AUTUMN, year)


class _CustomChineseCalendar(_CustomCalendar, _ChineseLunisolar):
class _CustomChineseHolidays(_CustomCalendar, _ChineseLunisolar):
pass
2 changes: 1 addition & 1 deletion holidays/calendars/hindu.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,5 +437,5 @@ def thaipusam_date(self, year: int) -> Tuple[Optional[date], bool]:
return self._get_holiday(THAIPUSAM, year)


class _CustomHinduCalendar(_CustomCalendar, _HinduLunisolar):
class _CustomHinduHolidays(_CustomCalendar, _HinduLunisolar):
pass
2 changes: 1 addition & 1 deletion holidays/calendars/islamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3395,5 +3395,5 @@ def tasua_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
return self._get_holiday(TASUA, year)


class _CustomIslamicCalendar(_CustomCalendar, _IslamicLunar):
class _CustomIslamicHolidays(_CustomCalendar, _IslamicLunar):
pass
6 changes: 3 additions & 3 deletions holidays/countries/azerbaijan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from datetime import date

from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.groups import InternationalHolidays, IslamicHolidays
from holidays.observed_holiday_base import (
Expand All @@ -31,7 +31,7 @@ class Azerbaijan(ObservedHolidayBase, InternationalHolidays, IslamicHolidays):

def __init__(self, *args, **kwargs):
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=AzerbaijanIslamicCalendar())
IslamicHolidays.__init__(self, cls=AzerbaijanIslamicHolidays)
super().__init__(
observed_rule=SAT_SUN_TO_NEXT_WORKDAY, observed_since=2006, *args, **kwargs
)
Expand Down Expand Up @@ -152,7 +152,7 @@ class AZE(Azerbaijan):
pass


class AzerbaijanIslamicCalendar(_CustomIslamicCalendar):
class AzerbaijanIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2011: (NOV, 6),
2012: (OCT, 25),
Expand Down
6 changes: 3 additions & 3 deletions holidays/countries/bahrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from gettext import gettext as tr

from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import FRI, SAT, MAY, JUL, AUG, OCT
from holidays.groups import InternationalHolidays, IslamicHolidays
from holidays.holiday_base import HolidayBase
Expand All @@ -35,7 +35,7 @@ class Bahrain(HolidayBase, InternationalHolidays, IslamicHolidays):

def __init__(self, *args, **kwargs):
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=BahrainIslamicCalendar())
IslamicHolidays.__init__(self, cls=BahrainIslamicHolidays)
super().__init__(*args, **kwargs)

def _populate(self, year):
Expand Down Expand Up @@ -88,7 +88,7 @@ class BAH(Bahrain):
pass


class BahrainIslamicCalendar(_CustomIslamicCalendar):
class BahrainIslamicHolidays(_CustomIslamicHolidays):
ASHURA_DATES = {
2022: (AUG, 8),
}
Expand Down
6 changes: 3 additions & 3 deletions holidays/countries/bosnia_and_herzegovina.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from gettext import gettext as tr

from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import (
GREGORIAN_CALENDAR,
JAN,
Expand Down Expand Up @@ -73,7 +73,7 @@ class BosniaAndHerzegovina(
def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self, JULIAN_CALENDAR)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=BosniaAndHerzegovinaIslamicCalendar())
IslamicHolidays.__init__(self, cls=BosniaAndHerzegovinaIslamicHolidays)
super().__init__(observed_rule=SUN_TO_NEXT_MON, *args, **kwargs)

def _populate(self, year):
Expand Down Expand Up @@ -253,7 +253,7 @@ class BIH(BosniaAndHerzegovina):
pass


class BosniaAndHerzegovinaIslamicCalendar(_CustomIslamicCalendar):
class BosniaAndHerzegovinaIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2001: (MAR, 6),
2002: (FEB, 23),
Expand Down
6 changes: 3 additions & 3 deletions holidays/countries/brunei.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from gettext import gettext as tr

from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.groups import (
ChineseCalendarHolidays,
Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(self, *args, **kwargs):
ChineseCalendarHolidays.__init__(self)
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=BruneiIslamicCalendar())
IslamicHolidays.__init__(self, cls=BruneiIslamicHolidays)
super().__init__(observed_rule=FRI_SUN_TO_NEXT_SAT_MON, *args, **kwargs)

def _populate(self, year):
Expand Down Expand Up @@ -205,7 +205,7 @@ class BRN(Brunei):
pass


class BruneiIslamicCalendar(_CustomIslamicCalendar):
class BruneiIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2000: (MAR, 16),
2001: (MAR, 6),
Expand Down
6 changes: 3 additions & 3 deletions holidays/countries/burkina_faso.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.groups import ChristianHolidays, InternationalHolidays, IslamicHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SUN_TO_NEXT_MON
Expand All @@ -27,7 +27,7 @@ class BurkinaFaso(ObservedHolidayBase, ChristianHolidays, InternationalHolidays,
def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=BurkinaFasoIslamicCalendar())
IslamicHolidays.__init__(self, cls=BurkinaFasoIslamicHolidays)
super().__init__(observed_rule=SUN_TO_NEXT_MON, *args, **kwargs)

def _populate(self, year):
Expand Down Expand Up @@ -96,7 +96,7 @@ class BFA(BurkinaFaso):
pass


class BurkinaFasoIslamicCalendar(_CustomIslamicCalendar):
class BurkinaFasoIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2014: (OCT, 5),
2015: (SEP, 24),
Expand Down
6 changes: 3 additions & 3 deletions holidays/countries/cameroon.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.groups import ChristianHolidays, InternationalHolidays, IslamicHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SUN_TO_NEXT_WORKDAY
Expand All @@ -35,7 +35,7 @@ class Cameroon(ObservedHolidayBase, ChristianHolidays, InternationalHolidays, Is
def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=CameroonIslamicCalendar())
IslamicHolidays.__init__(self, cls=CameroonIslamicHolidays)
super().__init__(observed_rule=SUN_TO_NEXT_WORKDAY, *args, **kwargs)

def _populate(self, year):
Expand Down Expand Up @@ -97,7 +97,7 @@ class CMR(Cameroon):
pass


class CameroonIslamicCalendar(_CustomIslamicCalendar):
class CameroonIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2001: (MAR, 6),
2002: (FEB, 23),
Expand Down
6 changes: 3 additions & 3 deletions holidays/countries/chad.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.groups import (
ChristianHolidays,
Expand All @@ -35,7 +35,7 @@ class Chad(
def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=ChadIslamicCalendar())
IslamicHolidays.__init__(self, cls=ChadIslamicHolidays)
StaticHolidays.__init__(self, ChadStaticHolidays)
super().__init__(observed_rule=SUN_TO_NEXT_MON, *args, **kwargs)

Expand Down Expand Up @@ -92,7 +92,7 @@ class TCD(Chad):
pass


class ChadIslamicCalendar(_CustomIslamicCalendar):
class ChadIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2015: (SEP, 24),
2016: (SEP, 13),
Expand Down
6 changes: 3 additions & 3 deletions holidays/countries/gabon.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.groups import ChristianHolidays, InternationalHolidays, IslamicHolidays
from holidays.holiday_base import HolidayBase
Expand All @@ -29,7 +29,7 @@ class Gabon(HolidayBase, ChristianHolidays, InternationalHolidays, IslamicHolida
def __init__(self, *args, **kwargs) -> None:
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=GabonIslamicCalendar())
IslamicHolidays.__init__(self, cls=GabonIslamicHolidays)
super().__init__(*args, **kwargs)

def _populate(self, year):
Expand Down Expand Up @@ -86,7 +86,7 @@ class GAB(Gabon):
pass


class GabonIslamicCalendar(_CustomIslamicCalendar):
class GabonIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2001: (MAR, 6),
2002: (FEB, 23),
Expand Down
22 changes: 9 additions & 13 deletions holidays/countries/indonesia.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from gettext import gettext as tr

from holidays.calendars import (
_CustomBuddhistCalendar,
_CustomChineseCalendar,
_CustomIslamicCalendar,
_CustomBuddhistHolidays,
_CustomChineseHolidays,
_CustomIslamicHolidays,
)
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.constants import GOVERNMENT, PUBLIC
Expand Down Expand Up @@ -87,15 +87,11 @@ class Indonesia(
}

def __init__(self, *args, **kwargs):
BuddhistCalendarHolidays.__init__(
self, calendar=IndonesiaBuddhistCalendar(), show_estimated=True
)
ChineseCalendarHolidays.__init__(
self, calendar=IndonesiaChineseCalendar(), show_estimated=True
)
BuddhistCalendarHolidays.__init__(self, cls=IndonesiaBuddhistHolidays, show_estimated=True)
ChineseCalendarHolidays.__init__(self, cls=IndonesiaChineseHolidays, show_estimated=True)
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=IndonesiaIslamicCalendar())
IslamicHolidays.__init__(self, cls=IndonesiaIslamicHolidays)
super().__init__(*args, **kwargs)

def _populate_public_holidays(self):
Expand Down Expand Up @@ -212,7 +208,7 @@ class IDN(Indonesia):
pass


class IndonesiaBuddhistCalendar(_CustomBuddhistCalendar):
class IndonesiaBuddhistHolidays(_CustomBuddhistHolidays):
VESAK_DATES = {
2007: (JUN, 1),
2008: (MAY, 20),
Expand All @@ -234,7 +230,7 @@ class IndonesiaBuddhistCalendar(_CustomBuddhistCalendar):
}


class IndonesiaChineseCalendar(_CustomChineseCalendar):
class IndonesiaChineseHolidays(_CustomChineseHolidays):
LUNAR_NEW_YEAR_DATES = {
2003: (FEB, 1),
2004: (JAN, 22),
Expand All @@ -260,7 +256,7 @@ class IndonesiaChineseCalendar(_CustomChineseCalendar):
}


class IndonesiaIslamicCalendar(_CustomIslamicCalendar):
class IndonesiaIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2001: (MAR, 6),
2002: (FEB, 23),
Expand Down
30 changes: 13 additions & 17 deletions holidays/countries/malaysia.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# License: MIT (see LICENSE file)

from holidays.calendars import (
_CustomBuddhistCalendar,
_CustomChineseCalendar,
_CustomHinduCalendar,
_CustomIslamicCalendar,
_CustomBuddhistHolidays,
_CustomChineseHolidays,
_CustomHinduHolidays,
_CustomIslamicHolidays,
)
from holidays.calendars.gregorian import (
JAN,
Expand Down Expand Up @@ -126,17 +126,13 @@ def __init__(self, *args, **kwargs):
See parameters and usage in :py:class:`HolidayBase`.
"""
BuddhistCalendarHolidays.__init__(
self, calendar=MalaysiaBuddhistCalendar(), show_estimated=True
)
ChineseCalendarHolidays.__init__(
self, calendar=MalaysiaChineseCalendar(), show_estimated=True
)
BuddhistCalendarHolidays.__init__(self, cls=MalaysiaBuddhistHolidays, show_estimated=True)
ChineseCalendarHolidays.__init__(self, cls=MalaysiaChineseHolidays, show_estimated=True)
ChristianHolidays.__init__(self)
HinduCalendarHolidays.__init__(self, calendar=MalaysiaHinduCalendar())
HinduCalendarHolidays.__init__(self, cls=MalaysiaHinduHolidays)
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self, calendar=MalaysiaIslamicCalendar())
StaticHolidays.__init__(self, MalaysiaStaticHolidays)
IslamicHolidays.__init__(self, cls=MalaysiaIslamicHolidays)
StaticHolidays.__init__(self, cls=MalaysiaStaticHolidays)
super().__init__(observed_rule=SUN_TO_NEXT_WORKDAY, *args, **kwargs)

def _populate(self, year):
Expand Down Expand Up @@ -396,7 +392,7 @@ class MYS(Malaysia):
pass


class MalaysiaBuddhistCalendar(_CustomBuddhistCalendar):
class MalaysiaBuddhistHolidays(_CustomBuddhistHolidays):
VESAK_MAY_DATES = {
2001: (MAY, 7),
2002: (MAY, 27),
Expand Down Expand Up @@ -424,7 +420,7 @@ class MalaysiaBuddhistCalendar(_CustomBuddhistCalendar):
}


class MalaysiaChineseCalendar(_CustomChineseCalendar):
class MalaysiaChineseHolidays(_CustomChineseHolidays):
LUNAR_NEW_YEAR_DATES = {
2001: (JAN, 24),
2002: (FEB, 12),
Expand Down Expand Up @@ -452,7 +448,7 @@ class MalaysiaChineseCalendar(_CustomChineseCalendar):
}


class MalaysiaHinduCalendar(_CustomHinduCalendar):
class MalaysiaHinduHolidays(_CustomHinduHolidays):
DIWALI_DATES = {
2001: (NOV, 14),
2002: (NOV, 3),
Expand Down Expand Up @@ -493,7 +489,7 @@ class MalaysiaHinduCalendar(_CustomHinduCalendar):
}


class MalaysiaIslamicCalendar(_CustomIslamicCalendar):
class MalaysiaIslamicHolidays(_CustomIslamicHolidays):
EID_AL_ADHA_DATES = {
2001: (MAR, 6),
2002: (FEB, 23),
Expand Down
Loading

0 comments on commit 83c44bf

Please sign in to comment.