Skip to content

Commit

Permalink
Drop Python 3.8 support (#2042)
Browse files Browse the repository at this point in the history
  • Loading branch information
PPsyrius authored Oct 11, 2024
1 parent 5c93ce7 commit 7335779
Show file tree
Hide file tree
Showing 32 changed files with 158 additions and 168 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ jobs:
- ubuntu-latest
- windows-latest
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
hooks:
- id: pyupgrade
args:
- --py38-plus
- --py39-plus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns: List[str] = []
exclude_patterns: list[str] = []

# Add any paths that contain templates here, relative to this directory.
#
Expand Down Expand Up @@ -144,7 +144,7 @@
#
# See https://sphinx-rtd-theme.readthedocs.io/en/latest/configuring.html
#
html_theme_options: Dict[str, Union[str, bool, int]] = {
html_theme_options: dict[str, Union[str, bool, int]] = {
# 'canonical_url': '',
# 'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard
# 'analytics_anonymize_ip': False
Expand Down
8 changes: 4 additions & 4 deletions holidays/calendars/buddhist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from datetime import date
from typing import Optional, Tuple
from typing import Optional

from holidays.calendars.custom import _CustomCalendar
from holidays.calendars.gregorian import MAY, JUN
Expand Down Expand Up @@ -425,16 +425,16 @@ class _BuddhistLunisolar:
2099: (MAY, 4),
}

def _get_holiday(self, holiday: str, year: int) -> Tuple[Optional[date], bool]:
def _get_holiday(self, holiday: str, year: int) -> tuple[Optional[date], bool]:
estimated_dates = getattr(self, f"{holiday}_DATES", {})
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
dt = exact_dates.get(year, estimated_dates.get(year, ()))
return date(year, *dt) if dt else None, year not in exact_dates

def vesak_date(self, year: int) -> Tuple[Optional[date], bool]:
def vesak_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(VESAK, year)

def vesak_may_date(self, year: int) -> Tuple[Optional[date], bool]:
def vesak_may_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(VESAK_MAY, year)


Expand Down
16 changes: 8 additions & 8 deletions holidays/calendars/chinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from datetime import date
from typing import Optional, Tuple
from typing import Optional

from holidays.calendars.custom import _CustomCalendar
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, SEP, OCT, NOV
Expand Down Expand Up @@ -1237,28 +1237,28 @@ class _ChineseLunisolar:
2099: (SEP, 29),
}

def _get_holiday(self, holiday: str, year: int) -> Tuple[Optional[date], bool]:
def _get_holiday(self, holiday: str, year: int) -> tuple[Optional[date], bool]:
estimated_dates = getattr(self, f"{holiday}_DATES", {})
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
dt = exact_dates.get(year, estimated_dates.get(year, ()))
return date(year, *dt) if dt else None, year not in exact_dates

def buddha_birthday_date(self, year: int) -> Tuple[Optional[date], bool]:
def buddha_birthday_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(BUDDHA_BIRTHDAY, year)

def double_ninth_date(self, year: int) -> Tuple[Optional[date], bool]:
def double_ninth_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(DOUBLE_NINTH, year)

def dragon_boat_date(self, year: int) -> Tuple[Optional[date], bool]:
def dragon_boat_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(DRAGON_BOAT, year)

def hung_kings_date(self, year: int) -> Tuple[Optional[date], bool]:
def hung_kings_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(HUNG_KINGS, year)

def lunar_new_year_date(self, year: int) -> Tuple[Optional[date], bool]:
def lunar_new_year_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(LUNAR_NEW_YEAR, year)

def mid_autumn_date(self, year: int) -> Tuple[Optional[date], bool]:
def mid_autumn_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(MID_AUTUMN, year)


Expand Down
8 changes: 4 additions & 4 deletions holidays/calendars/hindu.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from datetime import date
from typing import Optional, Tuple
from typing import Optional

from holidays.calendars.custom import _CustomCalendar
from holidays.calendars.gregorian import JAN, FEB, MAR, OCT, NOV
Expand Down Expand Up @@ -425,16 +425,16 @@ class _HinduLunisolar:
2099: (JAN, 6),
}

def _get_holiday(self, holiday: str, year: int) -> Tuple[Optional[date], bool]:
def _get_holiday(self, holiday: str, year: int) -> tuple[Optional[date], bool]:
estimated_dates = getattr(self, f"{holiday}_DATES", {})
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
dt = exact_dates.get(year, estimated_dates.get(year, ()))
return date(year, *dt) if dt else None, year not in exact_dates

def diwali_date(self, year: int) -> Tuple[Optional[date], bool]:
def diwali_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(DIWALI, year)

