Repository: vacanza/python-holidays

Issue:
Error with Austrian holidays from version 0.22
```
import holidays
at_holidays = holidays.AT(state=9)
'2023-12-25' in at_holidays
```

This code works fine up to version 0.21.13, but breaks at version 0.22 and above:

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/holidays/holiday_base.py", line 406, in __contains__
    cast("Mapping[Any, Any]", self), self.__keytransform__(key)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/holidays/holiday_base.py", line 384, in __keytransform__
    self._populate(dt.year)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/holidays/countries/austria.py", line 34, in _populate
    super()._populate(year)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/holidays/holiday_base.py", line 794, in _populate
    self._add_subdiv_holidays()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/holidays/holiday_base.py", line 764, in _add_subdiv_holidays
    self, f"_add_subdiv_{self.subdiv.lower()}_holidays", None
AttributeError: 'int' object has no attribute 'lower'
```

It's the same in Python 3.9. I got the error on MacOS Catalina as well as FreeBSD 13.2


Discussion:
I got somewhat a similar error. 
AttributeError: module 'holidays' has no attribute 'CountryHoliday'

The same code was working just a couple of days ago on OSX. Now I have the same exact line on another OS (Debian), same error. 
Hi @georgpfolz,
thanks for the report!

The `state` arg has been deprecated for a while. You can use either `at_holidays = holidays.AT(subdiv=9)` or `at_holidays = holidays.AT(state="9")` to avoid the error. 

I'll look into what can be done to improve the subdivision handling on our side.

Thank you!

> I got somewhat a similar error. AttributeError: module 'holidays' has no attribute 'CountryHoliday'
> 
> The same code was working just a couple of days ago on OSX. Now I have the same exact line on another OS (Debian), same error.

Hi @hinson-x, 
this doesn't look the same to me. Could you file a separate issue w/ a detailed description?

Thank you!
Hello @arkid15r 
Actually I found the issue. I was not too smart where I named my new test python file holiday.py too, so it was trying to.... import itself thus not finding any functions/attributes. Thanks anyhow, appreciate it.

Resolving patch:
diff --git a/holidays/countries/austria.py b/holidays/countries/austria.py
--- a/holidays/countries/austria.py
+++ b/holidays/countries/austria.py
@@ -26,11 +26,11 @@ class Austria(HolidayBase, ChristianHolidays, InternationalHolidays):
     def __init__(self, *args, **kwargs) -> None:
         ChristianHolidays.__init__(self)
         InternationalHolidays.__init__(self)
-        if isinstance(kwargs.get("subdiv"), int):
-            kwargs["subdiv"] = str(kwargs["subdiv"])
-        # Default subdivision to "9"
+
+        # Set the default subdivision.
         if not kwargs.get("subdiv", kwargs.get("state")):
             kwargs["subdiv"] = "9"
+
         super().__init__(*args, **kwargs)
 
     def _populate_public_holidays(self):
diff --git a/holidays/holiday_base.py b/holidays/holiday_base.py
--- a/holidays/holiday_base.py
+++ b/holidays/holiday_base.py
@@ -298,13 +298,18 @@ def __init__(
                 DeprecationWarning,
             )
 
+        if isinstance(self.subdiv, int):
+            self.subdiv = str(self.subdiv)
+
         if not isinstance(self, HolidaySum):
-            if subdiv and subdiv not in set(self.subdivisions + self._deprecated_subdivisions):
-                if hasattr(self, "market"):
-                    error = f"Market '{self.market}' does not have subdivision " f"'{subdiv}'"
-                else:
-                    error = f"Country '{self.country}' does not have subdivision " f"'{subdiv}'"
-                raise NotImplementedError(error)
+            if self.subdiv and self.subdiv not in set(
+                self.subdivisions + self._deprecated_subdivisions
+            ):
+                raise NotImplementedError(
+                    f"Market {self.market} does not have subdivision {self.subdiv}"
+                    if hasattr(self, "market")
+                    else f"Country {self.country} does not have subdivision {self.subdiv}"
+                )
 
             if subdiv and subdiv in self._deprecated_subdivisions:
                 warnings.warn(


Test patch:
diff --git a/tests/countries/test_austria.py b/tests/countries/test_austria.py
--- a/tests/countries/test_austria.py
+++ b/tests/countries/test_austria.py
@@ -9,6 +9,8 @@
 #  Website: https://github.com/dr-prodigy/python-holidays
 #  License: MIT (see LICENSE file)
 
+import warnings
+
 from holidays.constants import BANK
 from holidays.countries.austria import Austria, AT, AUT
 from tests.common import TestCase
@@ -149,9 +151,12 @@ def test_bank_2022(self):
             ("2022-12-31", "Silvester"),
         )
 
-    def test_subdiv(self):
-        at_holidays = Austria(subdiv=1)
-        self.assertEqual("1", at_holidays.subdiv)
+    def test_subdivisions(self):
+        warnings.simplefilter("ignore", category=DeprecationWarning)
+        for code in (9, "9", "", None):
+            self.assertEqual(AT(prov=code).subdiv, "9")
+            self.assertEqual(AT(state=code).subdiv, "9")
+            self.assertEqual(AT(subdiv=code).subdiv, "9")
 
     def test_l10n_default(self):
         self.assertLocalizedHolidays(