CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-us

A package for easily working with US and state metadata

Overall
score

88%

Overview
Eval results
Files

task.mdevals/scenario-5/

US Territory Validator

Build a utility that validates and categorizes US geographic entities to distinguish between states and territories.

Capabilities

Validate Territory Status

  • When given "PR", return True indicating it is a territory @test
  • When given "Guam", return True indicating it is a territory @test
  • When given "California", return False indicating it is not a territory @test
  • When given "TX", return False indicating it is not a territory @test

List All Territories

  • Return a list of all 5 US territory names in alphabetical order @test

Count Entities by Type

  • When given a list containing ["CA", "PR", "NY", "GU"], return {"states": 2, "territories": 2} @test
  • When given a list containing ["Alaska", "Virgin Islands", "Texas"], return {"states": 2, "territories": 1} @test

Implementation

@generates

API

def is_territory(identifier: str) -> bool:
    """
    Check if the given identifier (name or abbreviation) represents a US territory.

    Args:
        identifier: State/territory name or postal abbreviation (case-insensitive)

    Returns:
        True if the identifier represents a territory, False otherwise

    Raises:
        ValueError: If the identifier is not a valid US state or territory
    """
    pass

def list_all_territories() -> list[str]:
    """
    Return a list of all US territory names in alphabetical order.

    Returns:
        List of territory names sorted alphabetically
    """
    pass

def count_by_type(identifiers: list[str]) -> dict[str, int]:
    """
    Count how many states and territories are in the given list.

    Args:
        identifiers: List of state/territory names or abbreviations

    Returns:
        Dictionary with keys "states" and "territories" containing counts

    Raises:
        ValueError: If any identifier is not a valid US state or territory
    """
    pass

Dependencies { .dependencies }

us { .dependency }

Provides US state and territory metadata including territory identification.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-us

tile.json