holidays 0.82__py3-none-any.whl → 0.84__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. holidays/calendars/balinese_saka.py +2 -3
  2. holidays/calendars/buddhist.py +3 -4
  3. holidays/calendars/burmese.py +9 -10
  4. holidays/calendars/chinese.py +8 -9
  5. holidays/calendars/hebrew.py +10 -11
  6. holidays/calendars/hindu.py +27 -28
  7. holidays/calendars/islamic.py +26 -6
  8. holidays/calendars/mandaean.py +2 -3
  9. holidays/calendars/mongolian.py +4 -5
  10. holidays/calendars/persian.py +2 -3
  11. holidays/calendars/sinhala.py +25 -14
  12. holidays/calendars/thai.py +13 -14
  13. holidays/calendars/tibetan.py +12 -13
  14. holidays/countries/__init__.py +1 -0
  15. holidays/countries/angola.py +1 -2
  16. holidays/countries/austria.py +1 -1
  17. holidays/countries/azerbaijan.py +1 -1
  18. holidays/countries/canada.py +27 -13
  19. holidays/countries/denmark.py +18 -6
  20. holidays/countries/fiji.py +2 -3
  21. holidays/countries/finland.py +3 -6
  22. holidays/countries/guernsey.py +1 -2
  23. holidays/countries/guyana.py +24 -32
  24. holidays/countries/india.py +21 -78
  25. holidays/countries/iran.py +133 -269
  26. holidays/countries/ireland.py +1 -1
  27. holidays/countries/israel.py +1 -1
  28. holidays/countries/italy.py +2 -2
  29. holidays/countries/jersey.py +1 -2
  30. holidays/countries/macau.py +5 -8
  31. holidays/countries/malta.py +1 -1
  32. holidays/countries/mauritius.py +10 -9
  33. holidays/countries/montserrat.py +1 -1
  34. holidays/countries/myanmar.py +9 -10
  35. holidays/countries/nepal.py +11 -30
  36. holidays/countries/netherlands.py +28 -24
  37. holidays/countries/new_zealand.py +75 -31
  38. holidays/countries/nigeria.py +53 -75
  39. holidays/countries/norway.py +1 -1
  40. holidays/countries/portugal.py +6 -3
  41. holidays/countries/rwanda.py +2 -2
  42. holidays/countries/sint_maarten.py +1 -1
  43. holidays/countries/slovakia.py +23 -4
  44. holidays/countries/spain.py +418 -214
  45. holidays/countries/sri_lanka.py +58 -91
  46. holidays/countries/suriname.py +1 -2
  47. holidays/countries/sweden.py +1 -1
  48. holidays/countries/switzerland.py +86 -3
  49. holidays/countries/taiwan.py +3 -3
  50. holidays/countries/tanzania.py +19 -29
  51. holidays/countries/thailand.py +8 -7
  52. holidays/countries/trinidad_and_tobago.py +1 -1
  53. holidays/countries/ukraine.py +1 -1
  54. holidays/countries/united_kingdom.py +2 -3
  55. holidays/countries/united_states.py +3 -4
  56. holidays/countries/western_sahara.py +92 -0
  57. holidays/groups/balinese_saka.py +2 -3
  58. holidays/groups/buddhist.py +6 -7
  59. holidays/groups/burmese.py +11 -12
  60. holidays/groups/chinese.py +23 -21
  61. holidays/groups/christian.py +30 -0
  62. holidays/groups/eastern.py +5 -4
  63. holidays/groups/hebrew.py +7 -10
  64. holidays/groups/hindu.py +45 -40
  65. holidays/groups/international.py +1 -1
  66. holidays/groups/islamic.py +10 -3
  67. holidays/groups/mandaean.py +13 -14
  68. holidays/groups/mongolian.py +12 -10
  69. holidays/groups/persian.py +14 -15
  70. holidays/groups/sinhala.py +19 -17
  71. holidays/groups/thai.py +12 -13
  72. holidays/groups/tibetan.py +21 -19
  73. holidays/holiday_base.py +54 -54
  74. holidays/ical.py +1 -2
  75. holidays/locale/ar/LC_MESSAGES/EH.mo +0 -0
  76. holidays/locale/ca/LC_MESSAGES/ES.mo +0 -0
  77. holidays/locale/de/LC_MESSAGES/CH.mo +0 -0
  78. holidays/locale/en_US/LC_MESSAGES/CH.mo +0 -0
  79. holidays/locale/en_US/LC_MESSAGES/EH.mo +0 -0
  80. holidays/locale/en_US/LC_MESSAGES/ES.mo +0 -0
  81. holidays/locale/en_US/LC_MESSAGES/LK.mo +0 -0
  82. holidays/locale/en_US/LC_MESSAGES/NL.mo +0 -0
  83. holidays/locale/es/LC_MESSAGES/EH.mo +0 -0
  84. holidays/locale/es/LC_MESSAGES/ES.mo +0 -0
  85. holidays/locale/fr/LC_MESSAGES/CH.mo +0 -0
  86. holidays/locale/fr/LC_MESSAGES/EH.mo +0 -0
  87. holidays/locale/fy/LC_MESSAGES/NL.mo +0 -0
  88. holidays/locale/it/LC_MESSAGES/CH.mo +0 -0
  89. holidays/locale/nl/LC_MESSAGES/NL.mo +0 -0
  90. holidays/locale/si_LK/LC_MESSAGES/LK.mo +0 -0
  91. holidays/locale/ta_LK/LC_MESSAGES/LK.mo +0 -0
  92. holidays/locale/th/LC_MESSAGES/CH.mo +0 -0
  93. holidays/locale/th/LC_MESSAGES/CN.mo +0 -0
  94. holidays/locale/th/LC_MESSAGES/DK.mo +0 -0
  95. holidays/locale/th/LC_MESSAGES/ES.mo +0 -0
  96. holidays/locale/th/LC_MESSAGES/HK.mo +0 -0
  97. holidays/locale/th/LC_MESSAGES/KR.mo +0 -0
  98. holidays/locale/th/LC_MESSAGES/MO.mo +0 -0
  99. holidays/locale/th/LC_MESSAGES/NL.mo +0 -0
  100. holidays/locale/uk/LC_MESSAGES/CH.mo +0 -0
  101. holidays/locale/uk/LC_MESSAGES/ES.mo +0 -0
  102. holidays/locale/uk/LC_MESSAGES/NL.mo +0 -0
  103. holidays/mixins/child_entity.py +1 -3
  104. holidays/observed_holiday_base.py +25 -14
  105. holidays/registry.py +5 -3
  106. holidays/utils.py +13 -14
  107. holidays/version.py +1 -1
  108. {holidays-0.82.dist-info → holidays-0.84.dist-info}/METADATA +20 -19
  109. {holidays-0.82.dist-info → holidays-0.84.dist-info}/RECORD +113 -104
  110. {holidays-0.82.dist-info → holidays-0.84.dist-info}/WHEEL +0 -0
  111. {holidays-0.82.dist-info → holidays-0.84.dist-info}/licenses/CONTRIBUTORS +0 -0
  112. {holidays-0.82.dist-info → holidays-0.84.dist-info}/licenses/LICENSE +0 -0
  113. {holidays-0.82.dist-info → holidays-0.84.dist-info}/top_level.txt +0 -0
