Skip to content

Expose entity additional codes#2879

Merged
arkid15r merged 4 commits into
vacanza:devfrom
arkid15r:ark/expose-additional-aliases
Sep 1, 2025
Merged

Expose entity additional codes#2879
arkid15r merged 4 commits into
vacanza:devfrom
arkid15r:ark/expose-additional-aliases

Conversation

@arkid15r

@arkid15r arkid15r commented Aug 31, 2025

Copy link
Copy Markdown
Collaborator

Proposed change

Expose entity additional codes. Originally based on this comment.

Type of change

  • New country/market holidays support (thank you!)
  • Supported country/market holidays update (calendar discrepancy fix, localization)
  • Existing code/documentation/test/process quality improvement (best practice, cleanup, refactoring, optimization)
  • Dependency update (version deprecation/pin/upgrade)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (a code change causing existing functionality to break)
  • New feature (new holidays functionality in general)

Checklist

@coderabbitai

coderabbitai Bot commented Aug 31, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added flexible code retrieval with an option to include or exclude aliases.
    • Introduced min/max code-length filtering for more precise results.
    • Expanded recognition of common aliases for countries and financial markets (e.g., UK/GBR, USA, NYSE).
  • Documentation

    • Updated guidance and examples to clarify alias handling and code selection behavior.
  • Tests

    • Added tests covering alias inclusion/exclusion for both country and financial code retrieval.

Walkthrough

Refactors EntityLoader._get_entity_codes to accept explicit min/max code lengths and iterate only over codes after the human-readable name; include_aliases now controls yielding either only the first alias or all aliases. get_country_codes and get_financial_codes updated to call the new signature. Tests added for alias modes.

Changes

Cohort / File(s) Summary
Registry code retrieval refactor
holidays/registry.py
Rewrote _get_entity_codes signature to max_code_length, min_code_length, include_aliases; iterate over entity tuple elements after the name, apply length-range filtering, and break behavior when include_aliases=False. Updated get_country_codes and get_financial_codes, docstrings, and typing imports.
Tests for alias handling
tests/test_registry.py
Added tests asserting EntityLoader.get_country_codes and EntityLoader.get_financial_codes return only the first alias when include_aliases=False and all aliases when include_aliases=True; primary names are excluded.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • PPsyrius
  • KJhellico

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 59c9c41 and 744a804.

📒 Files selected for processing (1)
  • holidays/registry.py (2 hunks)
