Add observed holidays substitution support#3289
Conversation
Summary by CodeRabbit
WalkthroughRefactors substituted/observed holiday handling for Azerbaijan, Kazakhstan and Russia; adds Russia Constitution Day (1994–2004); updates core substituted-holiday logic; adjusts tests and snapshots to match new labeling and date mappings. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #3289 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 307 307
Lines 18373 18384 +11
Branches 2352 2353 +1
=========================================
+ Hits 18373 18384 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@holidays/countries/russia.py`:
- Around line 127-155: The issue is a missing blank line between the constant
definition constitution_day and the following symbol special_public_holidays;
insert a single blank line after the constitution_day declaration (the tr("День
Конституции Российской Федерации") assignment) so it matches the surrounding
spacing style and separates it from the special_public_holidays block.
In `@holidays/holiday_base.py`:
- Around line 860-867: The current removal uses self.pop(from_date) which
deletes all holiday entries on that date; change it to only remove the
substituted holiday entry or pop the date only if it's the sole entry. Locate
the block with self._is_weekend(from_date) and the else branch that calls
self.pop(from_date), then replace the unconditional pop with logic that: (a)
inspects the existing entries for from_date (via self.get(from_date) or indexing
like self[from_date]) to determine if multiple holidays are present, (b) removes
only the specific holiday name/entry associated with the substitution, and (c)
falls back to self.pop(from_date) only when there is a single entry left; keep
use of self.weekend_workdays and existing year checks intact.
Co-authored-by: Panpakorn Siripanich <[email protected]> Signed-off-by: ~Jhellico <[email protected]>
|
There was a problem hiding this comment.
♻️ Duplicate comments (1)
holidays/locale/th/LC_MESSAGES/RU.po (1)
88-91: Constitution Day translation already matches the prior suggestion.
msgstr "วันรัฐธรรมนูญสหพันธรัฐรัสเซีย"aligns with the existing reviewer suggestion and is a faithful translation of the Russianmsgid.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@holidays/locale/th/LC_MESSAGES/RU.po` around lines 88 - 91, The translation for the string with msgid "День Конституции Российской Федерации" already matches the suggested translation and should be left unchanged: keep msgstr "วันรัฐธรรมนูญสหพันธรัฐรัสเซีย" as-is and mark the change approved; also remove the duplicate review comment to avoid redundant approvals.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@holidays/locale/th/LC_MESSAGES/RU.po`:
- Around line 88-91: The translation for the string with msgid "День Конституции
Российской Федерации" already matches the suggested translation and should be
left unchanged: keep msgstr "วันรัฐธรรมนูญสหพันธรัฐรัสเซีย" as-is and mark the
change approved; also remove the duplicate review comment to avoid redundant
approvals.



Proposed change
Some countries (in particular, Azerbaijan, Kazakhstan, Russia) have a practice of transferring an additional non-working day, which occurs when holiday falls on weekend, from its usual date (Monday after this weekend) to a completely different date. This PR adds support for such cases. In this case, the "source" date can be either the date of the observed holiday (Azerbaijan, March 10, 2025 - "observed" March 8) or the date of the holiday itself (Russia, any New Year Holidays date).
Type of change
holidaysfunctionality in general)Checklist
make checklocally; all checks and tests passed.