-
-
Notifications
You must be signed in to change notification settings - Fork 560
Update IslamicHolidays: add an option whether to add estimation label to holiday name
#2298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #2298 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 204 204
Lines 12560 12562 +2
Branches 1797 1797
=========================================
+ Hits 12560 12562 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ☪️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structure looks good. A couple of points to address:
- this needs to be documented somehow (it's a dangling param at the moment) with a clear indication that the dates are still estimated but the names just don't contain that label
- maybe let's add a
def test_yyyy_no_estimated_label(self):test for better functionality representation in the tests?
Summary by CodeRabbit
WalkthroughThe modifications update various holiday classes to support an optional display of estimated Islamic holiday dates. Each class now accepts an additional parameter, Changes
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (5)
⏰ Context from checks skipped due to timeout of 300000ms (1)
🔇 Additional comments (19)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
IslamicHolidays: add an option whether to add estimation label to holiday nameIslamicHolidays: add an option whether to add estimation label to holiday name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (48)
holidays/countries/afghanistan.py(1 hunks)holidays/countries/albania.py(1 hunks)holidays/countries/algeria.py(1 hunks)holidays/countries/azerbaijan.py(1 hunks)holidays/countries/bahrain.py(1 hunks)holidays/countries/bosnia_and_herzegovina.py(1 hunks)holidays/countries/brunei.py(1 hunks)holidays/countries/burkina_faso.py(1 hunks)holidays/countries/burundi.py(1 hunks)holidays/countries/cameroon.py(1 hunks)holidays/countries/chad.py(1 hunks)holidays/countries/djibouti.py(1 hunks)holidays/countries/egypt.py(1 hunks)holidays/countries/ethiopia.py(1 hunks)holidays/countries/gabon.py(1 hunks)holidays/countries/ghana.py(1 hunks)holidays/countries/india.py(1 hunks)holidays/countries/indonesia.py(1 hunks)holidays/countries/iran.py(1 hunks)holidays/countries/jordan.py(1 hunks)holidays/countries/kazakhstan.py(1 hunks)holidays/countries/kenya.py(1 hunks)holidays/countries/kuwait.py(1 hunks)holidays/countries/kyrgyzstan.py(1 hunks)holidays/countries/malaysia.py(3 hunks)holidays/countries/maldives.py(1 hunks)holidays/countries/mauritania.py(1 hunks)holidays/countries/montenegro.py(1 hunks)holidays/countries/morocco.py(1 hunks)holidays/countries/nigeria.py(1 hunks)holidays/countries/north_macedonia.py(1 hunks)holidays/countries/philippines.py(1 hunks)holidays/countries/saudi_arabia.py(1 hunks)holidays/countries/singapore.py(2 hunks)holidays/countries/spain.py(1 hunks)holidays/countries/sri_lanka.py(1 hunks)holidays/countries/tanzania.py(1 hunks)holidays/countries/timor_leste.py(1 hunks)holidays/countries/tunisia.py(1 hunks)holidays/countries/turkey.py(1 hunks)holidays/countries/united_arab_emirates.py(1 hunks)holidays/countries/uzbekistan.py(1 hunks)tests/countries/test_afghanistan.py(8 hunks)tests/countries/test_albania.py(3 hunks)tests/countries/test_indonesia.py(10 hunks)tests/countries/test_kenya.py(2 hunks)tests/countries/test_philippines.py(3 hunks)tests/countries/test_united_arab_emirates.py(5 hunks)
🔇 Additional comments (93)
tests/countries/test_kenya.py (2)
207-209: Appropriate update for testing without estimated labels.The test now properly creates a Kenya instance with
islamic_show_estimated=Falseto test the holiday names without the "estimated" label.
257-261: Well-structured test for Islamic holidays without estimation label.This test case correctly verifies that the Islamic holiday name is displayed without the "estimated" label when the
islamic_show_estimatedparameter is set to False.holidays/countries/jordan.py (1)
33-40: Clean implementation of the show_estimated parameter.The parameter is well-documented with a proper type hint and default value that maintains backward compatibility. The initialization of the parent class correctly passes the parameter.
holidays/countries/spain.py (1)
81-90: Good implementation of the show_estimated option.The parameter is properly added with documentation and type hints. The initialization of IslamicHolidays passes the parameter correctly while maintaining the custom class parameter.
holidays/countries/djibouti.py (1)
30-37: Well-implemented parameter addition.The implementation follows the same pattern as other country classes, maintaining consistency across the codebase. The parameter is correctly documented and passed to the parent class.
tests/countries/test_albania.py (3)
23-23: Good addition of the no_estimated_holidays instance.This creates a test instance of Albania holidays with Islamic estimated labels turned off, which supports testing both display modes.
129-129: Clean implementation of testing without estimated labels.The test now properly uses the no_estimated_holidays instance to verify holiday names appear correctly without estimated labels.
147-147: Consistent approach for testing Eid al-Adha without estimated labels.Using the same pattern as the Eid al-Fitr test maintains consistency in the test approach.
holidays/countries/azerbaijan.py (2)
47-51: Well-structured parameter addition with good documentation.The parameter is clearly named, has a sensible default value, and includes proper type annotation. The docstring explains the parameter's purpose effectively.
53-55: Correct implementation of the parameter passing.The parameter is properly passed to the IslamicHolidays superclass, maintaining the connection between the user-facing option and the internal implementation.
tests/countries/test_philippines.py (3)
24-26: Good creation of Philippines test instance without estimated labels.Consistent with the pattern used in other test files, providing proper test coverage for the new feature.
283-284: Clean replacement of the previous testing approach.The test now properly verifies holiday names without estimated labels for Eid al-Fitr across the defined year ranges.
300-301: Consistent approach for testing Eid al-Adha without estimated labels.The same pattern is properly applied to the Eid al-Adha test, ensuring both Islamic holidays are tested consistently.
holidays/countries/ghana.py (2)
33-37: Good parameter addition with clear documentation.The islamic_show_estimated parameter is properly added with type annotation and default value. The docstring clearly explains its purpose.
40-40: Correct implementation of parameter passing to IslamicHolidays.The parameter is properly forwarded to the IslamicHolidays superclass initialization.
holidays/countries/cameroon.py (2)
39-43: Clean implementation of the new parameterThe parameter is well-documented and has a clear purpose.
46-48: Proper implementation of the parent class initializationGood job passing the new parameter to the IslamicHolidays initialization.
holidays/countries/chad.py (2)
38-42: Well-structured parameter documentationThe parameter documentation clearly explains the purpose of the option.
45-47: Consistent implementation across classesThe parameter is passed correctly to the parent class, maintaining consistency with other country implementations.
holidays/countries/gabon.py (2)
32-36: Clear parameter documentationThe parameter documentation is clear and consistent with other implementations.
39-41: Proper parameter passing to parent classGood implementation of passing the parameter to the IslamicHolidays initialization.
holidays/countries/philippines.py (3)
63-67: Consistent parameter implementationThe parameter is well-documented and matches the implementation in other country classes.
71-73: Correct parent class initializationThe parameter is correctly passed to the IslamicHolidays initialization.
59-60:❓ Verification inconclusive
Verify this estimated_label is used by IslamicHolidays
The class already has an
estimated_labelproperty. Make sure the IslamicHolidays class uses this property whenshow_estimatedis True.
🏁 Script executed:
#!/bin/bash # Search for where the estimated_label is used in IslamicHolidays rg -A 15 'estimated_label' --glob '*.py' | grep -B 5 -A 15 'class IslamicHolidays'Length of output: 82
Manual Verification Required: Confirm
estimated_labelUsage in IslamicHolidaysIt appears that our automated search didn’t uncover any usage of the
estimated_labelproperty within theIslamicHolidaysclass. Please manually verify that whenshow_estimatedis True, the class indeed applies theestimated_labelvalue as intended.
- Location:
holidays/countries/philippines.py(lines 59-60) defines theestimated_label.- Action: Confirm that within the definition or methods of the
IslamicHolidaysclass, theestimated_labelproperty is used correctly whenshow_estimatedis True.- Suggestion: If it isn’t currently being used, update the
IslamicHolidaysimplementation accordingly.holidays/countries/burundi.py (1)
33-40: Consistent implementation of the new parameterThe added parameter
islamic_show_estimatedwith proper typing and default value follows good practices. The docstring clearly explains the parameter's purpose.holidays/countries/saudi_arabia.py (1)
54-59: Good parameter implementation with clear documentationThe addition of the
islamic_show_estimatedparameter with proper typing and documentation aligns with the PR objectives to enhance flexibility for Islamic holiday representations.holidays/countries/united_arab_emirates.py (1)
65-73: Properly implemented parameter with clear documentationThe addition of the
islamic_show_estimatedparameter with default value and docstring is consistent with other country implementations. I appreciate the multi-line call toIslamicHolidays.__init__()which keeps the code readable even with multiple parameters.holidays/countries/indonesia.py (1)
65-76: Clean implementation of the configurable estimated label featureThe addition of the
islamic_show_estimatedparameter with proper documentation is consistent with the other country implementations. The parameter is correctly passed to theIslamicHolidaysconstructor.holidays/countries/bosnia_and_herzegovina.py (1)
76-85: Consistent implementation of the estimation label featureThe parameter addition for controlling the display of the estimated label is well-implemented. The type hinting, default value, and docstring provide clear guidance on the parameter's purpose.
holidays/countries/maldives.py (1)
29-35: Parameter implementation looks goodThe addition of the
islamic_show_estimatedparameter with its default value and docstring is appropriately implemented. This matches the pattern seen in other country classes.holidays/countries/burkina_faso.py (1)
31-40: Clear and consistent parameter implementationThe implementation of the
islamic_show_estimatedparameter is well-structured with proper documentation. The parameter is correctly passed to theIslamicHolidaysinitialization with the custom class.holidays/countries/albania.py (1)
49-58: Properly implemented parameter controlThe parameter addition follows the same pattern as other country classes. The implementation provides users flexibility in controlling Islamic holiday display labels without affecting other functionality.
holidays/countries/afghanistan.py (1)
51-59: Consistent parameter implementation enhances user control over holiday naming.The addition of the
islamic_show_estimatedparameter with a default value ofTrueprovides good flexibility for controlling how Islamic holidays with estimated dates are displayed.holidays/countries/nigeria.py (1)
34-41: Parameter implementation is consistent with other country classes.The implementation properly allows users to control whether estimated labels appear on Islamic holidays, maintaining consistency with the pattern established in other country classes.
holidays/countries/iran.py (1)
53-60: Implementation maintains consistency with other country classes.The changes here correctly implement the new parameter while preserving the existing class-specific customization through the
clsparameter.holidays/countries/north_macedonia.py (1)
25-33: Clean implementation follows established pattern.The parameter addition and docstring follow the same pattern as the other country classes, ensuring a consistent API throughout the codebase.
holidays/countries/mauritania.py (2)
28-34: Good implementation of the estimation labeling option.The code adds a well-documented parameter
islamic_show_estimatedthat allows users to control whether Islamic holidays are marked as estimated.
34-34: Clean implementation passing the parameter to IslamicHolidays.The parameter is properly forwarded to the IslamicHolidays constructor, ensuring the feature works correctly.
holidays/countries/kuwait.py (2)
34-40: Good implementation of the Islamic holiday estimation label option.The parameter addition is consistent with the PR objectives and follows the same pattern as other country implementations.
40-40: Properly passes the parameter to IslamicHolidays.The parameter is correctly forwarded as
show_estimatedto the IslamicHolidays constructor.holidays/countries/turkey.py (1)
41-49: Good implementation of the estimation labeling option with TurkeyIslamicHolidays.The new parameter is added while preserving the custom Islamic holidays class. The multiline call format improves readability.
holidays/countries/tanzania.py (1)
70-79: Good implementation of the Islamic holiday estimation label option.The new parameter is properly documented and passed correctly to IslamicHolidays along with the custom Tanzania implementation.
holidays/countries/sri_lanka.py (1)
90-100: Implementation ofislamic_show_estimatedparameter looks good.Clear parameter documentation and correct implementation in the IslamicHolidays initialization. This addition gives users control over the display of estimated labels for Islamic holidays.
holidays/countries/morocco.py (1)
34-40: Parameter implementation is consistent with design pattern.The
islamic_show_estimatedparameter is well-documented and correctly passed to the IslamicHolidays initialization, maintaining consistency with other country classes.holidays/countries/tunisia.py (1)
28-35: Good implementation of the optional estimation label feature.The parameter is properly documented and correctly passed to the IslamicHolidays class. This enhances the flexibility of Islamic holiday representations.
holidays/countries/algeria.py (1)
36-43: Implementation matches other country classes.The
islamic_show_estimatedparameter follows the same pattern used throughout the codebase. Documentation is clear and the parameter is correctly passed to IslamicHolidays.holidays/countries/kyrgyzstan.py (1)
28-35: Feature implementation looks correct and complete.The changes correctly implement the ability to control whether estimated labels are shown for Islamic holidays. The parameter is well-documented with proper type annotation.
holidays/countries/singapore.py (2)
50-54: Implementation is consistent with project patterns.The new parameter is properly typed and documented, matching the implementation across other country classes.
92-94: Good restructuring for improved readability.The multi-line format for the IslamicHolidays init call improves code readability while adding the new parameter.
holidays/countries/bahrain.py (1)
37-45: Feature implementation is correct and improves flexibility.The changes effectively implement the option to control showing estimated labels for Islamic holidays. Both the parameter addition and multi-line formatting improve code quality.
holidays/countries/timor_leste.py (1)
54-63: Implementation matches other country classes perfectly.The changes follow the same pattern as other country classes, showing consistent implementation across the codebase. The parameter is properly typed and documented, and the multi-line formatting improves readability.
holidays/countries/montenegro.py (2)
56-60: Clear and well-documented parameter additionThe new parameter
islamic_show_estimatedis clearly defined with a sensible default value and well documented. This enhances the API usability.
64-66: Parameter correctly passed to superclassGood implementation of passing the new parameter to the
IslamicHolidaysinitializer.tests/countries/test_afghanistan.py (7)
25-27: Good test setup for the new parameterCreating a separate test instance with
islamic_show_estimated=Falseis a clean approach to testing both behaviors.
114-115: Effective use of the no_estimated_holidays instanceWell implemented test that verifies holiday names without the estimated label.
134-134: Consistent testing patternMaintaining the same testing approach for all Islamic holidays ensures complete coverage of the new feature.
152-152: Consistent testing patternConsistent approach for testing the First Day of Ramadan.
192-192: Consistent testing patternConsistent approach for testing Eid al-Fitr.
210-210: Consistent testing patternConsistent approach for testing Arafah Day.
250-250: Consistent testing patternConsistent approach for testing Eid al-Adha.
holidays/countries/kenya.py (2)
56-60: Well-implemented parameter additionThe parameter implementation is clear and consistent with the pattern used in other country classes.
64-66: Parameter correctly passed to superclassGood implementation of passing the parameter to the
IslamicHolidayssuperclass.holidays/countries/kazakhstan.py (3)
95-99: Consistent parameter implementationThe parameter follows the same pattern established in other country classes, maintaining codebase consistency.
102-104: Parameter correctly passed to superclassGood implementation of passing the parameter to the
IslamicHolidaysinitializer.
95-104:✅ Verification successful
Verify change impact across other Islamic holidays
You should verify that the change properly affects the "Eid al-Adha" holiday that's being added at line 176.
🏁 Script executed:
#!/bin/bash # Check if the `show_estimated` parameter is being used in IslamicHolidays class # Search for the IslamicHolidays class implementation to understand how show_estimated is used echo "Checking IslamicHolidays class implementation:" rg -A 15 "class IslamicHolidays" --type py # Check the eid_al_adha_day method specifically echo -e "\nChecking eid_al_adha_day method:" rg "_add_eid_al_adha_day" --type pyLength of output: 9231
Action: Confirm Eid al-Adha Behavior with
show_estimatedParameterAfter reviewing the changes, the
IslamicHolidaysclass correctly accepts and stores theshow_estimatedparameter, and its usage (including in the_add_eid_al_adha_daymethod) is consistent across several country modules. In the Kazakhstan file, the instantiation:
- Passes
islamic_show_estimatedintoIslamicHolidays.__init__- Ultimately calls
_add_eid_al_adha_day(as seen at line 176), matching the pattern observed in other countriesPlease verify at runtime that the "estimated" label is applied as expected for Eid al-Adha when the parameter is enabled. Overall, the change impact on Islamic holidays appears correct.
holidays/countries/india.py (2)
74-78: Parameter addition looks goodThe new parameter
islamic_show_estimatedis well-defined with proper type annotation and a clear docstring explaining its purpose. This enhancement allows users to control whether estimated labels are shown for Islamic holidays.
80-80: Correctly implements the parameter usageThe parameter is correctly passed to the
IslamicHolidaysinitializer, maintaining consistent behavior across the inheritance chain.holidays/countries/malaysia.py (4)
13-13: Appropriate import additionAdding the
dateimport fromdatetimeis necessary to support the type annotation added later in the file.
129-133: Parameter addition is well-documentedThe new parameter
islamic_show_estimatedis clearly defined with an appropriate type annotation and helpful docstring.
154-156: Parameter correctly passed to superclassThe implementation properly passes the new parameter to the
IslamicHolidaysinitializer, ensuring consistent behavior.
160-160: Enhanced type annotationAdding the type hint
set[date]forself.dts_observedimproves code clarity and aids static analysis tools.holidays/countries/egypt.py (2)
38-42: Parameter addition with clear documentationThe new parameter
islamic_show_estimatedis well-defined with proper type annotation and helpful docstring explaining its purpose.
45-45: Correctly implements the new parameterThe parameter is properly passed to the
IslamicHolidaysinitializer, maintaining consistent behavior.holidays/countries/brunei.py (2)
133-137: Parameter addition is consistent with other classesThe new parameter
islamic_show_estimatedis well-defined with proper type annotation and clear docstring, consistent with implementations in other country classes.
141-143: Parameter correctly passed to superclassThe implementation properly passes the new parameter to the
IslamicHolidaysinitializer while maintaining the existingclsparameter.holidays/countries/uzbekistan.py (1)
41-49: Parameter addition for Islamic holiday estimation controlThe addition of this parameter provides good flexibility for controlling whether to show "estimated" labels on Islamic holidays. The implementation correctly passes this parameter to the IslamicHolidays superclass.
tests/countries/test_indonesia.py (10)
24-26: Good test setup for no-estimated holiday testingCreating a separate instance with
islamic_show_estimated=Falseallows for clean testing of holiday names without estimation labels.
307-309: Cleaner test method implementationUsing unpacked range generators makes the code more concise while maintaining readability.
371-372: Direct holiday name assertion is clearerPassing the string directly into the assertion makes the code more straightforward.
404-405: Proper use of new no_estimated_holidays instanceUsing the instance created with
islamic_show_estimated=Falsecorrectly tests the functionality of holiday names without estimated labels.
418-419: Consistent testing approach for second daySame approach applied consistently for the second day of Eid al-Fitr.
432-433: Consistent pattern applied to Eid al-AdhaThe same testing pattern is correctly applied across all Islamic holidays.
448-453: Thorough date range testingTesting multiple date ranges ensures the implementation works correctly across different historical periods.
465-470: Consistent testing pattern for Prophet's BirthdayTesting pattern remains consistent across all Islamic holidays, maintaining good test structure.
483-488: Comprehensive coverage for Isra and MirajTests cover both the presence and absence of holidays in appropriate year ranges.
504-507: Proper Islamic New Year testingTesting both positive and negative cases across appropriate year ranges.
holidays/countries/ethiopia.py (1)
46-55: Consistent parameter implementation across country classesThe implementation follows the same pattern as other country classes, maintaining consistency in the codebase. Good docstring explaining the parameter's purpose.
tests/countries/test_united_arab_emirates.py (6)
24-26: Test setup for UAE follows consistent patternCreating the no_estimated_holidays instance follows the same pattern used in other country tests, ensuring consistency across the test suite.
85-87: Simplified holiday assertions for Eid al-FitrThe direct holiday name assertions are cleaner and more straightforward than previous implementation that required checking year sets.
103-106: Comprehensive test coverage for Eid al-Adha and related holidaysTesting multiple related holidays ensures complete functionality coverage.
121-122: Simplified Islamic New Year assertionsDirect assertion with the no_estimated_holidays instance makes the test simpler and more maintainable.
137-138: Consistent testing for Prophet's BirthdayMaintains consistent testing pattern across all Islamic holidays.
142-143: Comprehensive testing for Isra and MirajTests both presence in early years and absence in later years, ensuring accuracy across the entire year range.
# Conflicts: # holidays/countries/indonesia.py
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍



Proposed change
Update
IslamicHolidays: add an option whether to add estimation label to holiday name.I believe that this feature is useful not only for testing, but also for real use.
Type of change
holidaysfunctionality in general)Checklist
make check, all checks and tests are green