@@ -12,7 +12,6 @@
12
12
 
13
13
  from collections.abc import Iterable
14
14
  from datetime import date
15
- from typing import Optional
16
15
 
17
16
  from holidays.calendars.sinhala import _SinhalaLunar
18
17
  from holidays.groups.eastern import EasternCalendarHolidays
@@ -32,13 +31,13 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
32
31
  Adhi month dates are instead hardcoded in Sri Lanka country implementation.
33
32
  """
34
33
 
35
- def __init__(self, cls=None, show_estimated=False) -> None:
34
+ def __init__(self, cls=None, *, show_estimated=False) -> None:
36
35
  self._sinhala_calendar = cls() if cls else _SinhalaLunar()
37
36
  self._sinhala_calendar_show_estimated = show_estimated
38
37
 
39
38
  def _add_sinhala_calendar_holiday(
40
- self, name: str, dt_estimated: tuple[Optional[date], bool]
41
- ) -> Optional[date]:
39
+ self, name: str, dt_estimated: tuple[date | None, bool]
40
+ ) -> date | None:
42
41
  """
43
42
  Add Sinhala calendar holiday.
44
43
 
@@ -46,7 +45,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
46
45
  is an estimation.
47
46
  """
48
47
  return self._add_eastern_calendar_holiday(
49
- name, dt_estimated, self._sinhala_calendar_show_estimated
48
+ name, dt_estimated, show_estimated=self._sinhala_calendar_show_estimated
50
49
  )
51
50
 
52
51
  def _add_sinhala_calendar_holiday_set(
@@ -59,10 +58,13 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
59
58
  is an estimation.
60
59
  """
61
60
  return self._add_eastern_calendar_holiday_set(
62
- name, dts_estimated, self._sinhala_calendar_show_estimated, days_delta
61
+ name,
62
+ dts_estimated,
63
+ show_estimated=self._sinhala_calendar_show_estimated,
64
+ days_delta=days_delta,
63
65
  )
64
66
 
65
- def _add_bak_poya(self, name) -> Optional[date]:
67
+ def _add_bak_poya(self, name) -> date | None:
66
68
  """
67
69
  Add Bak Poya (first full moon day of the 5th lunar month).
68
70
 
@@ -72,7 +74,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
72
74
  name, self._sinhala_calendar.bak_poya_date(self._year)
73
75
  )
74
76
 
75
- def _add_binara_poya(self, name) -> Optional[date]:
77
+ def _add_binara_poya(self, name) -> date | None:
76
78
  """
77
79
  Add Binara Poya (first full moon day of the 10th lunar month).
78
80
 
