Scope Warning handling in tests to DeprecationWarning#3541
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughUpdated deprecation warnings and tests: tests now assert Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 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 #3541 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 313 313
Lines 18693 18693
Branches 2389 2389
=========================================
Hits 18693 18693 ☔ 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/eswatini.py`:
- Around line 75-77: The DeprecationWarning in Swaziland.__init__ uses
stacklevel=3 which points one frame too high; update the warnings.warn call in
the Swaziland constructor to use stacklevel=2 so the warning references the
caller that invoked Swaziland(), keeping the same message and warning class
(DeprecationWarning).
In `@holidays/countries/south_korea.py`:
- Around line 290-292: The deprecation warning in Korea.__init__ uses
stacklevel=3 which points one frame too far; update the warnings.warn call
inside the Korea class (the "Korea is deprecated, use SouthKorea instead."
warning) to use stacklevel=2 so the reported location points to the direct
caller (test code) instantiating Korea().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: de07812c-d386-4c26-abe1-42964529edef
📒 Files selected for processing (3)
holidays/countries/eswatini.pyholidays/countries/south_korea.pyholidays/utils.py
|
Proposed change
KoreaandSwazilandonly emitDeprecationWarning, we can narrow our test assertions fromWarningtoDeprecationWarning. I spotted this earlier while working on Refactor India holidays testcases #3524.# mypy: disable-error-code=attr-definedfortest_solomon_islands.pystacklevelfor warnings so that they actually warn where it matters:Warning (from warnings module): File "D:\python-holidays\New Python Script.py", line 4 xx_public = holidays.Korea(years=2000) DeprecationWarning: Korea is deprecated, use SouthKorea instead.Warning (from warnings module): File "D:\python-holidays\New Python Script.py", line 4 xx_public = holidays.Swaziland(years=2000) DeprecationWarning: Swaziland is deprecated, use Eswatini instead.Note
The other 2
warnings.warninHolidayBaseare not getting thestackleveltreatment because the inheritance chain (ObservedHolidayBase\NoHolidayBase) alters the call stack depth, which would cause warnings to still point to incorrect call sites.Type of change
holidaysfunctionality in general)Checklist
make checklocally; all checks and tests passed.