🧰 Additional context used
🧠 Learnings (16)
📚 Learning: 2025-08-08T10:33:55.695Z
Learnt from: KJhellico
PR: vacanza/holidays#2763
File: README.md:108-110
Timestamp: 2025-08-08T10:33:55.695Z
Learning: When verifying the country total in holidays/registry.py, isolate between '^COUNTRIES:' and '^FINANCIAL:' and count only lines matching the strict key pattern '^\s*"[a-z0-9_ ]+":\s*\(' to avoid overcounting non-entry quoted lines. As of PR vacanza/holidays#2763, this yields 227 entries.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-24T13:01:51.370Z
Learnt from: Wasif-Shahzad
PR: vacanza/holidays#2852
File: tests/countries/test_tajikistan.py:26-28
Timestamp: 2025-08-24T13:01:51.370Z
Learning: In the holidays project country test files, the standard method name for testing country aliases (ISO codes) is `test_country_aliases`, not `test_aliases`. This naming convention is consistently used across all country test files.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-04-18T21:13:55.589Z
Learnt from: KJhellico
PR: vacanza/holidays#2483
File: holidays/registry.py:177-177
Timestamp: 2025-04-18T21:13:55.589Z
Learning: In the holidays/registry.py file, COUNTRIES dictionary entries should use the class name (without spaces) as the first element of the tuple (e.g., "TurksAndCaicosIslands"), not the human-readable country name with spaces.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-24T13:01:51.370Z
Learnt from: Wasif-Shahzad
PR: vacanza/holidays#2852
File: tests/countries/test_tajikistan.py:26-28
Timestamp: 2025-08-24T13:01:51.370Z
Learning: In the holidays project country test files, the universally adopted standard method name for testing country aliases (ISO codes) is `test_country_aliases`. This naming convention is used consistently across all 235+ country test files in the repository, with no exceptions using `test_aliases`.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-03T12:59:53.286Z
Learnt from: KJhellico
PR: vacanza/holidays#2635
File: README.md:108-110
Timestamp: 2025-08-03T12:59:53.286Z
Learning: Always verify country counts in the COUNTRIES dictionary by checking the current count in the COUNTRIES dictionary in holidays/registry.py directly, rather than relying on information from previous PRs, as the count changes frequently with new country additions.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-06-09T19:50:56.039Z
Learnt from: KJhellico
PR: vacanza/holidays#2609
File: holidays/countries/nauru.py:149-154
Timestamp: 2025-06-09T19:50:56.039Z
Learning: In the holidays library project, never suggest adding docstrings for alias classes (like NR, NRU country code aliases that inherit from main country classes). The project deliberately omits docstrings for these simple alias classes.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-06-24T19:41:46.854Z
Learnt from: KJhellico
PR: vacanza/holidays#2651
File: holidays/countries/bonaire_sint_eustatius_and_saba.py:121-126
Timestamp: 2025-06-24T19:41:46.854Z
Learning: In the holidays library, simple alias classes that inherit from parent classes with just `pass` statements do not include docstrings. This is a consistent pattern throughout the codebase and should be maintained for consistency.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-06-05T17:22:43.114Z
Learnt from: Wasif-Shahzad
PR: vacanza/holidays#2593
File: holidays/countries/senegal.py:104-110
Timestamp: 2025-06-05T17:22:43.114Z
Learning: In the holidays library codebase, country alias classes (like SN, SEN for Senegal) follow a consistent convention of having no docstrings and just containing "pass". This pattern is used across all countries - examples include BR/BRA for Brazil, CA/CAN for Canada, DE/DEU for Germany, etc. Static analysis tools may flag missing docstrings, but the established codebase convention is to keep these alias classes minimal.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-04-02T04:51:17.842Z
Learnt from: PPsyrius
PR: vacanza/holidays#2402
File: holidays/countries/trinidad_and_tobago.py:28-33
Timestamp: 2025-04-02T04:51:17.842Z
Learning: The library convention for country code aliases (like two-letter ISO 3166-1 alpha-2 and three-letter ISO 3166-1 alpha-3 codes) is to implement them as simple pass-through classes without docstrings.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-08T14:37:03.045Z
Learnt from: KJhellico
PR: vacanza/holidays#2774
File: tests/countries/test_liberia.py:15-16
Timestamp: 2025-08-08T14:37:03.045Z
Learning: In holidays/countries/__init__.py, re-export country classes using absolute imports (e.g., 'from holidays.countries.liberia import Liberia, LR, LBR') and keep alphabetical ordering (e.g., Lesotho, Liberia, Libya). Avoid relative imports in this file.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-07-15T15:00:32.728Z
Learnt from: KJhellico
PR: vacanza/holidays#2687
File: README.md:108-108
Timestamp: 2025-07-15T15:00:32.728Z
Learning: When verifying country counts in the holidays library, always check the current count in the COUNTRIES dictionary in holidays/registry.py rather than relying on previously recorded counts, as new countries may have been added in merged PRs.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-28T21:03:22.907Z
Learnt from: KJhellico
PR: vacanza/holidays#2831
File: README.md:1557-1563
Timestamp: 2025-08-28T21:03:22.907Z
Learning: When checking exports in holidays/countries/__init__.py, look for simple import statements like "from .module_name import Class, CODE1, CODE2" rather than using complex regex patterns. The import statements follow a straightforward format.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-24T11:55:06.810Z
Learnt from: KJhellico
PR: vacanza/holidays#2831
File: README.md:108-108
Timestamp: 2025-08-24T11:55:06.810Z
Learning: The actual count of countries in the holidays library should always be verified by counting entries in the COUNTRIES dictionary in holidays/registry.py using `grep -E '^\s*"[a-z_]+"\s*:' holidays/registry.py | wc -l`, rather than making assumptions about incremental changes.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-07-17T11:07:04.986Z
Learnt from: KJhellico
PR: vacanza/holidays#2720
File: README.md:108-110
Timestamp: 2025-07-17T11:07:04.986Z
Learning: Always verify country counts in the holidays library by checking the current count in the COUNTRIES dictionary in holidays/registry.py directly, rather than relying on information from previous PRs, as the count changes frequently with new country additions.

Applied to files:

  • holidays/registry.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:

  • holidays/registry.py
