mypy-boto3-route53resolver
mypy-boto3-route53resolver provides type annotations for the `boto3` Route53Resolver service. It is part of the `mypy-boto3` project, which offers comprehensive type hints for all `boto3` services. This package, currently at version 1.42.10, is generated by `mypy-boto3-builder` (version 8.12.0) and typically releases frequently to keep pace with `boto3` updates and new AWS services.
Warnings
- breaking The `mypy-boto3-builder` (which generates this package) migrated to PEP 561 package structure and removed support for Python 3.8 starting with builder version 8.12.0. This means `mypy-boto3-route53resolver` version 1.42.10 and newer will not work with Python 3.8.
- breaking Starting with `mypy-boto3-builder` version 8.9.0, there were breaking changes to how TypeDef names for method arguments are generated, often resulting in shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).
- gotcha The `mypy-boto3-route53resolver` package provides type hints only; it does not include the `boto3` runtime library itself. For your code to execute, `boto3` must be installed separately.
- gotcha To effectively use these type annotations, `mypy` must be installed and configured to check your project. Simply installing the stub package is not enough; you must integrate `mypy` into your development workflow.
Install
-
pip install mypy-boto3-route53resolver
Imports
- Route53ResolverClient
from mypy_boto3_route53resolver.client import Route53ResolverClient
- ListFirewallConfigsRequestRequestTypeDef
from mypy_boto3_route53resolver.type_defs import ListFirewallConfigsRequestRequestTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
# Only import type hints during type checking, not at runtime
if TYPE_CHECKING:
from mypy_boto3_route53resolver.client import Route53ResolverClient
from mypy_boto3_route53resolver.type_defs import ListFirewallConfigsRequestRequestTypeDef
def get_resolver_client() -> "Route53ResolverClient":
"""Initializes and returns a Route53Resolver client with type hints."""
# boto3.client returns an untyped client; mypy uses the stub's definition
return boto3.client("route53resolver")
def list_firewall_configs():
"""Lists Route53 Resolver firewall configurations."""
client: Route53ResolverClient = get_resolver_client()
# Example request type for a method
# The actual arguments passed to list_firewall_configs will be type-checked
request_params: ListFirewallConfigsRequestRequestTypeDef = {
"MaxResults": 10
}
response = client.list_firewall_configs(**request_params)
print("Firewall Configurations:")
for config in response.get("FirewallConfigs", []):
print(f" - {config.get('Id')} ({config.get('Name')})")
if __name__ == "__main__":
# This code requires AWS credentials configured (e.g., via AWS CLI or environment variables)
try:
list_firewall_configs()
except Exception as e:
print(f"Error during quickstart execution (likely AWS credentials/config issue): {e}")
print("Please ensure your AWS credentials are configured.")