@@ -92,7 +94,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
92
94
  name, self._sinhala_calendar.duruthu_poya_date(self._year)
93
95
  )
94
96
 
95
- def _add_esala_poya(self, name) -> Optional[date]:
97
+ def _add_esala_poya(self, name) -> date | None:
96
98
  """
97
99
  Add Esala Poya (first full moon day of the 8th lunar month).
98
100
 
@@ -102,7 +104,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
102
104
  name, self._sinhala_calendar.esala_poya_date(self._year)
103
105
  )
104
106
 
105
- def _add_il_poya(self, name) -> Optional[date]:
107
+ def _add_il_poya(self, name) -> date | None:
106
108
  """
107
109
  Add Il Poya (first full moon day of the 12th lunar month).
108
110
 
@@ -113,7 +115,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
113
115
  name, self._sinhala_calendar.il_poya_date(self._year)
114
116
  )
115
117
 
116
- def _add_medin_poya(self, name) -> Optional[date]:
118
+ def _add_medin_poya(self, name) -> date | None:
117
119
  """
118
120
  Add Medin Poya (first full moon day of the 4th lunar month).
119
121
 
@@ -123,7 +125,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
123
125
  name, self._sinhala_calendar.medin_poya_date(self._year)
124
126
  )
125
127
 
126
- def _add_nawam_poya(self, name) -> Optional[date]:
128
+ def _add_nawam_poya(self, name) -> date | None:
127
129
  """
128
130
  Add Nawam Poya (first full moon day of the 3rd lunar month).
129
131
 
@@ -134,7 +136,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
134
136
  name, self._sinhala_calendar.nawam_poya_date(self._year)
135
137
  )
136
138
 
137
- def _add_nikini_poya(self, name) -> Optional[date]:
139
+ def _add_nikini_poya(self, name) -> date | None:
138
140
  """
139
141
  Add Nikini Poya (first full moon day of the 9th lunar month).
140
142
 
@@ -144,7 +146,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
144
146
  name, self._sinhala_calendar.nikini_poya_date(self._year)
145
147
  )
146
148
 
147
- def _add_poson_poya(self, name) -> Optional[date]:
149
+ def _add_poson_poya(self, name) -> date | None:
148
150
  """
149
151
  Add Poson Poya (first full moon day of the 7th lunar month).
150
152
 
@@ -154,7 +156,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
154
156
  name, self._sinhala_calendar.poson_poya_date(self._year)
155
157
  )
156
158
 
157
- def _add_unduvap_poya(self, name) -> Optional[date]:
159
+ def _add_unduvap_poya(self, name) -> date | None:
158
160
  """
159
161
  Add Unduvap Poya (first full moon day of the 1st lunar month).
160
162
 
@@ -165,7 +167,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
165
167
  name, self._sinhala_calendar.unduvap_poya_date(self._year)
166
168
  )
167
169
 
168
- def _add_vap_poya(self, name) -> Optional[date]:
170
+ def _add_vap_poya(self, name) -> date | None:
169
171
  """
170
172
  Add Vap Poya (first full moon day of the 11th lunar month).
171
173
 
@@ -175,7 +177,7 @@ class SinhalaCalendarHolidays(EasternCalendarHolidays):
175
177
  name, self._sinhala_calendar.vap_poya_date(self._year)
176
178
  )
177
179
 
178
- def _add_vesak_poya(self, name) -> Optional[date]:
180
+ def _add_vesak_poya(self, name) -> date | None:
179
181
  """
180
182
  Add Vesak Poya (first full moon day of the 6th lunar month).
181
183
 
holidays/groups/thai.py CHANGED
@@ -11,7 +11,6 @@
11
11
  # License: MIT (see LICENSE file)
12
12
 
13
13
  from datetime import date
14
- from typing import Optional
15
14
 
16
15
  from holidays.calendars.thai import THAI_CALENDAR, _ThaiLunisolar
17
16
 
@@ -28,7 +27,7 @@ class ThaiCalendarHolidays:
28
27
  self.__calendar = calendar
29
28
  self._thai_calendar = _ThaiLunisolar(calendar)
30
29
 
31
- def _add_asarnha_bucha(self, name) -> Optional[date]:
30
+ def _add_asarnha_bucha(self, name) -> date | None:
32
31
  """
33
32
  Add Asarnha Bucha.
34
33
 
@@ -42,7 +41,7 @@ class ThaiCalendarHolidays:
42
41
  name, self._thai_calendar.asarnha_bucha_date(self._year)
43
42
  )
44
43
 
45
- def _add_boun_haw_khao_padapdin(self, name) -> Optional[date]:
44
+ def _add_boun_haw_khao_padapdin(self, name) -> date | None:
46
45
  """
47
46
  Add Boun Haw Khao Padapdin.
48
47
 
@@ -56,7 +55,7 @@ class ThaiCalendarHolidays:
56
55
  name, self._thai_calendar.boun_haw_khao_padapdin_date(self._year)
57
56
  )
58
57
 
59
- def _add_boun_haw_khao_salark(self, name) -> Optional[date]:
58
+ def _add_boun_haw_khao_salark(self, name) -> date | None:
60
59
  """
