{"id":1573,"library":"mypy-boto3-lambda","title":"mypy-boto3-lambda Type Annotations","description":"mypy-boto3-lambda provides type annotations for the AWS Lambda client in `boto3`, generated by `mypy-boto3-builder`. It enhances type checking for `boto3` usage, preventing common runtime errors related to incorrect AWS service calls or response parsing. The library version `1.42.85` corresponds to `boto3` version `1.42.85`. New versions are released frequently, typically mirroring `boto3` releases.","status":"active","version":"1.42.85","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["mypy","boto3","aws","lambda","types","stubs","typing","type-hints"],"install":[{"cmd":"pip install mypy-boto3-lambda boto3","lang":"bash","label":"Install stubs and boto3"}],"dependencies":[{"reason":"This package provides type stubs for `boto3`. `boto3` itself must be installed to use the Lambda client functionality at runtime.","package":"boto3","optional":false}],"imports":[{"note":"Used for explicit type hinting of the Lambda client object.","symbol":"LambdaClient","correct":"from mypy_boto3_lambda.client import LambdaClient"},{"note":"Used for explicit type hinting of method response objects.","symbol":"ListFunctionsResponseTypeDef","correct":"from mypy_boto3_lambda.type_defs import ListFunctionsResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_lambda.client import LambdaClient\nfrom mypy_boto3_lambda.type_defs import ListFunctionsResponseTypeDef\n\n# Create a typed Lambda client\n# mypy will automatically use the installed mypy-boto3-lambda stubs for type checking\nlambda_client: LambdaClient = boto3.client(\"lambda\")\n\ntry:\n    # Example: List Lambda functions\n    # The response object will be correctly typed\n    response: ListFunctionsResponseTypeDef = lambda_client.list_functions(MaxItems=1)\n    print(\"Successfully listed Lambda functions (first item): \")\n    for func in response.get(\"Functions\", []):\n        print(f\"- {func['FunctionName']}\")\nexcept Exception as e:\n    # This may happen if AWS credentials are not configured or if the user lacks permissions.\n    print(f\"Error listing Lambda functions: {e}\")\n    print(\"Ensure your AWS credentials are configured (e.g., via AWS CLI or environment variables).\")","lang":"python","description":"This example demonstrates how to create a type-hinted `boto3` Lambda client. `mypy` will automatically pick up the installed stubs when `boto3.client('lambda')` is called, providing autocompletion and type validation. Explicit imports for `LambdaClient` and response `TypeDef` are used for clearer annotations."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. If you must use Python 3.8, you'll need to pin to older `mypy-boto3-lambda` versions, though this is not recommended due to potential `boto3` mismatches.","message":"Support for Python 3.8 was removed. Packages generated by `mypy-boto3-builder` v8.12.0 and later (which includes `mypy-boto3-lambda` v1.42.85) require Python 3.9 or higher.","severity":"breaking","affected_versions":"Packages generated by `mypy-boto3-builder` v8.12.0+"},{"fix":"Update your code to use `boto3.client(\"pinpoint-sms-voice\")` instead of `boto3.client(\"sms-voice\")`.","message":"The `sms-voice` service was deprecated and renamed to `pinpoint-sms-voice`. Direct usage of the `sms-voice` client will fail.","severity":"breaking","affected_versions":"Packages generated by `mypy-boto3-builder` v8.11.0+"},{"fix":"Review and update explicit TypeDef annotations in your code to match the new naming conventions, or rely on implicit typing where possible and let `mypy` infer the correct types.","message":"TypeDef names for packed method arguments changed, becoming shorter (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`). Conflicting TypeDef `Extra` postfixes also moved.","severity":"breaking","affected_versions":"Packages generated by `mypy-boto3-builder` v8.9.0+"},{"fix":"Ensure `boto3` is included in your project's dependencies: `pip install boto3 mypy-boto3-lambda`.","message":"This package provides only type stubs. It is not the `boto3` library itself. You must install `boto3` separately for your code to function at runtime.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always try to keep your `mypy-boto3-*` stub versions as close as possible to your `boto3` version. The recommended approach is to install the latest versions of both.","message":"The `mypy-boto3-*` stub packages are versioned to align with specific `boto3` versions. Using mismatched versions (e.g., `mypy-boto3-lambda` 1.42.85 with `boto3` 1.20.0) can lead to incorrect type hints or `mypy` errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}