From dbefb36f3708abe76a6652131ca048ab19e4629f Mon Sep 17 00:00:00 2001 From: PPsyrius <19505219+PPsyrius@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:09:10 +0700 Subject: [PATCH 1/3] Restore Malaysia's 3-letter code as subdivisions aliases --- README.rst | 2 +- holidays/countries/malaysia.py | 54 ++++++++++---------------------- tests/countries/test_malaysia.py | 27 ---------------- 3 files changed, 17 insertions(+), 66 deletions(-) diff --git a/README.rst b/README.rst index 44062ccda..6d3aa3b44 100644 --- a/README.rst +++ b/README.rst @@ -612,7 +612,7 @@ All other default values are highlighted with bold: - * - Malaysia - MY - - States and federal territories: 01 (Johor), 02 (Kedah), 03 (Kelantan), 04 (Melaka), 05 (Negeri Sembilan), 06 (Pahang), 07 (Pulau Pinang), 08 (Perak), 09 (Perlis), 10 (Selangor), 11 (Terengganu), 12 (Sabah), 13 (Sarawak), 14 (WP Kuala Lumpur), 15 (WP Labuan), 16 (WP Putrajaya) + - States and federal territories: 01 (Johor, JHR), 02 (Kedah, KDH), 03 (Kelantan, KTN), 04 (Melaka, MLK), 05 (Negeri Sembilan, NSN), 06 (Pahang, PHG), 07 (Pulau Pinang, PNG), 08 (Perak, PRK), 09 (Perlis, PLS), 10 (Selangor, SGR), 11 (Terengganu, TRG), 12 (Sabah, SBH), 13 (Sarawak, SWK), 14 (WP Kuala Lumpur, KUL), 15 (WP Labuan, LBN), 16 (WP Putrajaya, PJY) - en_US, **ms_MY** - * - Maldives diff --git a/holidays/countries/malaysia.py b/holidays/countries/malaysia.py index 74e8f3aa0..9816fb7b2 100644 --- a/holidays/countries/malaysia.py +++ b/holidays/countries/malaysia.py @@ -87,41 +87,39 @@ class Malaysia( "15", "16", ) - _deprecated_subdivisions = ( - "JHR", - "KDH", - "KTN", - "KUL", - "LBN", - "MLK", - "NSN", - "PHG", - "PJY", - "PLS", - "PNG", - "PRK", - "SBH", - "SGR", - "SWK", - "TRG", - ) subdivisions_aliases = { "Johor": "01", + "JHR": "01", "Kedah": "02", + "KDH": "02", "Kelantan": "03", + "KTN": "03", "Melaka": "04", + "MLK": "04", "Negeri Sembilan": "05", + "NSN": "05", "Pahang": "06", + "PHG": "06", "Pulau Pinang": "07", + "PNG": "07", "Perak": "08", + "PRK": "08", "Perlis": "09", + "PLS": "09", "Selangor": "10", + "SGR": "10", "Terengganu": "11", + "TRG": "11", "Sabah": "12", + "SBH": "12", "Sarawak": "13", + "SWK": "13", "WP Kuala Lumpur": "14", + "KUL": "14", "WP Labuan": "15", + "LBN": "15", "WP Putrajaya": "16", + "PJY": "16", } supported_languages = ("en_US", "ms_MY") @@ -216,26 +214,6 @@ def _populate_subdiv_holidays(self): if self._year <= 1951: return None - deprecated_mapping = { - "JHR": "01", - "KDH": "02", - "KTN": "03", - "KUL": "14", - "LBN": "15", - "MLK": "04", - "NSN": "05", - "PHG": "06", - "PJY": "16", - "PLS": "09", - "PNG": "07", - "PRK": "08", - "SBH": "12", - "SGR": "10", - "SWK": "13", - "TRG": "11", - } - self.subdiv = deprecated_mapping.get(self.subdiv, self.subdiv) - if self.subdiv and self.subdiv not in {"13", "15"}: # Deepavali. self.dts_observed.add(self._add_diwali(tr("Hari Deepavali"))) diff --git a/tests/countries/test_malaysia.py b/tests/countries/test_malaysia.py index 956842f1f..4023a3d8f 100644 --- a/tests/countries/test_malaysia.py +++ b/tests/countries/test_malaysia.py @@ -33,33 +33,6 @@ def setUp(self): def test_country_aliases(self): self.assertAliases(Malaysia, MY, MYS) - def test_subdiv_deprecation(self): - self.assertDeprecatedSubdivisions("This subdivision is deprecated and will be removed") - - def test_deprecated(self): - for subdiv1, subdiv2 in ( - ("JHR", "01"), - ("KDH", "02"), - ("KTN", "03"), - ("KUL", "14"), - ("LBN", "15"), - ("MLK", "04"), - ("NSN", "05"), - ("PHG", "06"), - ("PJY", "16"), - ("PLS", "09"), - ("PNG", "07"), - ("PRK", "08"), - ("SBH", "12"), - ("SGR", "10"), - ("SWK", "13"), - ("TRG", "11"), - ): - self.assertEqual( - sorted(Malaysia(subdiv=subdiv1, years=2023).keys()), - sorted(Malaysia(subdiv=subdiv2, years=2023).keys()), - ) - def test_no_holidays(self): self.assertNoHolidays(Malaysia(years=1951)) From 77007874aa483901e7462a692abbed631eaeca77 Mon Sep 17 00:00:00 2001 From: PPsyrius <19505219+PPsyrius@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:29:30 +0700 Subject: [PATCH 2/3] [MY] remove unnecessary warning ignore --- tests/countries/test_malaysia.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/countries/test_malaysia.py b/tests/countries/test_malaysia.py index 4023a3d8f..804de02be 100644 --- a/tests/countries/test_malaysia.py +++ b/tests/countries/test_malaysia.py @@ -26,10 +26,6 @@ def setUpClass(cls): for subdiv in Malaysia.subdivisions } - def setUp(self): - super().setUp() - warnings.simplefilter("ignore", category=DeprecationWarning) - def test_country_aliases(self): self.assertAliases(Malaysia, MY, MYS) From 72be7376d27880f4fdd8e9366841d0ee812e0eec Mon Sep 17 00:00:00 2001 From: PPsyrius <19505219+PPsyrius@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:33:13 +0700 Subject: [PATCH 3/3] [MY] same goes for `warning` import --- tests/countries/test_malaysia.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/countries/test_malaysia.py b/tests/countries/test_malaysia.py index 804de02be..bddd8b71e 100644 --- a/tests/countries/test_malaysia.py +++ b/tests/countries/test_malaysia.py @@ -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.malaysia import Malaysia, MY, MYS