+
Skip to content

Conversation

KJhellico
Copy link
Collaborator

Proposed change

Refactor imports in certain countries: use TYPE_CHECKING.

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

Copy link
Contributor

coderabbitai bot commented Sep 20, 2025

Summary by CodeRabbit

  • Chores

    • Updated tooling configuration to preserve runtime typing hints during automated upgrades.
  • Refactor

    • Modernized internal type-hinting and import handling across multiple country holiday modules. No changes to behavior or public APIs.
  • Style

    • Minor formatting and lint adjustments to improve readability and consistency. No functional impact.

Walkthrough

Adds postponed evaluation of annotations and TYPE_CHECKING-guarded date imports across several country holiday modules; updates pre-commit pyupgrade args to keep runtime typing. taiwan.py also reformats a method signature and adds a lint suppression. No runtime behavior or public API changes.

Changes

Cohort / File(s) Summary of changes
Pre-commit tooling
\.pre-commit-config.yaml
Added pyupgrade arg --keep-runtime-typing.
Typing/annotations updates — multiple countries
holidays/countries/bulgaria.py, holidays/countries/rwanda.py, holidays/countries/south_korea.py, holidays/countries/tanzania.py, holidays/countries/tonga.py, holidays/countries/trinidad_and_tobago.py, holidays/countries/uruguay.py, holidays/countries/vietnam.py
Added from __future__ import annotations; introduced from typing import TYPE_CHECKING and moved from datetime import date into if TYPE_CHECKING: blocks. No logic or API changes.
Taiwan: typing + signature formatting
holidays/countries/taiwan.py
Same typing updates; reformatted _populate_observed signature to multi-line and added # noqa:UP045 on the rule parameter. Behavior unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • PPsyrius

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title is concise and accurately summarizes the primary change — refactoring imports in certain country modules to use typing.TYPE_CHECKING — and aligns with the file-level summaries showing TYPE_CHECKING guards and postponed annotations added across multiple country modules.
Description Check ✅ Passed The pull request description clearly states the proposed change (refactoring imports to use TYPE_CHECKING), classifies it as a code-quality refactor, and notes that local checks passed, which matches the changes and objectives summarized for the PR.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • 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 e5de4d0 and 4f33b1b.

📒 Files selected for processing (1)
  • .pre-commit-config.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: KJhellico
PR: vacanza/holidays#2631
File: tests/countries/test_sint_maarten.py:62-0
Timestamp: 2025-06-14T21:12:07.224Z
Learning: KJhellico prefers to focus on completing and reviewing the main holiday implementation code before doing detailed reviews of the corresponding test files.
Learnt from: KJhellico
PR: vacanza/holidays#2833
File: tests/countries/test_uganda.py:15-0
Timestamp: 2025-08-20T19:46:15.625Z
Learning: In the holidays project, the standard import pattern for country test files is `from holidays.countries.<country> import Country, CODE1, CODE2` (direct module import), used by ~75% of country test files. Only a minority (~25%) use the aggregated public API import `from holidays.countries import Country, CODE1, CODE2`. The direct module import pattern should be used for new country test files to follow the established convention.
📚 Learning: 2025-06-16T15:48:33.931Z
Learnt from: PPsyrius
PR: vacanza/holidays#2615
File: tests/countries/test_anguilla.py:20-24
Timestamp: 2025-06-16T15:48:33.931Z
Learning: The holidays project uses `make pre-commit` test which includes `ruff` as the primary linter. If `ruff` passes, then Pylint warnings that don't appear in `ruff` are considered acceptable and can be ignored.

Applied to files:

  • .pre-commit-config.yaml
⏰ 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.13 on windows-latest
🔇 Additional comments (1)
.pre-commit-config.yaml (1)

25-26: Approve — keep --keep-runtime-typing

pyupgrade v3.20.0 supports --keep-runtime-typing, and Ruff treats imports inside if TYPE_CHECKING: as type-only (won’t raise F401 by default).


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.

Copy link

codecov bot commented Sep 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f322abc) to head (4f33b1b).
⚠️ Report is 3 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##               dev     #2949    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          296       299     +3     
  Lines        17652     17842   +190     
  Branches      2271      2295    +24     
==========================================
+ Hits         17652     17842   +190     

☔ 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.

PPsyrius
PPsyrius previously approved these changes Sep 20, 2025
Copy link
Collaborator

@PPsyrius PPsyrius left a comment

Choose a reason for hiding this comment

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

LGTM 🛠️

Copy link

@arkid15r arkid15r added this pull request to the merge queue Sep 20, 2025
Merged via the queue into vacanza:dev with commit d891f60 Sep 20, 2025
36 checks passed
@KJhellico KJhellico deleted the ref-type-checking branch September 21, 2025 09:41
@arkid15r arkid15r mentioned this pull request Oct 6, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 9, 2025
9 tasks
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.

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载