61
60
  Add Boun Haw Khao Salark.
62
61
 
@@ -70,7 +69,7 @@ class ThaiCalendarHolidays:
70
69
  name, self._thai_calendar.boun_haw_khao_salark_date(self._year)
71
70
  )
72
71
 
73
- def _add_boun_suang_heua(self, name) -> Optional[date]:
72
+ def _add_boun_suang_heua(self, name) -> date | None:
74
73
  """
75
74
  Add Boun Suang Huea.
76
75
 
@@ -84,7 +83,7 @@ class ThaiCalendarHolidays:
84
83
  name, self._thai_calendar.boun_suang_heua_date(self._year)
85
84
  )
86
85
 
87
- def _add_khao_phansa(self, name) -> Optional[date]:
86
+ def _add_khao_phansa(self, name) -> date | None:
88
87
  """
89
88
  Add Khao Phansa.
90
89
 
@@ -98,7 +97,7 @@ class ThaiCalendarHolidays:
98
97
  name, self._thai_calendar.khao_phansa_date(self._year)
99
98
  )
100
99
 
101
- def _add_loy_krathong(self, name) -> Optional[date]:
100
+ def _add_loy_krathong(self, name) -> date | None:
102
101
  """
103
102
  Add Loy Krathong.
104
103
 
@@ -114,7 +113,7 @@ class ThaiCalendarHolidays:
114
113
  name, self._thai_calendar.loy_krathong_date(self._year)
115
114
  )
116
115
 
117
- def _add_makha_bucha(self, name, calendar=None) -> Optional[date]:
116
+ def _add_makha_bucha(self, name, calendar=None) -> date | None:
118
117
  """
119
118
  Add Makha Bucha.
120
119
 
@@ -132,7 +131,7 @@ class ThaiCalendarHolidays:
132
131
  name, self._thai_calendar.makha_bucha_date(self._year, calendar)
133
132
  )
134
133
 
135
- def _add_ok_phansa(self, name) -> Optional[date]:
134
+ def _add_ok_phansa(self, name) -> date | None:
136
135
  """
137
136
  Add Ok Phansa.
138
137
 
@@ -146,7 +145,7 @@ class ThaiCalendarHolidays:
146
145
  name, self._thai_calendar.ok_phansa_date(self._year)
147
146
  )
148
147
 
149
- def _add_pchum_ben(self, name) -> Optional[date]:
148
+ def _add_pchum_ben(self, name) -> date | None:
150
149
  """
151
150
  Add Pchum Ben.
152
151
 
@@ -161,7 +160,7 @@ class ThaiCalendarHolidays:
161
160
  name, self._thai_calendar.pchum_ben_date(self._year)
162
161
  )
163
162
 
164
- def _add_preah_neangkoal(self, name) -> Optional[date]:
163
+ def _add_preah_neangkoal(self, name) -> date | None:
165
164
  """
166
165
  Add Preah Reach Pithi Chrat Preah Neangkoal.
167
166
 
@@ -175,7 +174,7 @@ class ThaiCalendarHolidays:
175
174
  name, self._thai_calendar.preah_neangkoal_date(self._year)
176
175
  )
177
176
 
178
- def _add_thai_calendar_holiday(self, name, dt) -> Optional[date]:
177
+ def _add_thai_calendar_holiday(self, name, dt) -> date | None:
179
178
  """
180
179
  Add Thai calendar holiday.
181
180
 
@@ -186,7 +185,7 @@ class ThaiCalendarHolidays:
186
185
 
187
186
  return self._add_holiday(name, dt)
188
187
 
189
- def _add_visakha_bucha(self, name, calendar=None) -> Optional[date]:
188
+ def _add_visakha_bucha(self, name, calendar=None) -> date | None:
190
189
  """
191
190
  Add Visakha Bucha.
192
191
 
@@ -11,7 +11,6 @@
11
11
  # License: MIT (see LICENSE file)
12
12
 
13
13
  from datetime import date
14
- from typing import Optional
15
14
 
16
15
  from holidays.calendars.tibetan import _TibetanLunisolar
17
16
  from holidays.groups.eastern import EasternCalendarHolidays
@@ -22,13 +21,13 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
22
21
  Tibetan lunisolar calendar holidays.
23
22
  """
24
23
 
25
- def __init__(self, cls=None, show_estimated=False) -> None:
24
+ def __init__(self, cls=None, *, show_estimated=False) -> None:
26
25
  self._tibetan_calendar = cls() if cls else _TibetanLunisolar()
27
26
  self._tibetan_calendar_show_estimated = show_estimated
28
27
 
29
28
  def _add_tibetan_calendar_holiday(
30
- self, name: str, dt_estimated: tuple[Optional[date], bool], days_delta: int = 0
31
- ) -> Optional[date]:
29
+ self, name: str, dt_estimated: tuple[date | None, bool], days_delta: int = 0
30
+ ) -> date | None:
32
31
  """
33
32
  Add Tibetan calendar holiday.
34
33
 
@@ -36,10 +35,13 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
36
35
  is an estimation.
37
36
  """
