Skip to content

Commit

Permalink
Allow countries attribute as string
Browse files Browse the repository at this point in the history
  • Loading branch information
dc-almeida committed Oct 10, 2024
1 parent e64ed34 commit 49758c1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nomenclature/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ class RegionCode(Code):
"""

hierarchy: str = None
countries: Optional[List[str]] = None
countries: Optional[Union[List[str], str]] = None
iso3_codes: Optional[Union[List[str], str]] = None

@field_validator("countries")
def check_countries(cls, v: List[str], info: ValidationInfo) -> List[str]:
"""Verifies that each country name is defined in `nomenclature.countries`."""
if invalid_country_names := set(v) - set(countries.names):
if invalid_country_names := set(to_list(v)) - set(countries.names):
raise ValueError(
f"Region '{info.data['name']}' uses non-standard country name(s): "
+ ", ".join(invalid_country_names)
Expand Down

0 comments on commit 49758c1

Please sign in to comment.