mypy-boto3-vpc-lattice
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
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0, affecting all generated `mypy-boto3` packages. Users on Python 3.8 must pin to an older version of `mypy-boto3-vpc-lattice` (prior to versions generated by builder 8.12.0) or upgrade their Python environment.
- breaking In `mypy-boto3-builder` version 8.9.0, there were breaking changes to TypeDef naming conventions. Packed method arguments now use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes were moved to the end of the name (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). This may require updates to explicit TypeDef annotations in user code.
- gotcha This package provides only type annotations for `boto3`. You must install `boto3` separately for your code to run. This package is solely for static analysis tools like `mypy` or `pyright`.
- gotcha PyCharm's built-in type checker can experience slow performance or high CPU usage with the full `boto3-stubs` packages due to complex Literal overloads. For better IDE performance, consider using `boto3-stubs-lite` (e.g., `pip install 'boto3-stubs-lite[vpc-lattice]'`) or disabling PyCharm's type checker and relying on external tools like `mypy` or `pyright`.
Install
-
pip install mypy-boto3-vpc-lattice boto3 -
pip install 'boto3-stubs[vpc-lattice]' boto3
Imports
- VPCLatticeClient
from mypy_boto3_vpc_lattice.client import VPCLatticeClient
- ListServicesPaginator
from mypy_boto3_vpc_lattice.paginator import ListServicesPaginator
- ServiceSummaryTypeDef
from mypy_boto3_vpc_lattice.type_defs import ServiceSummaryTypeDef
Quickstart
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.")