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

Add supported countries tests #878

Merged
merged 3 commits into from
Jan 16, 2023

Conversation

arkid15r
Copy link
Collaborator

  • Add README.rst country count test
  • Add README.rst supported countries tests
  • Add UK back to the list of supported countries
  • Sort HolidayBase::subdivisions
  • Fix supported countries table formatting

  - Add README.rst country count test
  - Add README.rst supported countries tests
  - Add `UK` back to the list of supported countries
  - Sort `HolidayBase::subdivisions`
  - Fix supported countries table formatting
@coveralls
Copy link

Coverage Status

Coverage: 100.0%. Remained the same when pulling 107c750 on arkid15r:supported-countries-tests into 1a2e5ee on dr-prodigy:beta.

@arkid15r arkid15r merged commit 6e0ed3d into vacanza:beta Jan 16, 2023
@arkid15r arkid15r deleted the supported-countries-tests branch January 16, 2023 18:01
@arkid15r arkid15r mentioned this pull request Jan 30, 2023
@@ -272,7 +272,7 @@ def CountryHoliday(
)


def list_supported_countries() -> Dict[str, List[str]]:
def list_supported_countries(unique=False) -> Dict[str, List[str]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

@arkid15r I am working on #998 and need to update this function, but stumbled on this unique=False addition which I find zero documentation about (not even in the docstring!).

Since it's undocumented the default is to drop it. Thoughts?

Also, a good reminder that nothing should be released (PR merged) unless it's thoroughly documented, and we're probably a bit behind in that front.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's always a good idea to search for existing references before deletion even if there is no documentation about something. I'd do it first in general and for sure in this particular case (as it's definitely in use).

If you allow, I generalize your reminder re. thorough documentation and lift it to another level: any PR should go through a thorough review. This PR had been sitting in the queue for about half a month before I merged it. It seems that I focused on tests improvements and missed the documentation part.

The good news is that the team has grown since that time so we are able to do regular reviews for [almost] every PR.

As for the fix -- I'll add the docstring, shouldn't be too hard to implement.
Thanks for bringing this up, Mike!

Copy link
Contributor

Choose a reason for hiding this comment

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

It's always a good idea to search for existing references before deletion even if there is no documentation about something. I'd do it first in general and for sure in this particular case (as it's definitely in use).

Wise words.

If you allow, I generalize your reminder re. thorough documentation and lift it to another level: any PR should go through a thorough review. This PR had been sitting in the queue for about half a month before I merged it. It seems that I focused on tests improvements and missed the documentation part.

Wiser words.

As for the fix -- I'll add the docstring, shouldn't be too hard to implement.

Please wait. I found all references (all are in testing) and the unique argument may no longer be needed if I can get the lazy loading to work (stuck on one particular aspect at the moment).

Thanks for all the great work Arkadii!

@@ -281,13 +281,13 @@ def list_supported_countries() -> Dict[str, List[str]]:
the value is a list of supported subdivision codes.
"""
return {
cls.country: cls.subdivisions
cls.country if unique else name: cls.subdivisions
Copy link
Contributor

Choose a reason for hiding this comment

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

@arkid15r this code generates a Set when unique is set, which does not conform to the declared return type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Couldn't reproduce that:

>>> import holidays
>>> holidays.__version__
'0.22'
>>> type(holidays.list_supported_countries(unique=True))
<class 'dict'>

for name, cls in inspect.getmembers(countries, inspect.isclass)
if len(name) == 2 and issubclass(cls, HolidayBase)
}


def list_supported_financial() -> Dict[str, List[str]]:
def list_supported_financial(unique=False) -> Dict[str, List[str]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

See above

@@ -296,8 +296,8 @@ def list_supported_financial() -> Dict[str, List[str]]:
the value is a list of supported subdivision codes.
"""
return {
cls.market: cls.subdivisions
for _, cls in inspect.getmembers(financial, inspect.isclass)
cls.market if unique else name: cls.subdivisions
Copy link
Contributor

Choose a reason for hiding this comment

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

See above

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