📚 Learning: 2025-08-26T20:10:05.288Z
Learnt from: KJhellico
PR: vacanza/holidays#2834
File: holidays/financial/national_stock_exchange_of_india.py:38-44
Timestamp: 2025-08-26T20:10:05.288Z
Learning: For National Stock Exchange of India (NSE) holidays implementation, only `estimated_label = tr("%s (estimated)")` is needed for localization support. The `observed_label` and `observed_estimated_label` are not required for this financial market holidays implementation.

Applied to files:

  • holidays/registry.py
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test Python 3.13 on windows-latest
  • GitHub Check: Test Python 3.12 on windows-latest
🔇 Additional comments (2)
holidays/registry.py (2)

16-16: LGTM: typing imports are correct and used.


377-381: LGTM: financial codes max length 4 is appropriate.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot added the test label Aug 31, 2025
@codecov

codecov Bot commented Aug 31, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (47d8050) to head (744a804).
⚠️ Report is 2 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev     #2879   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          294       294           
  Lines        17445     17444    -1     
  Branches      2262      2262           
=========================================
- Hits         17445     17444    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a459edc and aa1de81.

📒 Files selected for processing (2)
  • holidays/registry.py (2 hunks)
  • tests/test_registry.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: KJhellico
PR: vacanza/holidays#2763
File: README.md:108-110
Timestamp: 2025-08-08T10:33:55.695Z
Learning: When verifying the country total in holidays/registry.py, isolate between '^COUNTRIES:' and '^FINANCIAL:' and count only lines matching the strict key pattern '^\s*"[a-z0-9_ ]+":\s*\(' to avoid overcounting non-entry quoted lines. As of PR vacanza/holidays#2763, this yields 227 entries.
Learnt from: KJhellico
PR: vacanza/holidays#2774
File: tests/countries/test_liberia.py:15-16
Timestamp: 2025-08-08T14:37:03.045Z
Learning: In holidays/countries/__init__.py, re-export country classes using absolute imports (e.g., 'from holidays.countries.liberia import Liberia, LR, LBR') and keep alphabetical ordering (e.g., Lesotho, Liberia, Libya). Avoid relative imports in this file.
Learnt from: KJhellico
PR: vacanza/holidays#2483
File: holidays/registry.py:177-177
Timestamp: 2025-04-18T21:13:55.589Z
Learning: In the holidays/registry.py file, COUNTRIES dictionary entries should use the class name (without spaces) as the first element of the tuple (e.g., "TurksAndCaicosIslands"), not the human-readable country name with spaces.
Learnt from: Wasif-Shahzad
PR: vacanza/holidays#2852
File: tests/countries/test_tajikistan.py:26-28
Timestamp: 2025-08-24T13:01:51.370Z
Learning: In the holidays project country test files, the standard method name for testing country aliases (ISO codes) is `test_country_aliases`, not `test_aliases`. This naming convention is consistently used across all country test files.
🧬 Code graph analysis (1)
tests/test_registry.py (1)
holidays/registry.py (3)
  • EntityLoader (288-382)
  • get_country_codes (353-360)
  • get_financial_codes (363-370)
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test Python 3.13 on windows-latest
🔇 Additional comments (4)
holidays/registry.py (2)

16-16: Typing import cleanup looks good.

Any/Optional only; no stray Union.


367-369: Docstring reads fine.

Examples align with financial identifiers.

tests/test_registry.py (2)

111-118: LGTM: baseline behavior pinned for include_aliases=False.

Asserts only the primary code (index 1) shows up.


126-140: LGTM: financial code expectations are clear.

Both include/exclude cases read correctly.

Comment thread holidays/registry.py Outdated
Comment thread holidays/registry.py
Comment thread holidays/registry.py Outdated
Comment thread tests/test_registry.py
Comment thread holidays/registry.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (3)
tests/test_registry.py (1)

119-128: Use code-shaped filter (2–3 uppercase letters) instead of isupper().

Aligns with the “codes-only” contract and excludes non-code aliases like HolidaysAX or name-like tokens.

-        for entity_classes in registry.COUNTRIES.values():
-            self.assertNotIn(entity_classes[0], country_codes)
-            for code in entity_classes[1:]:
-                if code.isupper():
-                    self.assertIn(code, country_codes)
-                else:
-                    self.assertNotIn(code, country_codes)
+        for entity_classes in registry.COUNTRIES.values():
+            self.assertNotIn(entity_classes[0], country_codes)
+            for code in entity_classes[1:]:
+                if code.isalpha() and code.isupper() and len(code) in (2, 3):
+                    self.assertIn(code, country_codes)
+                else:
+                    self.assertNotIn(code, country_codes)
holidays/registry.py (2)

