mypy-boto3-storagegateway: Boto3 StorageGateway Type Stubs
mypy-boto3-storagegateway provides type annotations for the AWS Boto3 StorageGateway service. It helps developers write type-safe Python code that interacts with StorageGateway by providing static type hints for clients, resources, and data structures. The library is generated by `mypy-boto3-builder` and is updated frequently, often daily or weekly, to keep pace with new `boto3` releases and AWS API changes, ensuring up-to-date type definitions.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. If you are using `mypy-boto3-storagegateway` version 1.42.3 or newer, your projects must use Python 3.9 or higher for type checking.
- breaking In `mypy-boto3-builder` version 8.9.0, there were breaking changes to TypeDef naming conventions, specifically for packed method arguments, shortening names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). This can cause type errors if updating from significantly older versions of the stubs.
- gotcha For optimal type checking accuracy, ensure the `mypy-boto3-storagegateway` version you install closely matches your `boto3` library version. Significant mismatches can lead to incorrect type hints or missing definitions, especially with new service features or API changes.
- gotcha These packages provide static type annotations for `boto3`; they do not replace `boto3` itself. You must have `boto3` installed to actually run your code against AWS services.
Install
-
pip install mypy-boto3-storagegateway -
pip install boto3-stubs[storagegateway]
Imports
- StorageGatewayClient
from mypy_boto3_storagegateway.client import StorageGatewayClient
- Client
from mypy_boto3_storagegateway import Client
- ListGatewaysOutputTypeDef
from mypy_boto3_storagegateway.type_defs import ListGatewaysOutputTypeDef
Quickstart
import boto3
from mypy_boto3_storagegateway import StorageGatewayClient
from mypy_boto3_storagegateway.type_defs import ListGatewaysOutputTypeDef
def get_storagegateway_client() -> StorageGatewayClient:
"""Returns a typed StorageGateway client."""
# boto3.client will automatically pick up the type hints
# if mypy-boto3-storagegateway is installed.
return boto3.client("storagegateway")
# Get a type-hinted StorageGateway client
client: StorageGatewayClient = get_storagegateway_client()
try:
# Use the client with type-hinted response
response: ListGatewaysOutputTypeDef = client.list_gateways(Limit=10)
gateway_names = [g['GatewayARN'] for g in response.get('GatewayInfos', [])]
if gateway_names:
print(f"Found gateways: {', '.join(gateway_names)}")
else:
print("No gateways found.")
except Exception as e:
print(f"An error occurred: {e}")
# For authentication, ensure AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials, or IAM roles)
# This quickstart assumes default credential setup.