Update holidays to 0.28 (#95091)

Bump Python Holidays version to 0.28

Set `language` from country's default language
for holidays objects.
This commit is contained in:
Arkadii Yakovets 2023-07-08 11:27:25 -07:00 committed by GitHub
parent 2f5ff808a0
commit b2bf360297
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 20 deletions

View File

@ -120,15 +120,16 @@ async def async_setup_entry(
sensor_name: str = entry.options[CONF_NAME]
workdays: list[str] = entry.options[CONF_WORKDAYS]
cls: HolidayBase = getattr(holidays, country)
year: int = (dt_util.now() + timedelta(days=days_offset)).year
obj_holidays: HolidayBase = getattr(holidays, country)(years=year)
if province:
try:
obj_holidays = getattr(holidays, country)(subdiv=province, years=year)
except NotImplementedError:
LOGGER.error("There is no subdivision %s in country %s", province, country)
return
if province and province not in cls.subdivisions:
LOGGER.error("There is no subdivision %s in country %s", province, country)
return
obj_holidays = cls(
subdiv=province, years=year, language=cls.default_language
) # type: ignore[operator]
# Add custom holidays
try:

View File

@ -3,7 +3,8 @@ from __future__ import annotations
from typing import Any
from holidays import country_holidays, list_supported_countries
import holidays
from holidays import HolidayBase, list_supported_countries
import voluptuous as vol
from homeassistant.config_entries import (
@ -76,10 +77,12 @@ def validate_custom_dates(user_input: dict[str, Any]) -> None:
if dt_util.parse_date(add_date) is None:
raise AddDatesError("Incorrect date")
cls: HolidayBase = getattr(holidays, user_input[CONF_COUNTRY])
year: int = dt_util.now().year
obj_holidays = country_holidays(
user_input[CONF_COUNTRY], user_input.get(CONF_PROVINCE), year
)
obj_holidays = cls(
subdiv=user_input.get(CONF_PROVINCE), years=year, language=cls.default_language
) # type: ignore[operator]
for remove_date in user_input[CONF_REMOVE_HOLIDAYS]:
if dt_util.parse_date(remove_date) is None:

View File

@ -5,12 +5,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/workday",
"iot_class": "local_polling",
"loggers": [
"convertdate",
"hijri_converter",
"holidays",
"korean_lunar_calendar"
],
"loggers": ["holidays"],
"quality_scale": "internal",
"requirements": ["holidays==0.21.13"]
"requirements": ["holidays==0.28"]
}

View File

@ -977,7 +977,7 @@ hlk-sw16==0.0.9
hole==0.8.0
# homeassistant.components.workday
holidays==0.21.13
holidays==0.28
# homeassistant.components.frontend
home-assistant-frontend==20230705.1

View File

@ -760,7 +760,7 @@ hlk-sw16==0.0.9
hole==0.8.0
# homeassistant.components.workday
holidays==0.21.13
holidays==0.28
# homeassistant.components.frontend
home-assistant-frontend==20230705.1