mypy-boto3-geo-maps
mypy-boto3-geo-maps provides type annotations for the `boto3` AWS LocationServiceMapsV2 service. It enhances development with static type checking, autocompletion, and improved code readability for `boto3` users. The library is actively maintained with frequent updates, aligning with `boto3` releases and the `mypy-boto3-builder`'s development cadence.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0 (which generated `mypy-boto3-geo-maps 1.42.84`). Projects using Python 3.8 will need to upgrade to Python 3.9 or newer.
- breaking Breaking changes in `mypy-boto3-builder` 8.9.0 introduced shorter names for TypeDefs for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This affects explicit imports of such TypeDefs.
- gotcha As of `mypy-boto3-builder` 8.12.0, all `mypy-boto3` packages (including `mypy-boto3-geo-maps`) are PEP 561 compliant. This generally simplifies `mypy`'s ability to find stubs, but if you had a custom or non-standard `mypy` setup for older versions, you might need to ensure your `mypy` configuration is up-to-date.
- gotcha When using `pylint`, it may report 'undefined variables' for type-hinted clients or TypeDefs, especially if `mypy-boto3` packages are not in `install_requires` for production builds. Using a `TYPE_CHECKING` guard can mitigate this.
Install
-
pip install mypy-boto3-geo-maps boto3 -
pip install 'boto3-stubs[geo-maps]' boto3
Imports
- LocationServiceMapsV2Client
from mypy_boto3_geo_maps.client import LocationServiceMapsV2Client
- CreateMapRequestRequestTypeDef
from mypy_boto3_geo_maps.type_defs import CreateMapRequestRequestTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_geo_maps.client import LocationServiceMapsV2Client
from mypy_boto3_geo_maps.type_defs import CreateMapRequestRequestTypeDef
# Get a typed client for AWS Location Service (Maps V2)
client: 'LocationServiceMapsV2Client' = boto3.client("geo-maps")
# Example usage with a typed request (for illustration, not runnable without AWS creds)
try:
# Define a request payload using TypeDef
create_map_request: CreateMapRequestRequestTypeDef = {
"MapName": "MyTestMap",
"Configuration": {"Style": "VectorEsriStreets"},
"Description": "A test map created via mypy-boto3-geo-maps",
}
# The actual API call (will raise ClientError without valid AWS setup)
response = client.create_map(**create_map_request)
print(f"Successfully initiated map creation: {response['MapArn']}")
except client.exceptions.ConflictException as e:
print(f"Map already exists: {e}")
except Exception as e:
print(f"An error occurred: {e}")
# Example of getting a static map (assuming a map exists and permissions are set)
# This call would require valid map name and API key if used publicly
# response = client.get_static_map(
# MapName="MyTestMap",
# CenterX=-77.0369,
# CenterY=38.9072,
# Zoom=12,
# Width=400,
# Height=300
# )
# print(f"Received static map data: {len(response['ImageData'])} bytes")