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

Migrate deprecated Italy subdivisions to subdivision aliases #1951

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ All other default values are highlighted with bold:
- OPTIONAL, SCHOOL
* - Italy
- IT
- Provinces: AG, AL, AN, AO, AP, AQ, AR, AT, AV, BA, BG, BI, BL, BN, BO, BR, BS, BT, BZ, CA, CB, CE, CH, CL, CN, CO, CR, CS, CT, CZ, EN, FC, FE, FG, FI, FM, FR, GE, GO, GR, IM, IS, KR, LC, LE, LI, LO, LT, LU, MB, MC, ME, MI, MN, MO, MS, MT, NA, NO, NU, OR, PA, PC, PD, PE, PG, PI, PN, PO, PR, PT, PU, PV, PZ, RA, RC, RE, RG, RI, RM, RN, RO, SA, SI, SO, SP, SR, SS, SU, SV, TA, TE, TN, TO, TP, TR, TS, TV, UD, VA, VB, VC, VE, VI, VR, VT, VV. Cities: Andria, Barletta, Cesena, Forli, Pesaro, Trani, Urbino
- Provinces: AG (Agrigento), AL (Alessandria), AN (Ancona), AO (Aosta), AP (Ascoli Piceno), AQ (L'Aquila), AR (Arezzo), AT (Asti), AV (Avellino), BA (Bari), BG (Bergamo), BI (Biella), BL (Belluno), BN (Benevento), BO (Bologna), BR (Brindisi), BS (Brescia), BT (Barletta-Andria-Trani), BZ (Bolzano), CA (Cagliari), CB (Campobasso), CE (Caserta), CH (Chieti), CL (Caltanissetta), CN (Cuneo), CO (Como), CR (Cremona), CS (Cosenza), CT (Catania), CZ (Catanzaro), EN (Enna), FC (Forli-Cesena, Forlì-Cesena), FE (Ferrara), FG (Foggia), FI (Firenze), FM (Fermo), FR (Frosinone), GE (Genova), GO (Gorizia), GR (Grosseto), IM (Imperia), IS (Isernia), KR (Crotone), LC (Lecco), LE (Lecce), LI (Livorno), LO (Lodi), LT (Latina), LU (Lucca), MB (Monza e Brianza), MC (Macerata), ME (Messina), MI (Milano), MN (Mantova), MO (Modena), MS (Massa-Carrara), MT (Matera), NA (Napoli), NO (Novara), NU (Nuoro), OR (Oristano), PA (Palermo), PC (Piacenza), PD (Padova), PE (Pescara), PG (Perugia), PI (Pisa), PN (Pordenone), PO (Prato), PR (Parma), PT (Pistoia), PU (Pesaro e Urbino), PV (Pavia), PZ (Potenza), RA (Ravenna), RC (Reggio Calabria), RE (Reggio Emilia), RG (Ragusa), RI (Rieti), RM (Roma), RN (Rimini), RO (Rovigo), SA (Salerno), SI (Siena), SO (Sondrio), SP (La Spezia), SR (Siracusa), SS (Sassari), SU (Sud Sardegna), SV (Savona), TA (Taranto), TE (Teramo), TN (Trento), TO (Torino), TP (Trapani), TR (Terni), TS (Trieste), TV (Treviso), UD (Udine), VA (Varese), VB (Verbano-Cusio-Ossola), VC (Vercelli), VE (Venezia), VI (Vicenza), VR (Verona), VT (Viterbo), VV (Vibo Valentia). Cities: Andria, Barletta, Cesena, Forli (Forlì), Pesaro, Trani, Urbino
-
-
* - Jamaica
Expand Down
118 changes: 113 additions & 5 deletions holidays/countries/italy.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,119 @@ class Italy(HolidayBase, ChristianHolidays, InternationalHolidays, StaticHoliday
"Trani",
"Urbino",
)

_deprecated_subdivisions = ("Forlì",)
subdivisions_aliases = {
# Provinces.
"Agrigento": "AG",
"Alessandria": "AL",
"Ancona": "AN",
"Aosta": "AO",
"Ascoli Piceno": "AP",
"L'Aquila": "AQ",
"Arezzo": "AR",
"Asti": "AT",
"Avellino": "AV",
"Bari": "BA",
"Bergamo": "BG",
"Biella": "BI",
"Belluno": "BL",
"Benevento": "BN",
"Bologna": "BO",
"Brindisi": "BR",
"Brescia": "BS",
"Barletta-Andria-Trani": "BT",
"Bolzano": "BZ",
"Cagliari": "CA",
"Campobasso": "CB",
"Caserta": "CE",
"Chieti": "CH",
"Caltanissetta": "CL",
"Cuneo": "CN",
"Como": "CO",
"Cremona": "CR",
"Cosenza": "CS",
"Catania": "CT",
"Catanzaro": "CZ",
"Enna": "EN",
"Forli-Cesena": "FC",
"Forlì-Cesena": "FC",
"Ferrara": "FE",
"Foggia": "FG",
"Firenze": "FI",
"Fermo": "FM",
"Frosinone": "FR",
"Genova": "GE",
"Gorizia": "GO",
"Grosseto": "GR",
"Imperia": "IM",
"Isernia": "IS",
"Crotone": "KR",
"Lecco": "LC",
"Lecce": "LE",
"Livorno": "LI",
"Lodi": "LO",
"Latina": "LT",
"Lucca": "LU",
"Monza e Brianza": "MB",
"Macerata": "MC",
"Messina": "ME",
"Milano": "MI",
"Mantova": "MN",
"Modena": "MO",
"Massa-Carrara": "MS",
"Matera": "MT",
"Napoli": "NA",
"Novara": "NO",
"Nuoro": "NU",
"Oristano": "OR",
"Palermo": "PA",
"Piacenza": "PC",
"Padova": "PD",
"Pescara": "PE",
"Perugia": "PG",
"Pisa": "PI",
"Pordenone": "PN",
"Prato": "PO",
"Parma": "PR",
"Pistoia": "PT",
"Pesaro e Urbino": "PU",
"Pavia": "PV",
"Potenza": "PZ",
"Ravenna": "RA",
"Reggio Calabria": "RC",
"Reggio Emilia": "RE",
"Ragusa": "RG",
"Rieti": "RI",
"Roma": "RM",
"Rimini": "RN",
"Rovigo": "RO",
"Salerno": "SA",
"Siena": "SI",
"Sondrio": "SO",
"La Spezia": "SP",
"Siracusa": "SR",
"Sassari": "SS",
"Sud Sardegna": "SU",
"Savona": "SV",
"Taranto": "TA",
"Teramo": "TE",
"Trento": "TN",
"Torino": "TO",
"Trapani": "TP",
"Terni": "TR",
"Trieste": "TS",
"Treviso": "TV",
"Udine": "UD",
"Varese": "VA",
"Verbano-Cusio-Ossola": "VB",
"Vercelli": "VC",
"Venezia": "VE",
"Vicenza": "VI",
"Verona": "VR",
"Viterbo": "VT",
"Vibo Valentia": "VV",
# Cities.
"Forlì": "Forli",
}

def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
Expand Down Expand Up @@ -208,9 +319,6 @@ def _populate_public_holidays(self):
# Saint Stephen's Day.
self._add_christmas_day_two("Santo Stefano")

if self.subdiv == "Forlì":
self._populate_subdiv_forli_public_holidays()

def _populate_subdiv_ag_public_holidays(self):
self._add_holiday_feb_25("San Gerlando")

Expand Down
13 changes: 0 additions & 13 deletions tests/countries/test_italy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)

import warnings
from unittest import TestCase

from holidays.countries.italy import Italy, IT, ITA
Expand All @@ -22,10 +21,6 @@ class TestItaly(CommonCountryTests, TestCase):
def setUpClass(cls):
super().setUpClass(Italy, years=range(1946, 2050))

def setUp(self):
super().setUp()
warnings.simplefilter("ignore", category=DeprecationWarning)

def test_country_aliases(self):
self.assertAliases(Italy, IT, ITA)

Expand Down Expand Up @@ -278,11 +273,3 @@ def test_province_specific_days(self):
}
for subdiv, holidays in subdiv_holidays.items():
self.assertHoliday(Italy(subdiv=subdiv, years=2017), holidays)

def test_deprecated(self):
self.assertEqual(
Italy(subdiv="Forlì", years=2022).keys(), Italy(subdiv="Forli", years=2022).keys()
)

def test_subdiv_deprecation(self):
self.assertDeprecatedSubdivisions("This subdivision is deprecated and will be removed")
Loading