mypy-boto3-vpc-lattice

1.42.3 · active · verified Sat Apr 11

mypy-boto3-vpc-lattice provides type annotations for the `boto3` AWS SDK's VPCLattice service, compatible with `mypy`, `pyright`, VSCode, and PyCharm. It's automatically generated by `mypy-boto3-builder` and aims to enhance static type checking for `boto3` users. The project follows a frequent release cadence, often synchronizing with `boto3` updates and `mypy-boto3-builder` enhancements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `mypy-boto3-vpc-lattice` for type-hinting a `boto3` VPC Lattice client. The `TYPE_CHECKING` block ensures that the type stub imports are only active during static analysis, avoiding runtime dependencies on the stub package. The `boto3.client` call returns the actual runtime client, which `mypy` (or another type checker) will understand as `VPCLatticeClient` thanks to the installed stubs.

import os
from typing import TYPE_CHECKING
import boto3

# These imports are only for type checking and won't be evaluated at runtime
if TYPE_CHECKING:
    from mypy_boto3_vpc_lattice.client import VPCLatticeClient
    from mypy_boto3_vpc_lattice.type_defs import ServiceSummaryTypeDef

def list_vpc_lattice_services() -> list["ServiceSummaryTypeDef"]:
    # Initialize a boto3 client (runtime object)
    # The type checker uses the VPCLatticeClient stub for this call
    client: VPCLatticeClient = boto3.client("vpc-lattice", region_name=os.environ.get('AWS_REGION', 'us-east-1'))
    
    print("Listing VPC Lattice services...")
    response = client.list_services()
    services = response.get("items", [])
    
    for service in services:
        print(f"  Service ID: {service.get('id')}, Name: {service.get('name')}")
    
    return services

if __name__ == "__main__":
    # Set a dummy AWS_REGION for local execution if not already set
    # In a real scenario, credentials/region would be configured via env vars, ~/.aws/config, etc.
    if 'AWS_REGION' not in os.environ:
        os.environ['AWS_REGION'] = 'us-east-1'

    try:
        # This call will actually execute and might require AWS credentials
        services = list_vpc_lattice_services()
        print(f"Found {len(services)} VPC Lattice services.")
    except Exception as e:
        print(f"An error occurred: {e}. Make sure you have AWS credentials configured.")

view raw JSON →