/
/
/
1"""Helper for the shared bundled ISO country code list."""
2
3from __future__ import annotations
4
5import json
6from functools import cache
7from importlib import resources
8from typing import cast
9
10
11@cache
12def get_country_codes() -> dict[str, str]:
13 """
14 Return the bundled ISO 3166-1 alpha-2 country code map.
15
16 Keys are uppercase two-letter codes (e.g. ``"NL"``), values are the English country name.
17 """
18 countries_file = resources.files(__package__).joinpath("resources", "countries.json")
19 raw = countries_file.read_text(encoding="utf-8")
20 return cast("dict[str, str]", json.loads(raw))
21