-
Notifications
You must be signed in to change notification settings - Fork 462
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
Use setdefault instead of hard-coding observed_rule and observed_since #1521
Conversation
70557fd
to
ef3f3ef
Compare
Sorry about the force pushes. Didn't realize what I was doing when I clicked the Update branch button. Been a while since I used GitHub. |
ef3f3ef
to
9cc4635
Compare
Rebased to resolve merge conflicts. |
9cc4635
to
1d973b7
Compare
Hi @BossColo, The implementation is clean and pretty straightforward, I have a question about the motivation though: do you have an example when a user would need to override those values? I agree, it may be great to have the proposed Anyway, I'd like to hear more opinions here as I'm not convinced this is beneficial in a long term run. @KJhellico, @PPsyrius could you also look into this? Thank you! |
My personal use case stems from the fact that I work for a Canadian company with a worldwide footprint. The company has decided that for all jurisdictions, we will use the SAT_SUN_TO_NEXT_MON rule, regardless of the country in question. So if I want to use this library for US holidays, I have to override the __init__ method for the US class. |
1d973b7
to
2407da2
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Thanks for providing more context, @BossColo. It may be weird but totally legit use case. Apparently, sometimes the library doesn't have to be the source of truth for holidays data. Thank you for the clean PR and your first contribution! |
Thank you for the kind words, and for the fantastic library! |
Proposed change
Instead of calling super().init() from countries with hard-coded values for override_rule and override_since, use kwargs.setdefaults() to add a value if one isn't passed in. This allows for users to set their own override_rule and override_since if desired.
Type of change
Checklist
make pre-commit
command generates no changesmake test
,make tox
(we strongly encourage adding tests to your code)