Skip to content

Conversation

@KJhellico
Copy link
Collaborator

Proposed change

Inline single-use variables, update .py files formatting.

Type of change

  • New country/market holidays support (thank you!)
  • Supported country/market holidays update (calendar discrepancy fix, localization)
  • Existing code/documentation/test/process quality improvement (best practice, cleanup, refactoring, optimization)
  • Dependency update (version deprecation/pin/upgrade)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (a code change causing existing functionality to break)
  • New feature (new holidays functionality in general)

Checklist

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 19, 2025

Summary by CodeRabbit

  • Refactor
    • Internal code optimizations across multiple country holiday definitions, simplifying method calls and removing intermediate variables with no impact to holiday calculations or user-facing functionality.

Walkthrough

This pull request refactors multiple country holiday files to eliminate unnecessary intermediate variable assignments. The changes directly pass computed translations to holiday-adding methods, simplifying call patterns while preserving identical logic and outcomes across Finland, Macau, New Zealand, Suriname, and Thailand.

Changes

Cohort / File(s) Summary
Intermediate variable elimination
holidays/countries/finland.py, holidays/countries/macau.py, holidays/countries/new_zealand.py, holidays/countries/suriname.py
Removes temporary name variable assignments; directly calls holiday-adding methods with conditional translations for specific dates (J.V. Snellman Day, Aleksis Kivi Day, Flag Day, Good Friday, Holy Saturday, Christmas, Waitangi Day, November 25). No logic changes.
Translation call refactoring
holidays/countries/macau.py
Switches observed label translation from self.tr(...) to tr(...) in government holidays population while maintaining identical conditional branching.
Structural formatting
holidays/countries/thailand.py
Minor formatting adjustment to Makha Bucha addition nested within _add_observed call; functionally equivalent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Homogeneous refactoring pattern applied consistently across files with no logic changes—straightforward verification that translations and conditionals map correctly to the new direct call structure.

Suggested reviewers

  • arkid15r
  • PPsyrius

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Inline single-use variables, update .py files formatting" directly corresponds to the changes in the changeset. Across all modified files (finland.py, macau.py, new_zealand.py, suriname.py, and thailand.py), the primary change is consistently removing intermediate variable assignments and making direct method calls instead. This refactoring pattern is the main point of the pull request, and the title captures both the inlining of variables and formatting adjustments accurately and concisely.
Description Check ✅ Passed The description is related to the changeset and appropriately categorizes the work as a code quality improvement focused on refactoring and cleanup. The proposed change clearly states the intent to inline single-use variables and update formatting, which aligns with all the modifications shown across the five country files. While brief, the description conveys meaningful information about the refactoring effort without being misleading or off-topic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 785ce0d and cda1c02.

