mypy-boto3-kinesis-video-media Type Stubs
mypy-boto3-kinesis-video-media provides type annotations for the `boto3` Kinesis Video Media service, enabling static type checking with tools like Mypy. It is part of the `mypy-boto3` project which generates comprehensive type stubs for all AWS services supported by `boto3`. The current version is 1.42.3, and new versions are released frequently, synchronized with `boto3`/`botocore` updates.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Any `mypy-boto3-*` packages built with 8.12.0 or newer (including `mypy-boto3-kinesis-video-media` 1.42.3) require Python 3.9 or higher.
- breaking Starting with `mypy-boto3-builder` 8.9.0, TypeDef names for method arguments (especially those ending with 'RequestTypeDef') were shortened, and conflicting TypeDef 'Extra' postfixes were moved. This can break code that directly imports or references specific TypeDefs.
- gotcha These are service-specific stubs. To type-check all `boto3` clients, you typically need to install `mypy-boto3-core` or install a separate `mypy-boto3-*` package for each AWS service you use. Mypy will only provide type hints for the services whose stubs are installed.
- gotcha The `mypy-boto3` project migrated to PEP 561 compliant packages in `mypy-boto3-builder` version 8.12.0. While this generally improves compatibility and discovery, ensure your build system properly recognizes and uses namespace packages if you encounter issues.
Install
-
pip install mypy-boto3-kinesis-video-media -
pip install boto3
Imports
- KinesisVideoMediaClient
from mypy_boto3_kinesis_video_media.client import KinesisVideoMediaClient
- boto3
import boto3
Quickstart
import boto3
from typing import TYPE_CHECKING
# These type imports are only needed for explicit annotations during type checking.
# Mypy often discovers them automatically if the stubs are installed.
if TYPE_CHECKING:
from mypy_boto3_kinesis_video_media.client import KinesisVideoMediaClient
from mypy_boto3_kinesis_video_media.type_defs import GetMediaInputRequestTypeDef
def get_kinesis_video_media_client():
# In a real application, ensure credentials/region are configured
# via environment variables, ~/.aws/credentials, or boto3 session config.
# For this example, we assume default configuration.
client = boto3.client("kinesis-video-media")
# For static type checking with Mypy, you can explicitly annotate the client.
if TYPE_CHECKING:
typed_client: KinesisVideoMediaClient = client
# Example of using a TypedDict from the stubs
get_media_params: GetMediaInputRequestTypeDef = {
"StreamARN": "arn:aws:kinesisvideo:REGION:ACCOUNT_ID:stream/YOUR_STREAM/1234567890123",
"StartSelector": {"StartSelectorType": "NOW"}
}
print(f"Client with type hints ready: {typed_client}")
# Mypy will now validate calls to `typed_client` based on KinesisVideoMedia API.
# Example (commented out as it requires a live stream and specific permissions):
# response = typed_client.get_media(**get_media_params)
# print(f"Response: {response}")
else:
print(f"Runtime client: {client}")
get_kinesis_video_media_client()