359-366: Docstring: clarify “aliases” means code aliases; exclude non-code names.

Be explicit that country “codes” are 2–3 uppercase letters (ISO-style); name-like aliases are not returned.

-        :param include_aliases:
-            Whether to include entity aliases (e.g. GBR and UK for GB,
-            UKR for UA, USA for US, etc).
+        :param include_aliases:
+            Whether to include code aliases (2–3 uppercase letters; e.g., GBR and UK for GB,
+            UKR for UA, USA for US). Non-code aliases (e.g., 'HolidaysAX', name-like tokens)
+            are excluded.

363-366: Keep “codes” strictly code-shaped at the API boundary.

Filter to 2–3 uppercase alphabetic codes for countries to avoid accidental leakage if data changes.

-        return EntityLoader._get_entity_codes(
-            COUNTRIES,
-            include_aliases=include_aliases,
-        )
+        return (
+            code
+            for code in EntityLoader._get_entity_codes(
+                COUNTRIES, include_aliases=include_aliases
+            )
+            if code.isalpha() and code.isupper() and 2 <= len(code) <= 3
+        )
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between aa1de81 and 59c9c41.

📒 Files selected for processing (2)
  • holidays/registry.py (2 hunks)
  • tests/test_registry.py (1 hunks)
🧰 Additional context used
🧠 Learnings (14)
📚 Learning: 2025-08-24T13:01:51.370Z
Learnt from: Wasif-Shahzad
PR: vacanza/holidays#2852
File: tests/countries/test_tajikistan.py:26-28
Timestamp: 2025-08-24T13:01:51.370Z
Learning: In the holidays project country test files, the standard method name for testing country aliases (ISO codes) is `test_country_aliases`, not `test_aliases`. This naming convention is consistently used across all country test files.

Applied to files:

  • tests/test_registry.py
  • holidays/registry.py
📚 Learning: 2025-08-24T13:01:51.370Z
Learnt from: Wasif-Shahzad
PR: vacanza/holidays#2852
File: tests/countries/test_tajikistan.py:26-28
Timestamp: 2025-08-24T13:01:51.370Z
Learning: In the holidays project country test files, the universally adopted standard method name for testing country aliases (ISO codes) is `test_country_aliases`. This naming convention is used consistently across all 235+ country test files in the repository, with no exceptions using `test_aliases`.

Applied to files:

  • tests/test_registry.py
  • holidays/registry.py
📚 Learning: 2025-04-18T21:13:55.589Z
Learnt from: KJhellico
PR: vacanza/holidays#2483
File: holidays/registry.py:177-177
Timestamp: 2025-04-18T21:13:55.589Z
Learning: In the holidays/registry.py file, COUNTRIES dictionary entries should use the class name (without spaces) as the first element of the tuple (e.g., "TurksAndCaicosIslands"), not the human-readable country name with spaces.

Applied to files:

  • tests/test_registry.py
  • holidays/registry.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/test_registry.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/test_registry.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/test_registry.py
📚 Learning: 2025-06-09T19:50:56.039Z
Learnt from: KJhellico
PR: vacanza/holidays#2609
File: holidays/countries/nauru.py:149-154
Timestamp: 2025-06-09T19:50:56.039Z
Learning: In the holidays library project, never suggest adding docstrings for alias classes (like NR, NRU country code aliases that inherit from main country classes). The project deliberately omits docstrings for these simple alias classes.

Applied to files:

  • tests/test_registry.py
  • holidays/registry.py
