question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

If state doesn't exist, it should raise an error

See original GitHub issue

This is confusing:

>>> import date
>>> import holidays
>>> date(2021,3,8) in holidays.CountryHoliday("DE", state="BE")    # should raise an error, because state="BE" does not exist
False
>>> date(2021,3,8) in holidays.CountryHoliday("DE", prov="BE")
True

The first line after the imports should better raise an error, because for Germany one has to use prov and not state. At the moment this leads to subtle bugs in computing wether a day is a holiday or not.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mborsetticommented, Jan 18, 2022

Hi Maurizio/@dr-prodigy! I agree with subdiv, which is why I gave you three choices! 😃

#586 is fixed; I will be handling this next in my spare time.

1reaction
mborsetticommented, Jan 13, 2022

@dr-prodigy I have a proposed solution.

According to the README, we don’t have a single country where we use both state and prov. Since this is the case, I propose we simplify everything by conforming to ISO 3166-2 and call these subdivisions (argument name subdivision or subd) and make everything simple.

We can maintain backwards compatibility by assigning the value of either state or prov, if specified, to subdivision.

If you agree I can do global changes this weekend and submit a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

when other than exception, and raise application error
What I'm trying to say there is - if the error is raised, caught and handled (not re-raised to the client) by PLSQL...
Read more >
How to implement error handling in SQL Server - SQLShack
This article explains how to implement SQL error handling using the SQL server try-catch statement and what can be done in general when...
Read more >
Why doesn't python throw an exception when you set an ...
It will throw an error as expected. So why does this functionality exist in the first place, to be able to create a...
Read more >
Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >
Built-in Exceptions — Python 3.11.1 documentation
In Python, all exceptions must be instances of a class that derives from ... an error condition “just like” the situation in which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found