mypy-boto3-mediastore
mypy-boto3-mediastore provides type annotations for the boto3 AWS MediaStore service. It is part of the `mypy-boto3` family of stub packages, generated by `mypy-boto3-builder`, and is frequently updated to align with `boto3` releases and AWS API changes. This allows for static type checking of boto3 client calls, enhancing code quality and developer experience.
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and later, affecting packages built with it, including `mypy-boto3-mediastore`. Ensure your project uses Python 3.9 or higher.
- breaking TypeDef naming conventions were changed in `mypy-boto3-builder` version 8.9.0. This might affect direct imports of specific `TypeDef` classes (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).
- gotcha This package provides *only* type stubs. You must install the actual `boto3` library to use AWS services at runtime. `mypy-boto3-mediastore` will be automatically detected by `mypy` (PEP 561 compliant) if both are installed in the same environment.
- gotcha While `mypy` often automatically infers types, explicit type annotations for `boto3.client` and similar calls (e.g., `client: MediaStoreClient = session.client('mediastore')`) are highly recommended for better IDE auto-completion and more robust type checking, especially with versions like `boto3-stubs-lite` which do not provide `session.client/resource` overloads.
Install
-
pip install mypy-boto3-mediastore boto3 mypy
Imports
- MediaStoreClient
from mypy_boto3_mediastore import MediaStoreClient
- ContainerTypeDef
from mypy_boto3_mediastore.type_defs import ContainerTypeDef
- ListContainersPaginator
from mypy_boto3_mediastore.paginator import ListContainersPaginator
- ContainerLevelMetricsType
from mypy_boto3_mediastore.literals import ContainerLevelMetricsType
Quickstart
import os
import boto3
from mypy_boto3_mediastore import MediaStoreClient
from mypy_boto3_mediastore.type_defs import ContainerTypeDef
def list_mediastore_containers(client: MediaStoreClient) -> list[ContainerTypeDef]:
"""Lists MediaStore containers and returns typed responses."""
response = client.list_containers()
containers = response.get('Containers', [])
print(f"Found {len(containers)} MediaStore containers.")
for container in containers:
print(f" Container Name: {container.get('Name')}, Status: {container.get('Status')}")
return containers
if __name__ == "__main__":
# Ensure AWS credentials are configured (e.g., via environment variables or ~/.aws/credentials)
session = boto3.Session(region_name=os.environ.get('AWS_REGION', 'us-east-1'))
mediastore_client: MediaStoreClient = session.client('mediastore')
print("Listing MediaStore containers...")
containers = list_mediastore_containers(mediastore_client)
# Example of accessing a typed attribute (mypy would check this)
if containers:
first_container_arn: str = containers[0]['ARN']
print(f"First container ARN: {first_container_arn}")
# To run static analysis:
# pip install mypy
# mypy your_script_name.py