Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up calendars #1349

Merged
merged 2 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions holidays/calendars/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
from holidays.calendars.buddhist import _CustomBuddhistCalendar, _BuddhistLunisolar
from holidays.calendars.chinese import _CustomChineseCalendar, _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.thai import _ThaiLunisolar

GREGORIAN_CALENDAR = "GREGORIAN_CALENDAR"
JULIAN_CALENDAR = "JULIAN_CALENDAR"
KHMER_CALENDAR = "KHMER_CALENDAR"
THAI_CALENDAR = "THAI_CALENDAR"
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.calendars.thai import _ThaiLunisolar, KHMER_CALENDAR, THAI_CALENDAR
2 changes: 1 addition & 1 deletion holidays/calendars/buddhist.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Optional, Tuple

from holidays.calendars.custom import _CustomCalendar
from holidays.constants import MAY, JUN
from holidays.calendars.gregorian import MAY, JUN

VESAK = "VESAK"
VESAK_MAY = "VESAK_MAY"
Expand Down
2 changes: 1 addition & 1 deletion holidays/calendars/chinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Optional, Tuple

from holidays.calendars.custom import _CustomCalendar
from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, SEP, OCT, NOV
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, SEP, OCT, NOV

BUDDHA_BIRTHDAY = "BUDDHA_BIRTHDAY"
DOUBLE_NINTH = "DOUBLE_NINTH"
Expand Down
17 changes: 17 additions & 0 deletions holidays/calendars/gregorian.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

GREGORIAN_CALENDAR = "GREGORIAN_CALENDAR"

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)
2 changes: 1 addition & 1 deletion holidays/calendars/hebrew.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datetime import date
from typing import Optional

from holidays.constants import FEB, MAR, APR, MAY, JUN, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import FEB, MAR, APR, MAY, JUN, SEP, OCT, NOV, DEC


class _HebrewLunisolar:
Expand Down
2 changes: 1 addition & 1 deletion holidays/calendars/hindu.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Optional, Tuple

from holidays.calendars.custom import _CustomCalendar
from holidays.constants import JAN, FEB, MAR, OCT, NOV
from holidays.calendars.gregorian import JAN, FEB, MAR, OCT, NOV

DIWALI = "DIWALI"
THAIPUSAM = "THAIPUSAM"
Expand Down
2 changes: 1 addition & 1 deletion holidays/calendars/islamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Iterable, Tuple

from holidays.calendars.custom import _CustomCalendar
from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.helpers import _normalize_tuple

ASHURA = "ASHURA"
Expand Down
12 changes: 12 additions & 0 deletions holidays/calendars/julian.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# python-holidays
# ---------------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

JULIAN_CALENDAR = "JULIAN_CALENDAR"
1 change: 0 additions & 1 deletion holidays/calendars/thai.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from functools import lru_cache
from typing import Optional

# Manual Assign to avoid circular import
KHMER_CALENDAR = "KHMER_CALENDAR"
THAI_CALENDAR = "THAI_CALENDAR"

Expand Down
28 changes: 24 additions & 4 deletions holidays/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,32 @@
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

HOLIDAY_NAME_DELIMITER = "; " # Holiday names separator.
# flake8: noqa: F401

MON, TUE, WED, THU, FRI, SAT, SUN = range(7)
WEEKEND = (SAT, SUN)
from holidays.calendars.gregorian import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we keeping here these constants import? For external compatibility?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, it needs to stay backward compatible

JAN,
FEB,
MAR,
APR,
MAY,
JUN,
JUL,
AUG,
SEP,
OCT,
NOV,
DEC,
MON,
TUE,
WED,
THU,
FRI,
SAT,
SUN,
WEEKEND,
)

JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC = range(1, 13)
HOLIDAY_NAME_DELIMITER = "; " # Holiday names separator.

# Supported holiday categories.
BANK = "bank"
Expand Down
4 changes: 2 additions & 2 deletions holidays/countries/albania.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

from datetime import timedelta as td

from holidays.calendars import JULIAN_CALENDAR
from holidays.constants import JAN, MAR, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import JAN, MAR, SEP, OCT, NOV, DEC
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, IslamicHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/algeria.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from holidays.constants import JAN, JUL, NOV
from holidays.calendars.gregorian import JAN, JUL, NOV
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import IslamicHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/andorra.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from datetime import timedelta as td

from holidays.constants import MAR, JUL, AUG, SEP, FRI, SAT
from holidays.calendars.gregorian import MAR, JUL, AUG, SEP, FRI, SAT
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/angola.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from datetime import timedelta as td

from holidays.constants import FEB, MAR, APR, SEP, NOV, DEC
from holidays.calendars.gregorian import FEB, MAR, APR, SEP, NOV, DEC
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
16 changes: 15 additions & 1 deletion holidays/countries/argentina.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@
from datetime import date
from gettext import gettext as tr

from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC, MON
from holidays.calendars.gregorian import (
JAN,
FEB,
MAR,
APR,
MAY,
JUN,
JUL,
AUG,
SEP,
OCT,
NOV,
DEC,
MON,
)
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
4 changes: 2 additions & 2 deletions holidays/countries/armenia.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

from gettext import gettext as tr

from holidays.calendars import JULIAN_CALENDAR
from holidays.constants import JAN, APR, MAY, JUL, SEP
from holidays.calendars.gregorian import JAN, APR, MAY, JUL, SEP
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/aruba.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datetime import timedelta as td
from gettext import gettext as tr

