{"id":3112,"library":"mypy-boto3-mediaconvert","title":"mypy-boto3-mediaconvert Type Annotations","description":"mypy-boto3-mediaconvert provides type annotations for the boto3 MediaConvert service, enhancing static analysis and IDE support for Python developers working with AWS. It ensures early error detection and improved code readability. This package is part of the larger `mypy-boto3-builder` ecosystem, which frequently releases updates in sync with `boto3` versions.","status":"active","version":"1.42.88","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-hints","cloud","mediaconvert"],"install":[{"cmd":"pip install mypy-boto3-mediaconvert boto3 mypy","lang":"bash","label":"Standalone installation"},{"cmd":"pip install 'boto3-stubs[mediaconvert]' boto3 mypy","lang":"bash","label":"Recommended: using boto3-stubs extras"}],"dependencies":[{"reason":"Runtime dependency for AWS SDK functionality.","package":"boto3"},{"reason":"Static type checker for leveraging type annotations.","package":"mypy"}],"imports":[{"symbol":"MediaConvertClient","correct":"from mypy_boto3_mediaconvert.client import MediaConvertClient"},{"symbol":"CreateJobRequestTypeDef","correct":"from mypy_boto3_mediaconvert.type_defs import CreateJobRequestTypeDef"},{"symbol":"CreateJobResponseTypeDef","correct":"from mypy_boto3_mediaconvert.type_defs import CreateJobResponseTypeDef"},{"symbol":"AacAudioDescriptionBroadcasterMixType","correct":"from mypy_boto3_mediaconvert.literals import AacAudioDescriptionBroadcasterMixType"},{"note":"Commonly used with an 'if TYPE_CHECKING:' block to avoid runtime dependency.","symbol":"TYPE_CHECKING","correct":"from typing import TYPE_CHECKING"},{"note":"The client object itself is from boto3, mypy-boto3 provides the type definition for it.","wrong":"from mypy_boto3_mediaconvert.client import client","symbol":"client","correct":"from boto3 import client"}],"quickstart":{"code":"import os\nfrom typing import TYPE_CHECKING, Dict, Any\nimport boto3\n\n# These imports are only for type checking, not for runtime execution\nif TYPE_CHECKING:\n    from mypy_boto3_mediaconvert.client import MediaConvertClient\n    from mypy_boto3_mediaconvert.type_defs import CreateJobRequestTypeDef, CreateJobResponseTypeDef\n\ndef create_sample_job(role_arn: str, s3_input_url: str, s3_output_bucket: str) -> Dict[str, Any]:\n    # In a real application, consider using AWS credentials from environment variables\n    # or ~/.aws/credentials. For quickstart, we assume they are configured.\n    \n    # The client variable is explicitly typed for static analysis\n    client: 'MediaConvertClient' = boto3.client(\"mediaconvert\", region_name=os.environ.get('AWS_REGION', 'us-east-1'))\n\n    job_settings: Dict[str, Any] = {\n        \"Inputs\": [\n            {\n                \"AudioSelectors\": {\"Audio Selector 1\": {\"DefaultSelection\": \"DEFAULT\"}},\n                \"FileInput\": s3_input_url,\n            }\n        ],\n        \"OutputGroups\": [\n            {\n                \"Name\": \"File Group\",\n                \"OutputGroupSettings\": {\n                    \"Type\": \"FILE_GROUP_SETTINGS\",\n                    \"FileGroupSettings\": {\"Destination\": f\"s3://{s3_output_bucket}/\"},\n                },\n                \"Outputs\": [\n                    {\n                        \"ContainerSettings\": {\"Container\":\"MP4\",\"Mp4Settings\":{}},\n                        \"VideoDescription\": {\"CodecSettings\": {\"Codec\": \"H_264\"}},\n                        \"AudioDescriptions\": [\n                            {\"CodecSettings\": {\"Codec\": \"AAC\"}}\n                        ],\n                    }\n                ],\n            }\n        ],\n    }\n\n    request_params: 'CreateJobRequestTypeDef' = {\n        \"Role\": role_arn,\n        \"Settings\": job_settings,\n        \"Queue\": os.environ.get('MEDIACONVERT_QUEUE_ARN', 'arn:aws:mediaconvert:us-east-1:123456789012:queues/Default')\n    }\n\n    try:\n        response: 'CreateJobResponseTypeDef' = client.create_job(**request_params)\n        print(\"Successfully created MediaConvert job.\")\n        print(f\"Job ID: {response['Job']['Id']}\")\n        return response\n    except client.exceptions.BadRequestException as e:\n        print(f\"Bad request: {e}\")\n        raise\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n        raise\n\nif __name__ == \"__main__\":\n    # Example usage: Replace with actual values and ensure AWS credentials/config are set.\n    # For a runnable example, you need a valid AWS account, MediaConvert permissions,\n    # an S3 input file, an S3 output bucket, and a MediaConvert queue.\n    # Using placeholder environment variables for demonstration.\n    ROLE_ARN = os.environ.get('MEDIACONVERT_ROLE_ARN', 'arn:aws:iam::123456789012:role/MediaConvertRole')\n    S3_INPUT_URL = os.environ.get('S3_INPUT_VIDEO_URL', 's3://your-input-bucket/input.mp4')\n    S3_OUTPUT_BUCKET = os.environ.get('S3_OUTPUT_BUCKET', 'your-output-bucket')\n\n    if not all([ROLE_ARN, S3_INPUT_URL, S3_OUTPUT_BUCKET, os.environ.get('AWS_REGION'), os.environ.get('MEDIACONVERT_QUEUE_ARN')]):\n        print(\"Warning: Please set MEDIACONVERT_ROLE_ARN, S3_INPUT_VIDEO_URL, S3_OUTPUT_BUCKET, AWS_REGION, and MEDIACONVERT_QUEUE_ARN environment variables for a real test.\")\n        print(\"Using dummy values for demonstration.\")\n        # Proceed with dummy values for type checking demonstration even if not runnable\n        _ = create_sample_job(ROLE_ARN, S3_INPUT_URL, S3_OUTPUT_BUCKET)\n    else:\n        create_sample_job(ROLE_ARN, S3_INPUT_URL, S3_OUTPUT_BUCKET)\n","lang":"python","description":"This quickstart demonstrates how to use `mypy-boto3-mediaconvert` for type-hinting a boto3 MediaConvert client. It shows how to import the client type and associated TypedDicts for request and response structures, enabling static analysis and IDE autocompletion. Ensure `boto3` is installed and AWS credentials are configured."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later.","message":"Python 3.8 support was removed with mypy-boto3-builder 8.12.0. Projects requiring type annotations must use Python 3.9 or newer.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder (which generates mypy-boto3-* packages)"},{"fix":"Review and update `TypeDef` import paths and names to match the new conventions (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`).","message":"TypeDef names for packed method arguments and conflicting TypeDef `Extra` postfixes were changed in mypy-boto3-builder 8.9.0. This might break existing type annotations that used the old naming conventions.","severity":"breaking","affected_versions":">=8.9.0 of mypy-boto3-builder"},{"fix":"Wrap type-only imports within `if TYPE_CHECKING:` blocks: `from typing import TYPE_CHECKING; if TYPE_CHECKING: from mypy_boto3_mediaconvert.client import MediaConvertClient`.","message":"`mypy-boto3-mediaconvert` (and other `mypy-boto3` packages) are solely for type-checking and are not runtime dependencies. To avoid unnecessary runtime overhead, always guard type-only imports with `if TYPE_CHECKING:` or ensure `mypy-boto3` packages are only installed in development environments.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure `boto3` is installed alongside `mypy-boto3-mediaconvert` (e.g., `pip install boto3 mypy-boto3-mediaconvert`).","message":"`mypy-boto3-mediaconvert` does not install `boto3`. You must install `boto3` separately for your application to function at runtime.","severity":"gotcha","affected_versions":"All"},{"fix":"Install `boto3-stubs-lite` instead of the full `boto3-stubs` or `mypy-boto3-*` packages, or disable PyCharm's internal type checker and use `mypy`/`pyright` externally.","message":"PyCharm users might experience slow performance with `Literal` overloads. Consider using `boto3-stubs-lite` if performance issues occur.","severity":"gotcha","affected_versions":"All"},{"fix":"Prefer `pip install 'boto3-stubs[mediaconvert]'` for consistency and comprehensive type coverage, especially if using `boto3.session.Session().client()`.","message":"Historically, `boto3-stubs` and `mypy-boto3` were somewhat distinct. `mypy-boto3` (and its per-service packages like `mypy-boto3-mediaconvert`) is the actively maintained and recommended solution. For broad coverage and easier management of `session.client`/`resource` overloads, using `boto3-stubs[service_name]` is often preferred.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}