mypy-boto3-route53resolver

1.42.10 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` Route53Resolver client and use its methods with `mypy-boto3-route53resolver` type hints. The `TYPE_CHECKING` block ensures type imports are only active during static analysis, avoiding runtime overhead or potential circular imports. The example lists firewall configurations, expecting AWS credentials to be configured in the environment.

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.")

view raw JSON →