def thaipusam_date(self, year: int) -> Tuple[Optional[date], bool]:
def thaipusam_date(self, year: int) -> tuple[Optional[date], bool]:
return self._get_holiday(THAIPUSAM, year)


Expand Down
50 changes: 25 additions & 25 deletions holidays/calendars/islamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# Website: https://github.com/vacanza/holidays
# License: MIT (see LICENSE file)

from collections.abc import Iterable
from datetime import date
from typing import Iterable, Tuple

from holidays.calendars.custom import _CustomCalendar
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
Expand Down Expand Up @@ -3641,80 +3641,80 @@ class _IslamicLunar:
2076: (DEC, 5),
}

def _get_holiday(self, holiday: str, year: int) -> Iterable[Tuple[date, bool]]:
def _get_holiday(self, holiday: str, year: int) -> Iterable[tuple[date, bool]]:
estimated_dates = getattr(self, f"{holiday}_DATES", {})
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
for year in (year - 1, year):
for dt in _normalize_tuple(exact_dates.get(year, estimated_dates.get(year, ()))):
yield date(year, *dt), year not in exact_dates

def ali_al_rida_death_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def ali_al_rida_death_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(ALI_AL_RIDA_DEATH, year)

def ali_birthday_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def ali_birthday_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(ALI_BIRTHDAY, year)

def ali_death_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def ali_death_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(ALI_DEATH, year)

def arbaeen_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def arbaeen_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(ARBAEEN, year)

def ashura_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def ashura_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(ASHURA, year)

def eid_al_adha_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def eid_al_adha_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(EID_AL_ADHA, year)

def eid_al_fitr_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def eid_al_fitr_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(EID_AL_FITR, year)

def eid_al_ghadir_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def eid_al_ghadir_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(EID_AL_GHADIR, year)

def fatima_death_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def fatima_death_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(FATIMA_DEATH, year)

def hari_hol_johor_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def hari_hol_johor_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(HARI_HOL_JOHOR, year)

def hasan_al_askari_death_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def hasan_al_askari_death_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(HASAN_AL_ASKARI_DEATH, year)

def hijri_new_year_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def hijri_new_year_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(HIJRI_NEW_YEAR, year)

def imam_mahdi_birthday_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def imam_mahdi_birthday_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(IMAM_MAHDI_BIRTHDAY, year)

def isra_and_miraj_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def isra_and_miraj_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(ISRA_AND_MIRAJ, year)

def maldives_embraced_islam_day_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def maldives_embraced_islam_day_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(MALDIVES_EMBRACED_ISLAM_DAY, year)

def mawlid_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def mawlid_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(MAWLID, year)

def nuzul_al_quran_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def nuzul_al_quran_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(NUZUL_AL_QURAN, year)

def prophet_death_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def prophet_death_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(PROPHET_DEATH, year)

def quamee_dhuvas_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def quamee_dhuvas_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(QUAMEE_DHUVAS, year)

def ramadan_beginning_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def ramadan_beginning_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(RAMADAN_BEGINNING, year)

def sadiq_birthday_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def sadiq_birthday_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(SADIQ_BIRTHDAY, year)

def sadiq_death_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def sadiq_death_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(SADIQ_DEATH, year)

def tasua_dates(self, year: int) -> Iterable[Tuple[date, bool]]:
def tasua_dates(self, year: int) -> Iterable[tuple[date, bool]]:
return self._get_holiday(TASUA, year)


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

from datetime import date
from gettext import gettext as tr
from typing import Optional, Tuple
from typing import Optional

from holidays.calendars.gregorian import AUG, SEP
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
Expand Down Expand Up @@ -59,7 +59,7 @@ def _is_observed(self, dt: date) -> bool:
# it rolls over to the following Monday.
return dt >= date(1996, SEP, 27)