from holidays.constants import JAN, MAR, APR, AUG
from holidays.calendars.gregorian import JAN, MAR, APR, AUG
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/australia.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datetime import date
from datetime import timedelta as td

from holidays.constants import JAN, MAR, APR, MAY, JUN, AUG, SEP, OCT, NOV, MON, TUE, FRI
from holidays.calendars.gregorian import JAN, MAR, APR, MAY, JUN, AUG, SEP, OCT, NOV, MON, TUE, FRI
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
3 changes: 2 additions & 1 deletion holidays/countries/austria.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

from gettext import gettext as tr

from holidays.constants import OCT, NOV, BANK, PUBLIC
from holidays.calendars.gregorian import OCT, NOV
from holidays.constants import BANK, PUBLIC
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/azerbaijan.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datetime import timedelta as td

from holidays.calendars import _CustomIslamicCalendar
from holidays.constants import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import JAN, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import InternationalHolidays, IslamicHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/bahrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# License: MIT (see LICENSE file)

from holidays.calendars import _CustomIslamicCalendar
from holidays.constants import FRI, SAT, MAY, JUL, AUG, OCT, DEC
from holidays.calendars.gregorian import FRI, SAT, MAY, JUL, AUG, OCT, DEC
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import InternationalHolidays, IslamicHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/bangladesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from datetime import date

from holidays.constants import FEB, MAR, APR, MAY, AUG, DEC
from holidays.calendars.gregorian import FEB, MAR, APR, MAY, AUG, DEC
from holidays.holiday_base import HolidayBase


Expand Down
4 changes: 2 additions & 2 deletions holidays/countries/belarus.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

from gettext import gettext as tr

from holidays.calendars import GREGORIAN_CALENDAR, JULIAN_CALENDAR
from holidays.constants import JUL, NOV
from holidays.calendars.gregorian import GREGORIAN_CALENDAR, JUL, NOV
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/belgium.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from dateutil.easter import easter

from holidays.constants import JAN, MAY, JUL, AUG, NOV, DEC
from holidays.calendars.gregorian import JAN, MAY, JUL, AUG, NOV, DEC
from holidays.holiday_base import HolidayBase


Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/belize.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datetime import timedelta as td
from typing import Optional

from holidays.constants import JAN, MAR, MAY, AUG, SEP, OCT, NOV, MON
from holidays.calendars.gregorian import JAN, MAR, MAY, AUG, SEP, OCT, NOV, MON
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/bolivia.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from datetime import timedelta as td

from holidays.constants import JAN, APR, MAY, JUN, JUL, AUG, SEP, NOV
from holidays.calendars.gregorian import JAN, APR, MAY, JUN, JUL, AUG, SEP, NOV
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
4 changes: 3 additions & 1 deletion holidays/countries/bosnia_and_herzegovina.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
from datetime import timedelta as td
from gettext import gettext as tr

from holidays.calendars import _CustomIslamicCalendar, GREGORIAN_CALENDAR, JULIAN_CALENDAR
from holidays.calendars import _CustomIslamicCalendar
from holidays.calendars.gregorian import GREGORIAN_CALENDAR
from holidays.calendars.julian import JULIAN_CALENDAR
from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, IslamicHolidays, InternationalHolidays
Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/botswana.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datetime import date
from datetime import timedelta as td

from holidays.constants import JUL, SEP, MON
from holidays.calendars.gregorian import JUL, SEP, MON
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
17 changes: 16 additions & 1 deletion holidays/countries/brazil.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@
from datetime import timedelta as td
from datetime import date

from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC, FRI, SUN
from holidays.calendars.gregorian import (
JAN,
FEB,
MAR,
APR,
MAY,
JUN,
JUL,
AUG,
SEP,
OCT,
NOV,
DEC,
FRI,
SUN,
)
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/brunei.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from gettext import gettext as tr

from holidays.calendars import _CustomIslamicCalendar
from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import (
ChineseCalendarHolidays,
Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/bulgaria.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from dateutil.easter import EASTER_ORTHODOX, easter

from holidays.constants import JAN, MAR, MAY, SEP, NOV, DEC
from holidays.calendars.gregorian import JAN, MAR, MAY, SEP, NOV, DEC
from holidays.holiday_base import HolidayBase


Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/burkina_faso.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datetime import timedelta as td

from holidays.calendars import _CustomIslamicCalendar
from holidays.constants import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays, IslamicHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/burundi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datetime import timedelta as td
from typing import Optional

from holidays.constants import FEB, APR, JUN, JUL, OCT
from holidays.calendars.gregorian import FEB, APR, JUN, JUL, OCT
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, IslamicHolidays, InternationalHolidays

Expand Down
4 changes: 2 additions & 2 deletions holidays/countries/cambodia.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from datetime import timedelta as td
from gettext import gettext as tr

from holidays.calendars import KHMER_CALENDAR
from holidays.constants import JAN, APR, MAY, JUN, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import JAN, APR, MAY, JUN, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.thai import KHMER_CALENDAR
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import InternationalHolidays, ThaiCalendarHolidays

Expand Down
2 changes: 1 addition & 1 deletion holidays/countries/cameroon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from datetime import timedelta as td

from holidays.calendars import _CustomIslamicCalendar
from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
from holidays.holiday_base import HolidayBase
from holidays.holiday_groups import ChristianHolidays, InternationalHolidays, IslamicHolidays

Expand Down
Loading