mypy-boto3-geo-places type annotations for AWS Location Service Places V2

1.42.82 · active · verified Sat Apr 11

This library provides comprehensive type annotations for the `boto3` AWS SDK, specifically for the Location Service Places V2. Generated by `mypy-boto3-builder`, it enhances developer experience by enabling static type checking with tools like Mypy and improving IDE features like autocompletion and error detection for `boto3` calls. The current version is 1.42.82, with releases typically synchronized with `boto3` updates and `mypy-boto3-builder` enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-geo-places` to type-hint a `boto3` Location Service Places V2 client and its API responses. The `TYPE_CHECKING` block ensures that the type imports are only active during static analysis, avoiding runtime dependencies. Remember that `boto3` itself needs to be configured with AWS credentials to make actual API calls.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_geo_places.client import LocationServicePlacesV2Client
    from mypy_boto3_geo_places.type_defs import SearchPlaceIndexForTextResponseTypeDef


def search_places(index_name: str, text: str) -> SearchPlaceIndexForTextResponseTypeDef:
    client: LocationServicePlacesV2Client = boto3.client("geo-places", region_name="us-east-1")
    response: SearchPlaceIndexForTextResponseTypeDef = client.search_place_index_for_text(
        IndexName=index_name,
        Text=text
    )
    return response

# Example usage (will not run without actual AWS credentials and an index)
if __name__ == "__main__":
    # Replace with your actual index name
    my_index = "YOUR_PLACE_INDEX_NAME"
    search_query = "coffee shop in New York"

    try:
        # Mock environment variables for demonstration, replace with actual if running
        import os
        os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY')
        os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET')

        result = search_places(my_index, search_query)
        print(f"Found {len(result['Results'])} places.")
        for place in result['Results']:
            print(f"  Place: {place['Place']['Label']}")
    except Exception as e:
        print(f"An error occurred (expected without proper AWS setup): {e}")

view raw JSON →