Skip to content
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

Refactor HolidayBase class and utils #815

Merged
merged 8 commits into from
Feb 1, 2023

Conversation

arkid15r
Copy link
Collaborator

@arkid15r arkid15r commented Dec 2, 2022

This PR aims to simplify and optimize PH foundational code logic.

It covers holiday_base.py and utils.py. The main points are:

  • Optimize branching.
  • Remove unneeded casting/copying.
  • Add _add_observed_holiday method.
  • Optimize methods:
    • __setattr__
    • __keytransform__
    • __getitem__
    • __setitem__
    • get_named
    • update
    • __repr__
    • __str__
  • Simplify utils.country_holidays country/market lookup logic.
  • Fix minor issues (style, grammar, punctuation).
  • Clean up unused code.

I'd like to request @dr-prodigy (obviously), @kasya, @KJhellico, @mborsetti consider reviewing it. Feel free to jump in even if you weren't tagged but have comments regarding this change.

Thank you!

  - Optimize branching.
  - Remove unneeded casting/copying.
  - Add `_add_observed_holiday` method.
  - Optimize methods:
    - `__setattr__`
    - `__keytransform__`
    - `__getitem__`
    - `__setitem__`
    - `get_named`
    - `update`
    - `__repr__`
    - `__str__`
  - Simplify `utils.country_holidays` country/market lookup logic.
  - Fix minor issues (style, grammar, punctuation).
  - Clean up unused code.
@coveralls
Copy link

coveralls commented Dec 2, 2022

Coverage Status

Coverage: 100.0%. Remained the same when pulling dcef913 on arkid15r:base-class-refactoring into f16437f on dr-prodigy:beta.

@mborsetti
Copy link
Contributor

@arkid15r

Wow, that's a lot of good edits. 👍

I can't find any apparent faults with it, but realize that while I wrote util._islamic_to_gre to return a list, it could/should probably return a generator instead.

@arkid15r
Copy link
Collaborator Author

arkid15r commented Dec 7, 2022

Thanks for the review, @mborsetti!

util._islamic_to_gre to return a list, it could/should probably return a generator instead.

That's a good point, done!

@dr-prodigy
Copy link
Collaborator

So good work! I could not check every single row, but all looks fine to me! Thank you @arkid15r 👍

KJhellico added a commit to KJhellico/python-holidays that referenced this pull request Jan 29, 2023
- fix for holidays that happen twice in a Gregorian year (primarily islamic New Year)
- years range checking more strictly
- utils._islamic_to_gre() refactoring from vacanza#815 (except returning value type change)
@arkid15r arkid15r added the ready for beta Ready to merge on beta branch label Jan 31, 2023
@arkid15r arkid15r changed the title Base class refactoring Refactor HolidayBase class and utils Feb 1, 2023
@arkid15r arkid15r merged commit e93d064 into vacanza:beta Feb 1, 2023
@arkid15r arkid15r deleted the base-class-refactoring branch February 1, 2023 17:23
@arkid15r arkid15r removed the ready for beta Ready to merge on beta branch label Feb 1, 2023
This was referenced Feb 20, 2023
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.

4 participants