mypy-boto3-appmesh
mypy-boto3-appmesh provides type annotations for the boto3 AppMesh 1.42.3 service, generated using mypy-boto3-builder 8.12.0. This library enhances type checking and IDE autocompletion for AWS SDK usage in Python projects. It is part of the larger `mypy-boto3` ecosystem which aims to provide comprehensive type hints for all boto3 services and closely follows boto3's release cycle.
Warnings
- breaking Python 3.8 is no longer supported by `mypy-boto3-builder` (version 8.12.0 and above), which generates `mypy-boto3-appmesh`.
- breaking Type definition (TypedDict) naming conventions changed in `mypy-boto3-builder`. Shorter names are used, and 'Extra' postfixes moved, which can break existing explicit `TypeDef` imports.
- gotcha This package only provides type annotations. The `boto3` library itself must be installed in your environment for runtime execution of AWS API calls.
- gotcha For Pylint compatibility, if `mypy-boto3-appmesh` is a dev-only dependency, Pylint may complain about undefined variables. Using `if TYPE_CHECKING:` guards around imports helps.
- gotcha Some IDEs (like VSCode with certain extensions) might require explicit type annotations for `boto3.client()` and `boto3.resource()` calls to provide full autocomplete and type checking, even if `mypy` itself can infer them.
- gotcha When passing dictionaries as arguments to boto3 methods, ensure they match the generated `TypedDict` structure. Mypy will flag direct dictionaries as type mismatches if not explicitly cast or constructed as the `TypedDict`.
Install
-
pip install mypy-boto3-appmesh boto3
Imports
- AppMeshClient
from mypy_boto3_appmesh import AppMeshClient
- AppMeshServiceResource
from mypy_boto3_appmesh import AppMeshServiceResource
- ListMeshesResponseTypeDef
from mypy_boto3_appmesh.type_defs import ListMeshesResponseTypeDef
Quickstart
import os
from typing import TYPE_CHECKING
import boto3
if TYPE_CHECKING:
from mypy_boto3_appmesh import AppMeshClient
from mypy_boto3_appmesh.type_defs import ListMeshesResponseTypeDef
# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
# For example:
# os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')
# os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')
# os.environ['AWS_REGION'] = os.environ.get('AWS_REGION', 'us-east-1')
def list_app_meshes() -> None:
session = boto3.Session()
client: AppMeshClient = session.client("appmesh")
try:
# Using explicit type annotation for the response for demonstration
response: ListMeshesResponseTypeDef = client.list_meshes()
print("App Mesh Meshes:")
for mesh in response.get("meshes", []):
print(f" - {mesh.get('meshName')}")
except Exception as e:
print(f"Error listing App Meshes: {e}")
if __name__ == "__main__":
list_app_meshes()