Type Annotations for aiobotocore Route53
Provides static type checking for `aiobotocore`'s Route53 service using `mypy`. It enhances asynchronous AWS operations in Python by offering precise type hints for clients, requests, and responses. The project is actively maintained, with frequent releases that often align with `boto3`/`aiobotocore` updates and `mypy-boto3-builder` improvements.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0 (which generated `types-aiobotocore-route53` version 3.4.0). Users on Python 3.8 will need to pin to an older version of the stubs.
- breaking TypedDict names for service request/response arguments changed significantly in `mypy-boto3-builder` version 8.9.0. Names were shortened (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) and `Extra` postfixes moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`).
- gotcha These are type stubs for `aiobotocore`. You must install `aiobotocore` itself (`pip install aiobotocore`) in addition to `types-aiobotocore-route53` for your code to run at runtime. The type stubs only provide static analysis.
- gotcha While `types-aiobotocore` aims to be compatible with `aiobotocore`, significant version mismatches between the stubs and the runtime library can lead to incorrect type checking or runtime errors. For best results, keep their versions relatively synchronized.
Install
-
pip install types-aiobotocore-route53
Imports
- Route53Client
from types_aiobotocore_route53 import Route53Client
- Route53ServiceName
from types_aiobotocore_route53 import Route53ServiceName
- ListHostedZonesResponseTypeDef
from types_aiobotocore_route53.type_defs import ListHostedZonesResponseTypeDef
Quickstart
import asyncio
from aiobotocore.session import get_session
from types_aiobotocore_route53 import Route53Client, Route53ServiceName
from types_aiobotocore_route53.type_defs import ListHostedZonesResponseTypeDef, HostedZoneSummaryTypeDef
async def main():
# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
session = get_session()
async with session.create_client(Route53ServiceName.route53) as client: # type: Route53Client
print(f"Successfully created Route53 client: {type(client)}")
try:
response: ListHostedZonesResponseTypeDef = await client.list_hosted_zones()
print(f"Number of hosted zones: {len(response['HostedZones'])}")
for zone: HostedZoneSummaryTypeDef in response['HostedZones']:
print(f" ID: {zone['Id']}, Name: {zone['Name']}, Public: {not zone['Config']['PrivateZone']}")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
asyncio.run(main())