38
37
  return self._add_eastern_calendar_holiday(
39
- name, dt_estimated, self._tibetan_calendar_show_estimated, days_delta
38
+ name,
39
+ dt_estimated,
40
+ show_estimated=self._tibetan_calendar_show_estimated,
41
+ days_delta=days_delta,
40
42
  )
41
43
 
42
- def _add_blessed_rainy_day(self, name) -> Optional[date]:
44
+ def _add_blessed_rainy_day(self, name) -> date | None:
43
45
  """
44
46
  Add Blessed Rainy Day (September Equinox of Autumn Calendar).
45
47
  """
@@ -47,7 +49,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
47
49
  name, self._tibetan_calendar.blessed_rainy_day_date(self._year)
48
50
  )
49
51
 
50
- def _add_birth_of_guru_rinpoche(self, name) -> Optional[date]:
52
+ def _add_birth_of_guru_rinpoche(self, name) -> date | None:
51
53
  """
52
54
  Add Birth of Guru Rinpoche (10th day of the 5th lunar month).
53
55
  """
@@ -55,7 +57,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
55
57
  name, self._tibetan_calendar.birth_of_guru_rinpoche_date(self._year)
56
58
  )
57
59
 
58
- def _add_buddha_first_sermon(self, name) -> Optional[date]:
60
+ def _add_buddha_first_sermon(self, name) -> date | None:
59
61
  """
60
62
  Add Buddha First Sermon (4th day of the 6th lunar month).
61
63
  """
@@ -63,7 +65,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
63
65
  name, self._tibetan_calendar.buddha_first_sermon_date(self._year)
64
66
  )
65
67
 
66
- def _add_buddha_parinirvana(self, name) -> Optional[date]:
68
+ def _add_buddha_parinirvana(self, name) -> date | None:
67
69
  """
68
70
  Add Buddha Parinirvana (15th day of the 4th lunar month).
69
71
  """
@@ -71,7 +73,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
71
73
  name, self._tibetan_calendar.buddha_parinirvana_date(self._year)
72
74
  )
73
75
 
74
- def _add_day_of_offering(self, name) -> Optional[date]:
76
+ def _add_day_of_offering(self, name) -> date | None:
75
77
  """
76
78
  Add Day of Offering (1st day of the 12th lunar month).
77
79
  """
@@ -79,7 +81,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
79
81
  name, self._tibetan_calendar.day_of_offering_date(self._year)
80
82
  )
81
83
 
82
- def _add_death_of_zhabdrung(self, name) -> Optional[date]:
84
+ def _add_death_of_zhabdrung(self, name) -> date | None:
83
85
  """
84
86
  Add Death of Zhabdrung (10th day of the 3rd lunar month).
85
87
  """
@@ -87,7 +89,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
87
89
  name, self._tibetan_calendar.death_of_zhabdrung_date(self._year)
88
90
  )
89
91
 
90
- def _add_descending_day_of_lord_buddha(self, name) -> Optional[date]:
92
+ def _add_descending_day_of_lord_buddha(self, name) -> date | None:
91
93
  """
92
94
  Add Descending Day of Lord Buddha (22nd day of the 9th lunar month).
93
95
  """
@@ -95,7 +97,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
95
97
  name, self._tibetan_calendar.descending_day_of_lord_buddha_date(self._year)
96
98
  )
97
99
 
98
- def _add_losar(self, name) -> Optional[date]:
100
+ def _add_losar(self, name) -> date | None:
99
101
  """
100
102
  Add Losar (1st day of the 1st lunar month).
101
103
  """
@@ -103,7 +105,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
103
105
  name, self._tibetan_calendar.losar_date(self._year)
104
106
  )
105
107
 
106
- def _add_losar_day_two(self, name) -> Optional[date]:
108
+ def _add_losar_day_two(self, name) -> date | None:
107
109
  """
108
110
  Add Losar Day Two.
109
111
  """
@@ -111,7 +113,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
111
113
  name, self._tibetan_calendar.losar_date(self._year), days_delta=+1
112
114
  )
113
115
 
114
- def _add_thimphu_drubchen_day(self, name) -> Optional[date]:
116
+ def _add_thimphu_drubchen_day(self, name) -> date | None:
115
117
  """
116
118
  Add Thimphu Drubchen (6th day of the 8th lunar month).
117
119
  """
@@ -119,7 +121,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
119
121
  name, self._tibetan_calendar.thimphu_drubchen_date(self._year), days_delta=+1
120
122
  )
121
123
 
122
- def _add_thimphu_tshechu_day(self, name) -> Optional[date]:
124
+ def _add_thimphu_tshechu_day(self, name) -> date | None:
123
125
  """
124
126
  Add Thimphu Tshechu (10th day of the 8th lunar month).
125
127
  """
