Skip to content

Location

location

Location

Location(client: _HTTPClientT_co)

Bases: AsyncBaseExtension[Location]

Extension for location related endpoints.

Source code in pokelance/ext/_base.py
def __init__(self, client: _HTTPClientT_co) -> None:
    self._client = client
    self._cache_manager = client.cache_manager
    self._cache_group = getattr(self._cache_manager, self.__class__.__name__.lower())

get_location

get_location(name: str | int) -> Location | None

Gets a location from the cache.

Parameters:

Name Type Description Default
name str | int

The name or id.

required

Returns:

Type Description
Location | None

The cached model or None.

Examples:

location = client.location.get_location("canalave-city")
if location:
    print(location)
Source code in pokelance/ext/_async/location.py
def get_location(self, name: str | int) -> models.Location | None:
    """Gets a location from the cache.

    Parameters
    ----------
    name : str | int
        The name or id.

    Returns
    -------
    models.Location | None
        The cached model or None.

    Examples
    --------
    ```python
    location = client.location.get_location("canalave-city")
    if location:
        print(location)
    ```"""
    route = Endpoint.get_location(name)
    self._validate_resource(self._cache_group.location, name, route)
    return self._cache_group.location.get(route, None)

fetch_location async

fetch_location(name: str | int) -> Location

Fetches a location from the API.

Parameters:

Name Type Description Default
name str | int

The name or id.

required

Returns:

Type Description
Location

The fetched model.

Examples:

location = await client.location.fetch_location("canalave-city")
print(location)
Source code in pokelance/ext/_async/location.py
async def fetch_location(self, name: str | int) -> models.Location:
    """Fetches a location from the API.

    Parameters
    ----------
    name : str | int
        The name or id.

    Returns
    -------
    models.Location
        The fetched model.

    Examples
    --------
    ```python
    location = await client.location.fetch_location("canalave-city")
    print(location)
    ```"""
    route = Endpoint.get_location(name)
    self._validate_resource(self._cache_group.location, name, route)
    data = await self._client.request(route)
    return self._cache_group.location.setdefault(route, self._cache_group.location.from_payload(data))

get_location_area

get_location_area(name: str | int) -> LocationArea | None

Gets a location area from the cache.

Parameters:

Name Type Description Default
name str | int

The name or id.

required

Returns:

Type Description
LocationArea | None

The cached model or None.

Examples:

area = client.location.get_location_area("canalave-city-area")
if area:
    print(area)
Source code in pokelance/ext/_async/location.py
def get_location_area(self, name: str | int) -> models.LocationArea | None:
    """Gets a location area from the cache.

    Parameters
    ----------
    name : str | int
        The name or id.

    Returns
    -------
    models.LocationArea | None
        The cached model or None.

    Examples
    --------
    ```python
    area = client.location.get_location_area("canalave-city-area")
    if area:
        print(area)
    ```"""
    route = Endpoint.get_location_area(name)
    self._validate_resource(self._cache_group.location_area, name, route)
    return self._cache_group.location_area.get(route, None)

fetch_location_area async

fetch_location_area(name: str | int) -> LocationArea

Fetches a location area from the API.

Parameters:

Name Type Description Default
name str | int

The name or id.

required

Returns:

Type Description
LocationArea

The fetched model.

Examples:

area = await client.location.fetch_location_area("canalave-city-area")
print(area)
Source code in pokelance/ext/_async/location.py
async def fetch_location_area(self, name: str | int) -> models.LocationArea:
    """Fetches a location area from the API.

    Parameters
    ----------
    name : str | int
        The name or id.

    Returns
    -------
    models.LocationArea
        The fetched model.

    Examples
    --------
    ```python
    area = await client.location.fetch_location_area("canalave-city-area")
    print(area)
    ```"""
    route = Endpoint.get_location_area(name)
    self._validate_resource(self._cache_group.location_area, name, route)
    data = await self._client.request(route)
    return self._cache_group.location_area.setdefault(route, self._cache_group.location_area.from_payload(data))