📚 Learning: 2025-08-08T10:33:55.695Z
Learnt from: KJhellico
PR: vacanza/holidays#2763
File: README.md:108-110
Timestamp: 2025-08-08T10:33:55.695Z
Learning: When verifying the country total in holidays/registry.py, isolate between '^COUNTRIES:' and '^FINANCIAL:' and count only lines matching the strict key pattern '^\s*"[a-z0-9_ ]+":\s*\(' to avoid overcounting non-entry quoted lines. As of PR vacanza/holidays#2763, this yields 227 entries.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-03T12:59:53.286Z
Learnt from: KJhellico
PR: vacanza/holidays#2635
File: README.md:108-110
Timestamp: 2025-08-03T12:59:53.286Z
Learning: Always verify country counts in the COUNTRIES dictionary by checking the current count in the COUNTRIES dictionary in holidays/registry.py directly, rather than relying on information from previous PRs, as the count changes frequently with new country additions.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-06-24T19:41:46.854Z
Learnt from: KJhellico
PR: vacanza/holidays#2651
File: holidays/countries/bonaire_sint_eustatius_and_saba.py:121-126
Timestamp: 2025-06-24T19:41:46.854Z
Learning: In the holidays library, simple alias classes that inherit from parent classes with just `pass` statements do not include docstrings. This is a consistent pattern throughout the codebase and should be maintained for consistency.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-06-05T17:22:43.114Z
Learnt from: Wasif-Shahzad
PR: vacanza/holidays#2593
File: holidays/countries/senegal.py:104-110
Timestamp: 2025-06-05T17:22:43.114Z
Learning: In the holidays library codebase, country alias classes (like SN, SEN for Senegal) follow a consistent convention of having no docstrings and just containing "pass". This pattern is used across all countries - examples include BR/BRA for Brazil, CA/CAN for Canada, DE/DEU for Germany, etc. Static analysis tools may flag missing docstrings, but the established codebase convention is to keep these alias classes minimal.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-04-02T04:51:17.842Z
Learnt from: PPsyrius
PR: vacanza/holidays#2402
File: holidays/countries/trinidad_and_tobago.py:28-33
Timestamp: 2025-04-02T04:51:17.842Z
Learning: The library convention for country code aliases (like two-letter ISO 3166-1 alpha-2 and three-letter ISO 3166-1 alpha-3 codes) is to implement them as simple pass-through classes without docstrings.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-08T14:37:03.045Z
Learnt from: KJhellico
PR: vacanza/holidays#2774
File: tests/countries/test_liberia.py:15-16
Timestamp: 2025-08-08T14:37:03.045Z
Learning: In holidays/countries/__init__.py, re-export country classes using absolute imports (e.g., 'from holidays.countries.liberia import Liberia, LR, LBR') and keep alphabetical ordering (e.g., Lesotho, Liberia, Libya). Avoid relative imports in this file.

Applied to files:

  • holidays/registry.py
📚 Learning: 2025-08-26T20:10:05.288Z
Learnt from: KJhellico
PR: vacanza/holidays#2834
File: holidays/financial/national_stock_exchange_of_india.py:38-44
Timestamp: 2025-08-26T20:10:05.288Z
Learning: For National Stock Exchange of India (NSE) holidays implementation, only `estimated_label = tr("%s (estimated)")` is needed for localization support. The `observed_label` and `observed_estimated_label` are not required for this financial market holidays implementation.

Applied to files:

  • holidays/registry.py
🧬 Code graph analysis (1)
tests/test_registry.py (1)
holidays/registry.py (3)
  • EntityLoader (288-392)
  • get_country_codes (356-366)
  • get_financial_codes (369-380)
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test Python 3.13 on windows-latest
🔇 Additional comments (3)
tests/test_registry.py (2)

111-118: Index-based assumption is brittle; break only after yielding first code.

This test assumes the first alias (index 1) is always the primary code. It mirrors the current data, but it will silently pass if order ever changes. Consider asserting “exactly one code per entity when include_aliases=False” and let the implementation choose which, or make the implementation break only after yielding a matching code (see registry comment).


129-136: LGTM for “first alias only” behavior.

Matches the intended include_aliases=False contract.

holidays/registry.py (1)

16-16: Import cleanup is correct.

Removing unused Union is appropriate after the signature change.

Comment thread holidays/registry.py
Comment thread holidays/registry.py Outdated
Comment thread holidays/registry.py
Comment thread tests/test_registry.py
@arkid15r arkid15r changed the title Expose entity additional aliases Expose entity additional codes Aug 31, 2025
@sonarqubecloud

Copy link
Copy Markdown

@arkid15r arkid15r marked this pull request as ready for review August 31, 2025 18:45
@arkid15r arkid15r requested a review from PPsyrius as a code owner August 31, 2025 18:45
@arkid15r arkid15r requested a review from KJhellico August 31, 2025 21:34

@KJhellico KJhellico left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@arkid15r arkid15r added this pull request to the merge queue Sep 1, 2025
Merged via the queue into vacanza:dev with commit 515ba78 Sep 1, 2025
36 checks passed
@arkid15r arkid15r deleted the ark/expose-additional-aliases branch September 1, 2025 02:05
@arkid15r arkid15r mentioned this pull request Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants