@@ -54,19 +54,25 @@ def create_bdew_calendar() -> HolidaySum:
5454 """
5555
5656 # First we need the BDEW specific holidays.
57- calendar = BdewDefinedHolidays ()
57+ calendar = BdewDefinedHolidays (language = "de" )
5858
5959 # the type is wrong at assignment but correct after the first loop iteration
6060 result : HolidaySum = calendar # type:ignore[assignment]
61-
61+ original_language_before_adding_subdivisions = result . language
6262 # If a day is holiday in any subdivision, the holiday is valid nationwide.
6363 # Therefore, we add all subdivisions of Germany to the BDEW specific holidays.
6464 # Currently, in Germany holidays are not observed.
6565 for subdivision in Germany .subdivisions :
6666 # the method __add__ expects a Union[int, "HolidayBase", "HolidaySum"] as `other`
6767 # here, we're dealing with a child instance of HolidayBase
6868 result += Germany (
69- subdiv = subdivision , observed = False
69+ subdiv = subdivision , observed = False , language = "de"
7070 ) # type:ignore[assignment]
71-
71+ if result .language is None :
72+ # This is a workaround to a problem in holidays 0.20-0.53 (at least):
73+ # When adding the subdivisions, the language attribute is lost,
74+ # although holiday base and subdivision share the same language.
75+ # The problem happens here:
76+ # https://github.com/vacanza/python-holidays/blob/v0.53/holidays/holiday_base.py#L1164
77+ result .language = original_language_before_adding_subdivisions
7278 return result
0 commit comments