@@ -127,7 +129,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
127
129
  name, self._tibetan_calendar.thimphu_tshechu_date(self._year)
128
130
  )
129
131
 
130
- def _add_thimphu_tshechu_day_two(self, name) -> Optional[date]:
132
+ def _add_thimphu_tshechu_day_two(self, name) -> date | None:
131
133
  """
132
134
  Add Thimphu Tshechu Day 2.
133
135
  """
@@ -135,7 +137,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
135
137
  name, self._tibetan_calendar.thimphu_tshechu_date(self._year), days_delta=+1
136
138
  )
137
139
 
138
- def _add_thimphu_tshechu_day_three(self, name) -> Optional[date]:
140
+ def _add_thimphu_tshechu_day_three(self, name) -> date | None:
139
141
  """
140
142
  Add Thimphu Tshechu Day 3.
141
143
  """
@@ -143,7 +145,7 @@ class TibetanCalendarHolidays(EasternCalendarHolidays):
143
145
  name, self._tibetan_calendar.thimphu_tshechu_date(self._year), days_delta=+2
144
146
  )
145
147
 
146
- def _add_tibetan_winter_solstice(self, name) -> Optional[date]:
148
+ def _add_tibetan_winter_solstice(self, name) -> date | None:
147
149
  """
148
150
  Add Winter Solstice Day.
149
151
  """
holidays/holiday_base.py CHANGED
@@ -21,7 +21,7 @@ from datetime import date, datetime, timedelta, timezone
21
21
  from functools import cached_property
22
22
  from gettext import gettext, translation
23
23
  from pathlib import Path
24
- from typing import Any, Literal, Optional, Union, cast
24
+ from typing import Any, Literal, Union, cast
25
25
 
26
26
  from dateutil.parser import parse
27
27
 