get_pal_park_area

get_pal_park_area(name: str | int) -> PalParkArea | None

Gets a pal park area from the cache.

Parameters:

Name Type Description Default
name str | int

The name or id.

required

Returns:

Type Description
PalParkArea | None

The cached model or None.

Examples:

area = client.location.get_pal_park_area("forest")
if area:
    print(area)
Source code in pokelance/ext/_async/location.py
def get_pal_park_area(self, name: str | int) -> models.PalParkArea | None:
    """Gets a pal park area from the cache.

    Parameters
    ----------
    name : str | int
        The name or id.

    Returns
    -------
    models.PalParkArea | None
        The cached model or None.

    Examples
    --------
    ```python
    area = client.location.get_pal_park_area("forest")
    if area:
        print(area)
    ```"""
    route = Endpoint.get_pal_park_area(name)
    self._validate_resource(self._cache_group.pal_park_area, name, route)
    return self._cache_group.pal_park_area.get(route, None)

fetch_pal_park_area async

fetch_pal_park_area(name: str | int) -> PalParkArea

Fetches a pal park area from the API.

Parameters:

Name Type Description Default
name str | int

The name or id.

required

Returns:

Type Description
PalParkArea

The fetched model.

Examples:

area = await client.location.fetch_pal_park_area("forest")
print(area)
Source code in pokelance/ext/_async/location.py
async def fetch_pal_park_area(self, name: str | int) -> models.PalParkArea:
    """Fetches a pal park area from the API.

    Parameters
    ----------
    name : str | int
        The name or id.

    Returns
    -------
    models.PalParkArea
        The fetched model.

    Examples
    --------
    ```python
    area = await client.location.fetch_pal_park_area("forest")
    print(area)
    ```"""
    route = Endpoint.get_pal_park_area(name)
    self._validate_resource(self._cache_group.pal_park_area, name, route)
    data = await self._client.request(route)
    return self._cache_group.pal_park_area.setdefault(route, self._cache_group.pal_park_area.from_payload(data))

get_region

get_region(name: str | int) -> Region | None

Gets a region from the cache.

Parameters:

Name Type Description Default
name str | int

The name or id.

required

Returns:

Type Description
Region | None

The cached model or None.

Examples:

region = client.location.get_region("kanto")
if region:
    print(region)
Source code in pokelance/ext/_async/location.py
def get_region(self, name: str | int) -> models.Region | None:
    """Gets a region from the cache.

    Parameters
    ----------
    name : str | int
        The name or id.

    Returns
    -------
    models.Region | None
        The cached model or None.

    Examples
    --------
    ```python
    region = client.location.get_region("kanto")
    if region:
        print(region)
    ```"""
    route = Endpoint.get_region(name)
    self._validate_resource(self._cache_group.region, name, route)
    return self._cache_group.region.get(route, None)

fetch_region async

fetch_region(name: str | int) -> Region

Fetches a region from the API.

Parameters:

Name Type Description Default
name str | int

The name or id.

required

Returns:

Type Description
Region

The fetched model.

Examples:

region = await client.location.fetch_region("kanto")
print(region)
Source code in pokelance/ext/_async/location.py
async def fetch_region(self, name: str | int) -> models.Region:
    """Fetches a region from the API.

    Parameters
    ----------
    name : str | int
        The name or id.

    Returns
    -------
    models.Region
        The fetched model.

    Examples
    --------
    ```python
    region = await client.location.fetch_region("kanto")
    print(region)
    ```"""
    route = Endpoint.get_region(name)
    self._validate_resource(self._cache_group.region, name, route)
    data = await self._client.request(route)
    return self._cache_group.region.setdefault(route, self._cache_group.region.from_payload(data))

setup

setup(lance: PokeLanceAsyncClient) -> None

Sets up the location extension.

Source code in pokelance/ext/_async/location.py
def setup(lance: PokeLanceAsyncClient) -> None:
    """Sets up the location extension."""
    lance.add_extension("location", Location(lance.http))

Comments