Update Norway holidays: update subdivision list as per 2024 administrative reform#2952
Conversation
Viken was disolved in 2024 with Østfold, Akershus & Buskerud being reinstated. Signed-off-by: Exerqtor <41635644+Exerqtor@users.noreply.github.com>
PPsyrius
left a comment
There was a problem hiding this comment.
You'll need to do the following as well:
- Update Norway's section in the readme file
- Add Viken to the
_deprecated_subdivisionslist in thenorway pyfile; see https://github.com/vacanza/holidays/blob/dev/holidays/countries/united_states.py#L237 or https://github.com/vacanza/holidays/blob/dev/holidays/countries/france.py#L102 for example - Add
test_subdiv_deprecationandsetUp(self)override totest_norway.pyfile; see https://github.com/vacanza/holidays/blob/dev/tests/countries/test_france.py#L71 for example
As far as I know, the official ISO-3166 entry for NO hasn’t been updated with the new counties list yet: https://www.iso.org/obp/ui/#iso:code:3166:NO - do you have references for these new county ISO codes?
|
Turns out it's been even more changes to the counties farther North as well, so I have to take a better look at it soon. Regarding the ISO I have no idea, but it does look like it haven't been updated for some reason. Even though the counties have been officialy changed by the Norwegian goverment (linked site in Norwegian): https://www.regjeringen.no/no/tema/kommuner-og-regioner/kommunestruktur/nye-kommune-og-fylkesnummer-fra-1.-januar-2024/id2924701/ |
"Vestfold og Telemark" and "Troms og Finnmark" also got split up into four respective counties in 2024. Signed-off-by: Exerqtor <41635644+Exerqtor@users.noreply.github.com>
Added `_deprecated_subdivisions` list. Signed-off-by: Exerqtor <41635644+Exerqtor@users.noreply.github.com>
Added `setUp(self)` & `test_subdiv_deprecation`. Signed-off-by: Exerqtor <41635644+Exerqtor@users.noreply.github.com>
Updated Norwegian counties. Signed-off-by: Exerqtor <41635644+Exerqtor@users.noreply.github.com>
Signed-off-by: Panpakorn Siripanich <19505219+PPsyrius@users.noreply.github.com>
Summary by CodeRabbit
WalkthroughReplaced deprecated Norwegian subdivision codes 30, 38, 54 with new codes 31, 32, 33, 39, 40, 55, 56; updated subdivision names and aliases; added Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (15)📓 Common learnings📚 Learning: 2025-07-12T20:54:28.749ZApplied to files:
📚 Learning: 2025-06-16T11:46:35.303ZApplied to files:
📚 Learning: 2025-06-16T11:46:35.303ZApplied to files:
📚 Learning: 2025-06-18T10:18:59.447ZApplied to files:
📚 Learning: 2025-06-16T11:46:35.303ZApplied to files:
📚 Learning: 2025-06-18T10:07:58.780ZApplied to files:
📚 Learning: 2025-06-18T10:12:57.419ZApplied to files:
📚 Learning: 2025-04-01T14:14:01.519ZApplied to files:
📚 Learning: 2025-04-06T17:44:24.598ZApplied to files:
📚 Learning: 2025-06-05T18:24:26.712ZApplied to files:
📚 Learning: 2025-06-05T09:31:22.753ZApplied to files:
📚 Learning: 2025-06-04T11:06:21.179ZApplied to files:
📚 Learning: 2025-06-16T15:48:33.931ZApplied to files:
📚 Learning: 2025-09-27T05:11:09.451ZApplied to files:
🔇 Additional comments (1)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Ruff (0.13.1)holidays/countries/norway.py�[1;31mruff failed�[0m Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: Panpakorn Siripanich <19505219+PPsyrius@users.noreply.github.com>
Signed-off-by: Panpakorn Siripanich <19505219+PPsyrius@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
README.md(1 hunks)holidays/countries/norway.py(2 hunks)tests/countries/test_norway.py(2 hunks)
🧰 Additional context used
🧠 Learnings (19)
📓 Common learnings
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: In the holidays library, Norwegian subdivisions all yield the same holiday results regardless of the subdivision code used. This is similar to how Åland is implemented as a simple alias of Finland holidays with just a country code override.
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: In the holidays library, Norwegian subdivisions all yield the same holiday results regardless of the subdivision code used. This is similar to how Åland is implemented as a simple alias of Finland holidays with just a country code override.
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: In the holidays library, Norwegian subdivisions all yield the same holiday results regardless of the subdivision code used. This is similar to how Åland is implemented as a simple alias of Finland holidays with just a country code override.
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: When creating country holiday aliases that inherit from parent countries (like Svalbard and Jan Mayen from Norway, or Åland from Finland), it's standard practice to hardcode a specific subdivision code in the _populate methods since the subdivision codes for the parent country yield identical results. The Åland Islands implementation serves as the reference pattern for this approach.
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: When creating country holiday aliases that inherit from parent countries (like Svalbard and Jan Mayen from Norway, or Åland from Finland), it's common and acceptable to hardcode a specific subdivision code since the subdivision codes for the parent country yield identical results.
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: When creating country holiday aliases that inherit from parent countries (like Svalbard and Jan Mayen from Norway, or Åland from Finland), it's common and acceptable to hardcode a specific subdivision code since the subdivision codes for the parent country yield identical results.
📚 Learning: 2025-06-16T11:46:35.303Z
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: In the holidays library, Norwegian subdivisions all yield the same holiday results regardless of the subdivision code used. This is similar to how Åland is implemented as a simple alias of Finland holidays with just a country code override.
Applied to files:
README.mdholidays/countries/norway.py
📚 Learning: 2025-06-16T11:46:35.303Z
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: When creating country holiday aliases that inherit from parent countries (like Svalbard and Jan Mayen from Norway, or Åland from Finland), it's common and acceptable to hardcode a specific subdivision code since the subdivision codes for the parent country yield identical results.
Applied to files:
README.mdholidays/countries/norway.py
📚 Learning: 2025-06-18T10:18:59.447Z
Learnt from: PPsyrius
PR: vacanza/holidays#2642
File: holidays/countries/france.py:178-182
Timestamp: 2025-06-18T10:18:59.447Z
Learning: In the France holidays implementation, deprecated subdivision names like "Alsace-Moselle" and "Saint-Barthélémy" are handled through explicit conditionals in _populate_public_holidays() that map them to their corresponding new subdivision-specific holiday population methods, providing backward compatibility while users transition to the new ISO codes.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-06-18T10:07:58.780Z
Learnt from: PPsyrius
PR: vacanza/holidays#2642
File: holidays/countries/french_southern_territories.py:41-44
Timestamp: 2025-06-18T10:07:58.780Z
Learning: Territorial holiday classes that inherit from parent countries (like HolidaysAX from Finland, HolidaysSJ from Norway, HolidaysTF from France) follow a standard pattern of silently overriding self.subdiv in their _populate_public_holidays() method without validation, as this ensures they always use the correct subdivision code for their territory regardless of user input.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-06-16T11:46:35.303Z
Learnt from: PPsyrius
PR: vacanza/holidays#2638
File: holidays/countries/svalbard_and_jan_mayen.py:26-32
Timestamp: 2025-06-16T11:46:35.303Z
Learning: When creating country holiday aliases that inherit from parent countries (like Svalbard and Jan Mayen from Norway, or Åland from Finland), it's standard practice to hardcode a specific subdivision code in the _populate methods since the subdivision codes for the parent country yield identical results. The Åland Islands implementation serves as the reference pattern for this approach.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-04-01T14:14:01.519Z
Learnt from: PPsyrius
PR: vacanza/holidays#2398
File: holidays/groups/islamic.py:301-301
Timestamp: 2025-04-01T14:14:01.519Z
Learning: Running `make pre-commit` in the holidays project can automatically fix common code style issues like whitespace in blank lines.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-04-06T17:44:24.598Z
Learnt from: PPsyrius
PR: vacanza/holidays#2439
File: holidays/calendars/thai.py:0-0
Timestamp: 2025-04-06T17:44:24.598Z
Learning: When making code suggestions, only include the specific lines that need to be changed in the committable suggestion part, without surrounding unrelated code.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-06-05T18:24:26.712Z
Learnt from: PPsyrius
PR: vacanza/holidays#2600
File: holidays/countries/philippines.py:56-56
Timestamp: 2025-06-05T18:24:26.712Z
Learning: In the holidays repository, if code passes `make pre-commit` checks, then it's allowed regardless of individual static analysis tool warnings like Pylint line length violations. The pre-commit hooks are the definitive source of truth for their coding standards.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-06-05T09:31:22.753Z
Learnt from: PPsyrius
PR: vacanza/holidays#2599
File: holidays/countries/__init__.py:193-193
Timestamp: 2025-06-05T09:31:22.753Z
Learning: For the holidays Python library, when encountering line length or formatting issues, suggest contributors run `make pre-commit` to auto-format their files instead of providing specific manual formatting fixes like line splitting or noqa comments.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-06-04T11:06:21.179Z
Learnt from: PPsyrius
PR: vacanza/holidays#2594
File: holidays/countries/micronesia.py:25-30
Timestamp: 2025-06-04T11:06:21.179Z
Learning: In the holidays repository, line length formatting should defer to pre-commit formatting checks rather than manual suggestions. If pre-commit allows it, the formatting is acceptable per project policy.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-06-16T15:48:33.931Z
Learnt from: PPsyrius
PR: vacanza/holidays#2615
File: tests/countries/test_anguilla.py:20-24
Timestamp: 2025-06-16T15:48:33.931Z
Learning: The holidays project uses `make pre-commit` test which includes `ruff` as the primary linter. If `ruff` passes, then Pylint warnings that don't appear in `ruff` are considered acceptable and can be ignored.
Applied to files:
holidays/countries/norway.py
📚 Learning: 2025-04-05T04:29:38.042Z
Learnt from: PPsyrius
PR: vacanza/holidays#2416
File: tests/countries/test_turkmenistan.py:85-86
Timestamp: 2025-04-05T04:29:38.042Z
Learning: For testing holiday implementations in the vacanza/holidays repository, recommend using `from tests.common import CommonCountryTests` as the base class instead of directly using `unittest.TestCase` to maintain consistency with project conventions and leverage common test utilities.
Applied to files:
tests/countries/test_norway.py
📚 Learning: 2025-04-05T04:50:40.752Z
Learnt from: PPsyrius
PR: vacanza/holidays#2416
File: tests/countries/test_turkmenistan.py:31-49
Timestamp: 2025-04-05T04:50:40.752Z
Learning: For Turkmenistan holiday tests, use this class structure: `class TestTurkmenistan(CommonCountryTests, TestCase)` with imports `from unittest import TestCase`, `from holidays.countries import Turkmenistan, TM, TKM`, and `from tests.common import CommonCountryTests`. Ensure to call `super().setUp()` in the setUp method.
Applied to files:
tests/countries/test_norway.py
📚 Learning: 2025-08-09T18:31:23.218Z
Learnt from: KJhellico
PR: vacanza/holidays#2778
File: tests/countries/test_kiribati.py:15-15
Timestamp: 2025-08-09T18:31:23.218Z
Learning: In the holidays project test files, the standard import pattern is `from holidays.countries.<country> import Country, CODE1, CODE2` (used in ~97% of test files), not `from holidays.countries import Country, CODE1, CODE2`. Only a few exceptions (Suriname, Sierra Leone, Mauritius, Mali, Ivory Coast, Guyana) use the aggregated import pattern.
Applied to files:
tests/countries/test_norway.py
📚 Learning: 2025-06-18T17:01:58.067Z
Learnt from: PPsyrius
PR: vacanza/holidays#2642
File: tests/countries/test_wallis_and_futuna.py:19-23
Timestamp: 2025-06-18T17:01:58.067Z
Learning: In the vacanza/holidays repository, the standard pattern for test class setUpClass methods is `super().setUpClass(HolidayClass)` or `super().setUpClass(HolidayClass, years=...)` where HolidayClass is passed as the first argument. This is the correct signature that matches the CommonCountryTests.setUpClass method which accepts test_class as the first parameter after cls. Pylint warnings about parameter count mismatch are false positives when comparing against TestCase.setUpClass instead of the immediate parent CommonCountryTests.setUpClass.
Applied to files:
tests/countries/test_norway.py
📚 Learning: 2025-08-20T19:46:15.625Z
Learnt from: KJhellico
PR: vacanza/holidays#2833
File: tests/countries/test_uganda.py:15-0
Timestamp: 2025-08-20T19:46:15.625Z
Learning: In the holidays project, the standard import pattern for country test files is `from holidays.countries.<country> import Country, CODE1, CODE2` (direct module import), used by ~75% of country test files. Only a minority (~25%) use the aggregated public API import `from holidays.countries import Country, CODE1, CODE2`. The direct module import pattern should be used for new country test files to follow the established convention.
Applied to files:
tests/countries/test_norway.py
📚 Learning: 2025-04-05T04:33:53.254Z
Learnt from: PPsyrius
PR: vacanza/holidays#2416
File: tests/countries/test_turkmenistan.py:52-64
Timestamp: 2025-04-05T04:33:53.254Z
Learning: For Turkmenistan holiday tests, recommend using CommonCountryTests as the base class rather than unittest.TestCase to follow project conventions, be consistent with other country test files, and gain access to common test utilities.
Applied to files:
tests/countries/test_norway.py
📚 Learning: 2025-06-16T15:48:48.680Z
Learnt from: PPsyrius
PR: vacanza/holidays#2615
File: tests/countries/test_anguilla.py:1-12
Timestamp: 2025-06-16T15:48:48.680Z
Learning: Test files in the holidays repository follow a standardized structure without module or class docstrings. All country test files use the same pattern: license header, imports, and class definition (`class Test{Country}(CommonCountryTests, TestCase):`) without docstrings. This is an established codebase convention that should be maintained for consistency.
Applied to files:
tests/countries/test_norway.py
🧬 Code graph analysis (1)
tests/countries/test_norway.py (1)
tests/common.py (2)
setUp(58-68)assertDeprecatedSubdivisions(135-142)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Panpakorn Siripanich <19505219+PPsyrius@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #2952 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 301 301
Lines 17978 17979 +1
Branches 2328 2328
=========================================
+ Hits 17978 17979 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The code is LGTM, but I am concerned about the absence of these changes in ISO. |
|
I haven't had time to do the changes during the work week, but @PPsyrius beat me to it and fixed it. Thx! Regarding the ISO it ain't much I can do obviously, and I haven't got an answer for why it haven't been updated. Regardless "ISO 3166-2:NO" is in this point of time "outdated" / wrong when compared to the state/government enforced changes which where put in effect 1 January 2024. |
|
Proposed change
Viken county was disolved in 2024 with Østfold, Akershus & Buskerud being reinstated.
Type of change
holidaysfunctionality in general)Checklist
make checklocally; all checks and tests passed.