@@ -43,15 +43,16 @@ from holidays.calendars.gregorian import (
43
43
  from holidays.constants import HOLIDAY_NAME_DELIMITER, PUBLIC, DEFAULT_START_YEAR, DEFAULT_END_YEAR
44
44
  from holidays.helpers import _normalize_arguments, _normalize_tuple
45
45
 
46
- CategoryArg = Union[str, Iterable[str]]
47
- DateArg = Union[date, tuple[int, int], tuple[int, int, int]]
48
- DateLike = Union[date, datetime, str, float, int]
49
- SpecialHoliday = Union[tuple[int, int, str], tuple[tuple[int, int, str], ...]]
50
- SubstitutedHoliday = Union[
51
- Union[tuple[int, int, int, int], tuple[int, int, int, int, int]],
52
- tuple[Union[tuple[int, int, int, int], tuple[int, int, int, int, int]], ...],
53
- ]
54
- YearArg = Union[int, Iterable[int]]
46
+ CategoryArg = str | Iterable[str]
47
+ DateArg = date | tuple[int, int] | tuple[int, int, int]
48
+ DateLike = date | datetime | str | float | int
49
+ SpecialHoliday = tuple[int, int, str] | tuple[tuple[int, int, str], ...]
50
+ SubstitutedHoliday = (
51
+ tuple[int, int, int, int]
52
+ | tuple[int, int, int, int, int]
53
+ | tuple[tuple[int, int, int, int] | tuple[int, int, int, int, int], ...]
54
+ )
55
+ YearArg = int | Iterable[int]
55
56
 
56
57
 
57
58
  class HolidayBase(dict[date, str]):
@@ -199,9 +200,9 @@ class HolidayBase(dict[date, str]):
199
200
  is requested."""
200
201
  observed: bool
201
202
  """Whether dates when public holiday are observed are included."""
202
- subdiv: Optional[str] = None
203
+ subdiv: str | None = None
203
204
  """The subdiv requested as ISO 3166-2 code or one of the aliases."""
204
- special_holidays: dict[int, Union[SpecialHoliday, SubstitutedHoliday]] = {}
205
+ special_holidays: dict[int, SpecialHoliday | SubstitutedHoliday] = {}
205
206
  """A list of the country-wide special (as opposite to regular) holidays for
206
207
  a specific year."""
207
208
  _deprecated_subdivisions: tuple[str, ...] = ()
@@ -213,7 +214,7 @@ class HolidayBase(dict[date, str]):
213
214
  """Working days moved to weekends."""
214
215
  default_category: str = PUBLIC
215
216
  """The entity category used by default."""
216
- default_language: Optional[str] = None
217
+ default_language: str | None = None
217
218
  """The entity language used by default."""
218
219
  categories: set[str] = set()
219
220
  """Requested holiday categories."""
@@ -225,19 +226,19 @@ class HolidayBase(dict[date, str]):
225
226
  """Start year of holidays presence for this entity."""
226
227
  end_year: int = DEFAULT_END_YEAR
227
228
  """End year of holidays presence for this entity."""
228
- parent_entity: Optional[type["HolidayBase"]] = None
229
+ parent_entity: type["HolidayBase"] | None = None
229
230
  """Optional parent entity to reference as a base."""
230
231
 
231
232
  def __init__(
232
233
  self,
233
- years: Optional[YearArg] = None,
234
+ years: YearArg | None = None,
234
235
  expand: bool = True,
235
236
  observed: bool = True,
236
- subdiv: Optional[str] = None,
237
- prov: Optional[str] = None, # Deprecated.
238
- state: Optional[str] = None, # Deprecated.
239
- language: Optional[str] = None,
240
- categories: Optional[CategoryArg] = None,
237
+ subdiv: str | None = None,
238
+ prov: str | None = None, # Deprecated.
239
+ state: str | None = None, # Deprecated.
240
+ language: str | None = None,
241
+ categories: CategoryArg | None = None,
241
242
  ) -> None:
242
243
  """
243
244
  Args:
@@ -605,7 +606,7 @@ class HolidayBase(dict[date, str]):
605
606
  The corresponding `datetime.date` representation.
606
607
  """
607
608
 
608
- dt: Optional[date] = None
609
+ dt: date | None = None
609
610
  # Try to catch `date` and `str` type keys first.
610
611
  # Using type() here to skip date subclasses.
611
612
  # Key is `date`.
@@ -662,7 +663,7 @@ class HolidayBase(dict[date, str]):
662
663
  def __radd__(self, other: Any) -> "HolidayBase":
663
664
  return self.__add__(other)
664
665
 
665
- def __reduce__(self) -> Union[str, tuple[Any, ...]]:
666
+ def __reduce__(self) -> str | tuple[Any, ...]:
666
667
  return super().__reduce__()
667
668
 
668
669
  def __repr__(self) -> str:
@@ -794,7 +795,7 @@ class HolidayBase(dict[date, str]):
794
795
  """Returns True if the year is leap. Returns False otherwise."""
795
796
  return isleap(self._year)
796
797
 
797
- def _add_holiday(self, name: str, *args) -> Optional[date]:
798
+ def _add_holiday(self, name: str, *args) -> date | None:
798
799
  """Add a holiday."""
799
800
  if not args:
800
801
  raise TypeError("Incorrect number of arguments.")
@@ -808,7 +809,7 @@ class HolidayBase(dict[date, str]):
808
809
  self[dt] = self.tr(name)
809
810
  return dt
810
811
 
811
- def _add_special_holidays(self, mapping_names, observed=False):
812
+ def _add_special_holidays(self, mapping_names, *, observed=False):
812
813
  """Add special holidays."""
813
814
  for mapping_name in mapping_names:
814
815
  for data in _normalize_tuple(getattr(self, mapping_name, {}).get(self._year, ())):
@@ -865,7 +866,14 @@ class HolidayBase(dict[date, str]):
865
866
  def _is_sunday(self, *args) -> bool:
866
867
  return self._check_weekday(SUN, *args)
867
868
 
868
- def _is_weekend(self, *args):
869
+ def _is_weekday(self, *args) -> bool:
870
+ """
871
+ Returns True if date's week day is not a weekend day.
872
+ Returns False otherwise.
873
+ """
874
+ return not self._is_weekend(*args)
875
+
876
+ def _is_weekend(self, *args) -> bool:
869
877
  """
870
878
  Returns True if date's week day is a weekend day.
871
879
  Returns False otherwise.
@@ -929,7 +937,7 @@ class HolidayBase(dict[date, str]):
929
937
  for category in self._sorted_categories
930
938
  )
931
939
 
932
- def append(self, *args: Union[dict[DateLike, str], list[DateLike], DateLike]) -> None:
940
+ def append(self, *args: dict[DateLike, str] | list[DateLike] | DateLike) -> None:
933
941
  """Alias for [update()][holidays.holiday_base.HolidayBase.update] to mimic list type.
934
942
 
935
943
  Args:
@@ -946,7 +954,7 @@ class HolidayBase(dict[date, str]):
946
954
  """Return a copy of the object."""
947
955
  return copy.copy(self)
948
956
 
949
- def get(self, key: DateLike, default: Union[str, Any] = None) -> Union[str, Any]:
957
+ def get(self, key: DateLike, default: str | Any = None) -> str | Any:
950
958
  """Retrieve the holiday name(s) for a given date.
951
959
 
952
960
  If the date is a holiday, returns the holiday name as a string.
@@ -1048,9 +1056,9 @@ class HolidayBase(dict[date, str]):
1048
1056
 
1049
1057
  def get_closest_holiday(
1050
1058
  self,
1051
- target_date: Optional[DateLike] = None,
1059
+ target_date: DateLike | None = None,
1052
1060
  direction: Literal["forward", "backward"] = "forward",
1053
- ) -> Optional[tuple[date, str]]:
1061
+ ) -> tuple[date, str] | None:
1054
1062
  """Find the closest holiday relative to a given date.
1055
1063
 
1056
1064
  If `direction` is "forward", returns the next holiday after `target_date`.
@@ -1163,7 +1171,7 @@ class HolidayBase(dict[date, str]):
1163
1171
  dt = self.__keytransform__(key)
1164
1172
  return dt in self.weekend_workdays if self._is_weekend(dt) else dt not in self
1165
1173
 
1166
- def pop(self, key: DateLike, default: Union[str, Any] = None) -> Union[str, Any]:
1174
+ def pop(self, key: DateLike, default: str | Any = None) -> str | Any:
1167
1175
  """Remove a holiday for a given date and return its name.