def _add_observed(self, dt: date, **kwargs) -> Tuple[bool, Optional[date]]:
def _add_observed(self, dt: date, **kwargs) -> tuple[bool, Optional[date]]:
# As per Law # #11/18, from 2018/9/10, when public holiday falls on Tuesday or Thursday,
# the Monday or Friday is also a holiday.
kwargs.setdefault(
Expand Down
3 changes: 1 addition & 2 deletions holidays/countries/bulgaria.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from datetime import date
from gettext import gettext as tr
from typing import Set

from holidays.calendars.julian_revised import JULIAN_REVISED_CALENDAR
from holidays.constants import PUBLIC, SCHOOL
Expand Down Expand Up @@ -57,7 +56,7 @@ def __init__(self, *args, **kwargs):
kwargs.setdefault("observed_since", 2017)
super().__init__(*args, **kwargs)

def _populate_observed(self, dts: Set[date], excluded_names: Set[str]) -> None:
def _populate_observed(self, dts: set[date], excluded_names: set[str]) -> None:
for dt in sorted(dts):
if not self._is_observed(dt):
continue
Expand Down
3 changes: 1 addition & 2 deletions holidays/countries/chile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# License: MIT (see LICENSE file)

from gettext import gettext as tr
from typing import Tuple

from holidays.calendars.gregorian import JUN, SEP, DEC
from holidays.constants import BANK, PUBLIC
Expand Down Expand Up @@ -226,7 +225,7 @@ def _populate_bank_holidays(self):
self._add_holiday_dec_31(name)

@property
def _summer_solstice_date(self) -> Tuple[int, int]:
def _summer_solstice_date(self) -> tuple[int, int]:
day = 20
if (self._year % 4 > 1 and self._year <= 2046) or (
self._year % 4 > 2 and self._year <= 2075
Expand Down
3 changes: 1 addition & 2 deletions holidays/countries/hongkong.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# License: MIT (see LICENSE file)

from datetime import date
from typing import Tuple

from holidays.calendars.gregorian import (
JAN,
Expand Down Expand Up @@ -416,7 +415,7 @@ def _populate_optional_holidays(self):
self._add_holiday_aug_30(name)

@property
def _winter_solstice_date(self) -> Tuple[int, int]:
def _winter_solstice_date(self) -> tuple[int, int]:
# This approximation is reliable for 1952-2099 years.
if (
(self._year % 4 == 0 and self._year >= 1988)
Expand Down
7 changes: 3 additions & 4 deletions holidays/countries/japan.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from datetime import date
from gettext import gettext as tr
from typing import Set, Tuple

from holidays.calendars.gregorian import (
FEB,
Expand Down Expand Up @@ -54,7 +53,7 @@ def __init__(self, *args, **kwargs) -> None:
def _is_observed(self, dt: date) -> bool:
return dt >= date(1973, APR, 12)

def _populate_observed(self, dts: Set[date]) -> None:
def _populate_observed(self, dts: set[date]) -> None:
# When a national holiday falls on Sunday, next working day
# shall become a public holiday (振替休日) - substitute holiday.
for dt in sorted(dts):
Expand Down Expand Up @@ -211,7 +210,7 @@ def _populate_bank_holidays(self):
self._add_new_years_eve(name)

@property
def _vernal_equinox_date(self) -> Tuple[int, int]:
def _vernal_equinox_date(self) -> tuple[int, int]:
day = 20
if (
(self._year % 4 == 0 and self._year <= 1956)
Expand All @@ -225,7 +224,7 @@ def _vernal_equinox_date(self) -> Tuple[int, int]:
return MAR, day

@property
def _autumnal_equinox_date(self) -> Tuple[int, int]:
def _autumnal_equinox_date(self) -> tuple[int, int]:
day = 23
if self._year % 4 == 3 and self._year <= 1979:
day = 24
Expand Down
4 changes: 2 additions & 2 deletions holidays/countries/jersey.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# License: MIT (see LICENSE file)

from datetime import date
from typing import Optional, Tuple
from typing import Optional

from holidays.calendars.gregorian import JAN, APR, MAY, JUN, JUL, SEP, OCT, DEC
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(self, *args, **kwargs):
kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_WORKDAY)
ObservedHolidayBase.__init__(self, *args, **kwargs)

def _add_observed(self, dt: date, **kwargs) -> Tuple[bool, Optional[date]]:
def _add_observed(self, dt: date, **kwargs) -> tuple[bool, Optional[date]]:
# Prior to 2004, in-lieu are only given for Sundays.
# https://www.jerseylaw.je/laws/enacted/Pages/RO-123-2004.aspx
kwargs.setdefault(
Expand Down
3 changes: 1 addition & 2 deletions holidays/countries/saudi_arabia.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from datetime import date
from gettext import gettext as tr
from typing import Set

from holidays.calendars.gregorian import JAN, FEB, SEP, NOV, THU, FRI, SAT, _timedelta
from holidays.groups import IslamicHolidays, StaticHolidays
Expand Down Expand Up @@ -58,7 +57,7 @@ def __init__(self, *args, **kwargs):
kwargs.setdefault("observed_rule", FRI_TO_PREV_THU + SAT_TO_NEXT_SUN)
super().__init__(*args, **kwargs)

def _add_islamic_observed(self, dts: Set[date]) -> None:
def _add_islamic_observed(self, dts: set[date]) -> None:
# Observed days are added to make up for any days falling on a weekend.
if not self.observed:
return None
Expand Down
Loading

0 comments on commit 7335779

Please sign in to comment.