mypy-boto3-transcribe

1.42.25 · active · verified Sat Apr 11

mypy-boto3-transcribe provides type annotations for the boto3 Transcribe service, specifically for version 1.42.25 of boto3. These packages are automatically generated by `mypy-boto3-builder` and are released frequently to keep up with boto3 updates, offering precise type hints for clients, resources, and various TypeDefs.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `TranscribeClient` using `boto3` and `typing.cast`. It then shows a simple usage example to list transcription jobs, highlighting how `mypy` can provide static analysis for `boto3` calls.

import boto3
from mypy_boto3_transcribe.client import TranscribeClient
from typing import TYPE_CHECKING, cast
import os

# Boto3 client requires AWS credentials, which can be configured via
# environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)
# or other boto3 configuration methods.

if TYPE_CHECKING:
    # This block is only for type checking tools like mypy or pyright.
    # It helps prevent runtime import issues and ensures correct type resolution.
    pass

def get_typed_transcribe_client() -> TranscribeClient:
    """Returns a type-hinted boto3 Transcribe client."""
    # boto3.client returns a DynamicClient which is untyped.
    # We cast it to the specific mypy-boto3-transcribe client type.
    client = boto3.client("transcribe", region_name=os.environ.get('AWS_REGION', 'us-east-1'))
    return cast(TranscribeClient, client)

# --- Example Usage ---

transcribe_client = get_typed_transcribe_client()

print("Listing first 3 transcription jobs:")
response = transcribe_client.list_transcription_jobs(
    MaxResults=3,
    Status='COMPLETED' # Example filter
)

job_summaries = response.get("TranscriptionJobSummaries", [])
if job_summaries:
    for job in job_summaries:
        print(f"  - Name: {job['TranscriptionJobName']}, Status: {job['TranscriptionJobStatus']}")
else:
    print("  No completed transcription jobs found.")

# mypy will now correctly check arguments and return types for methods of transcribe_client
# e.g., transcribe_client.start_transcription_job(TranscriptionJobName=123) will be flagged
# as TranscriptionJobName expects a string.

view raw JSON →