1168
1176
 
1169
1177
  If the specified date is a holiday, it will be removed, and its name will
@@ -1269,7 +1277,7 @@ class HolidayBase(dict[date, str]):
1269
1277
  return popped
1270
1278
 
1271
1279
  def update( # type: ignore[override]
1272
- self, *args: Union[dict[DateLike, str], list[DateLike], DateLike]
1280
+ self, *args: dict[DateLike, str] | list[DateLike] | DateLike
1273
1281
  ) -> None:
1274
1282
  """Update the object, overwriting existing dates.
1275
1283
 
@@ -1312,11 +1320,11 @@ class HolidaySum(HolidayBase):
1312
1320
  * Holidays are generated (expanded) for all years included in the operands.
1313
1321
  """
1314
1322
 
1315
- country: Union[str, list[str]] # type: ignore[assignment]
1323
+ country: str | list[str] # type: ignore[assignment]
1316
1324
  """Countries included in the addition."""
1317
- market: Union[str, list[str]] # type: ignore[assignment]
1325
+ market: str | list[str] # type: ignore[assignment]
1318
1326
  """Markets included in the addition."""
1319
- subdiv: Optional[Union[str, list[str]]] # type: ignore[assignment]
1327
+ subdiv: str | list[str] | None # type: ignore[assignment]
1320
1328
  """Subdivisions included in the addition."""
1321
1329
  holidays: list[HolidayBase]
1322
1330
  """The original HolidayBase objects included in the addition."""
@@ -1361,11 +1369,12 @@ class HolidaySum(HolidayBase):
1361
1369
  else:
1362
1370
  self.holidays.append(operand)
1363
1371
 
1364
- kwargs: dict[str, Any] = {}
1365
1372
  # Join years, expand and observed.
1366
- kwargs["years"] = h1.years | h2.years
1367
- kwargs["expand"] = h1.expand or h2.expand
1368
- kwargs["observed"] = h1.observed or h2.observed
1373
+ kwargs: dict[str, Any] = {
1374
+ "expand": h1.expand or h2.expand,
1375
+ "observed": h1.observed or h2.observed,
1376
+ "years": h1.years | h2.years,
1377
+ }
1369
1378
  # Join country and subdivisions data.
1370
1379
  # TODO: this way makes no sense: joining Italy Catania (IT, CA) with
1371
1380
  # USA Mississippi (US, MS) and USA Michigan (US, MI) yields
@@ -1374,25 +1383,16 @@ class HolidaySum(HolidayBase):
1374
1383
  # and Milano, or ... you get the picture.
1375
1384
  # Same goes when countries and markets are being mixed (working, yet
1376
1385
  # still nonsensical).
1386
+ value: str | list[str] | None
1377
1387
  for attr in ("country", "market", "subdiv"):
1378
- if (
1379
- getattr(h1, attr, None)
1380
- and getattr(h2, attr, None)
1381
- and getattr(h1, attr) != getattr(h2, attr)
1382
- ):
1383
- a1 = (
1384
- getattr(h1, attr)
1385
- if isinstance(getattr(h1, attr), list)
1386
- else [getattr(h1, attr)]
1387
- )
1388
- a2 = (
1389
- getattr(h2, attr)
1390
- if isinstance(getattr(h2, attr), list)
1391
- else [getattr(h2, attr)]
1392
- )
1388
+ a1 = getattr(h1, attr, None)
1389
+ a2 = getattr(h2, attr, None)
1390
+ if a1 and a2 and a1 != a2:
1391
+ a1 = a1 if isinstance(a1, list) else [a1]
1392
+ a2 = a2 if isinstance(a2, list) else [a2]
1393
1393
  value = a1 + a2
1394
1394
  else:
1395
- value = getattr(h1, attr, None) or getattr(h2, attr, None)
1395
+ value = a1 or a2
1396
1396
 
1397
1397
  if attr == "subdiv":
1398
1398
  kwargs[attr] = value
holidays/ical.py CHANGED
@@ -13,7 +13,6 @@
13
13
  import re
14
14
  import uuid
15
15
  from datetime import date, datetime, timezone
16
- from typing import Union
17
16
 
18
17
  from holidays.calendars.gregorian import _timedelta
19
18
  from holidays.holiday_base import HolidayBase
@@ -166,7 +165,7 @@ class ICalExporter:
166
165
  "END:VEVENT",
167
166
  ]
168
167
 
169
- def generate(self, return_bytes: bool = False) -> Union[str, bytes]:
168
+ def generate(self, return_bytes: bool = False) -> str | bytes:
170
169
  """Generate iCalendar data.
171
170
 
172
171
  Args:
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file