📒 Files selected for processing (5)
  • holidays/countries/finland.py (3 hunks)
  • holidays/countries/macau.py (3 hunks)
  • holidays/countries/new_zealand.py (1 hunks)
  • holidays/countries/suriname.py (1 hunks)
  • holidays/countries/thailand.py (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: PPsyrius
PR: vacanza/holidays#2881
File: tests/countries/test_albania.py:40-42
Timestamp: 2025-09-04T08:54:35.319Z
Learning: In the vacanza/holidays project test files, extract holiday name strings to local variables only when they are reused multiple times within the same test method (e.g., used in both assertHolidayName and assertNoHolidayName calls). When a holiday name is used only once, keep it inline rather than extracting it to a variable for the sake of consistency.
Learnt from: KJhellico
PR: vacanza/holidays#2608
File: tests/countries/test_saint_vincent_and_the_grenadines.py:162-178
Timestamp: 2025-07-02T18:21:59.302Z
Learning: In the Saint Vincent and the Grenadines holiday tests, for holidays without observed rules that only require a single assertHolidayName call, pass the holiday name directly as a string literal rather than storing it in a variable first for cleaner, more concise code.
Learnt from: KJhellico
PR: vacanza/holidays#2398
File: tests/countries/test_guinea.py:237-239
Timestamp: 2025-04-02T18:38:35.164Z
Learning: In the vacanza/holidays project, the method assertLocalizedHolidays in country test files should be called with positional parameters rather than named parameters to maintain consistency with the rest of the codebase.
Learnt from: PPsyrius
PR: vacanza/holidays#2632
File: holidays/countries/solomon_islands.py:95-98
Timestamp: 2025-06-16T12:28:31.641Z
Learning: Library-wide holiday patterns and their optimizations should be handled at the base class level (like InternationalHolidays) rather than documenting workarounds in individual country modules. This maintains separation of concerns and avoids documentation duplication.
📚 Learning: 2025-03-05T02:35:03.298Z
Learnt from: PPsyrius
PR: vacanza/holidays#2323
File: holidays/countries/macau.py:278-377
Timestamp: 2025-03-05T02:35:03.298Z
Learning: For Macau holiday implementations, it's preferable to maintain separate methods for different holiday categories (MANDATORY, GOVERNMENT, PUBLIC) as they are based on different sets of laws, making the code easier to maintain despite having multiple year-based conditionals.

Applied to files:

  • holidays/countries/macau.py
📚 Learning: 2025-03-04T11:41:56.389Z
Learnt from: PPsyrius
PR: vacanza/holidays#2323
File: holidays/countries/macau.py:284-366
Timestamp: 2025-03-04T11:41:56.389Z
Learning: For Macau holidays implementation, maintaining separate methods for each holiday category (PUBLIC, MANDATORY, GOVERNMENT) is preferred because these categories are based on different sets of laws and have distinct historical evolution.

Applied to files:

  • holidays/countries/macau.py
📚 Learning: 2025-08-21T04:56:03.780Z
Learnt from: PPsyrius
PR: vacanza/holidays#2843
File: holidays/countries/burundi.py:63-101
Timestamp: 2025-08-21T04:56:03.780Z
Learning: In the holidays library, countries with localization support consistently use tr() wrappers around holiday names when calling _add_* methods (e.g., self._add_new_years_day(tr("Holiday Name"))). This is the established pattern across United States, Thailand, and other l10n-enabled countries, contrary to any suggestion that translation is handled internally by _add_* methods.

Applied to files:

  • holidays/countries/macau.py
📚 Learning: 2025-08-26T20:10:05.288Z
Learnt from: KJhellico
PR: vacanza/holidays#2834
File: holidays/financial/national_stock_exchange_of_india.py:38-44
Timestamp: 2025-08-26T20:10:05.288Z
Learning: For National Stock Exchange of India (NSE) holidays implementation, only `estimated_label = tr("%s (estimated)")` is needed for localization support. The `observed_label` and `observed_estimated_label` are not required for this financial market holidays implementation.

Applied to files:

  • holidays/countries/macau.py
📚 Learning: 2025-08-28T02:34:11.657Z
Learnt from: PPsyrius
PR: vacanza/holidays#2860
File: holidays/groups/eastern.py:36-36
Timestamp: 2025-08-28T02:34:11.657Z
Learning: The default estimated_label change from "%s (estimated)" to "%s" in holidays/groups/eastern.py is intentional to remove English-only fallback text from localized holiday names. Countries that need estimated labels should define them properly with localization support rather than relying on the English fallback.

Applied to files:

  • holidays/countries/macau.py
🧬 Code graph analysis (2)
holidays/countries/thailand.py (2)
holidays/observed_holiday_base.py (1)
  • _add_observed (144-198)
holidays/groups/thai.py (1)
  • _add_makha_bucha (117-133)
holidays/countries/macau.py (1)
holidays/groups/christian.py (3)
  • _add_good_friday (344-353)
  • _add_holy_saturday (355-362)
  • _add_christmas_day (224-232)
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test Python 3.14 on windows-latest
🔇 Additional comments (7)
holidays/countries/thailand.py (1)

684-692: LGTM! Clean refactor.

The nested call preserves identical behavior while eliminating the intermediate variable. The year-based name selection logic is maintained correctly.

holidays/countries/suriname.py (1)

111-117: LGTM! Cleaner inline approach.

Passing the conditional expression directly to _add_holiday_nov_25 eliminates the temporary variable while preserving the year-based name logic.

holidays/countries/new_zealand.py (1)

147-153: LGTM! Simplified initialization.

Directly assigning feb_6 from _add_holiday_feb_6 with the conditional name in one step is cleaner. The year-based name selection and subsequent observed handling remain correct.

holidays/countries/macau.py (3)

169-184: LGTM! Consistent inlining pattern.

Both Good Friday and Holy Saturday now use direct conditional expressions, eliminating intermediate variables while preserving the year-based Chinese name changes.


233-239: LGTM! Clean inline refactor.

Passing the conditional expression directly maintains the year-based name logic (1999 boundary) without the temporary variable.


369-375: LGTM! Correct translation function usage.

Using tr() for static observed_label assignments is consistent with the pattern used throughout this file for class-level string attributes. The year-based conditional logic remains intact.

holidays/countries/finland.py (1)

218-224: LGTM! Consistent refactoring across all three holidays.

J.V. Snellman Day, Aleksis Kivi Day, and Flag Day of the Finnish Defense Forces all now use inlined conditional expressions. The year-based name evolution logic is preserved correctly in each case.

Also applies to: 250-256, 311-317


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Oct 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (785ce0d) to head (cda1c02).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev     #3014   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          306       306           
  Lines        18072     18063    -9     
  Branches      2333      2333           
=========================================
- Hits         18072     18063    -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small wins that make ultimate difference 👍

LGTM

@arkid15r arkid15r added this pull request to the merge queue Oct 19, 2025
Merged via the queue into vacanza:dev with commit c64ba05 Oct 19, 2025
36 checks passed
@KJhellico KJhellico deleted the ref-vars branch October 19, 2025 20:16
@KJhellico KJhellico mentioned this pull request Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants