Skip to content

Examples#

Index > LocationService > Examples

Auto-generated documentation for LocationService type annotations stubs module mypy-boto3-location.

Client#

Implicit type annotations#

Can be used with boto3-stubs[location] package installed.

Write your LocationService code as usual, type checking and code completion should work out of the box.

Client method usage example#

# LocationServiceClient usage example

from boto3.session import Session


session = Session()

client = session.client("location")  # (1)
result = client.batch_delete_device_position_history()  # (2)
  1. client: LocationServiceClient
  2. result: BatchDeleteDevicePositionHistoryResponseTypeDef

Paginator usage example#

# ForecastGeofenceEventsPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("location")  # (1)

paginator = client.get_paginator("forecast_geofence_events")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: LocationServiceClient
  2. paginator: ForecastGeofenceEventsPaginator
  3. item: ForecastGeofenceEventsResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[location] or a standalone mypy_boto3_location package, you have to explicitly specify client: LocationServiceClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

Client method usage example#

# LocationServiceClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_location.client import LocationServiceClient
from mypy_boto3_location.type_defs import BatchDeleteDevicePositionHistoryResponseTypeDef
from mypy_boto3_location.type_defs import BatchDeleteDevicePositionHistoryRequestTypeDef


session = Session()

client: LocationServiceClient = session.client("location")

kwargs: BatchDeleteDevicePositionHistoryRequestTypeDef = {...}
result: BatchDeleteDevicePositionHistoryResponseTypeDef = client.batch_delete_device_position_history(**kwargs)

Paginator usage example#

# ForecastGeofenceEventsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_location.client import LocationServiceClient
from mypy_boto3_location.paginator import ForecastGeofenceEventsPaginator
from mypy_boto3_location.type_defs import ForecastGeofenceEventsResponseTypeDef


session = Session()
client: LocationServiceClient = session.client("location")

paginator: ForecastGeofenceEventsPaginator = client.get_paginator("forecast_geofence_events")
for item in paginator.paginate(...):
    item: ForecastGeofenceEventsResponseTypeDef
    print(item)