Type annotations for boto3 CodeDeploy

1.42.3 · active · verified Sat Apr 11

mypy-boto3-codedeploy provides comprehensive type annotations for the boto3 CodeDeploy service, enhancing development with static type checking, auto-completion, and improved error detection. This package is currently at version 1.42.3 and is actively maintained with frequent updates to align with boto3 releases and the underlying mypy-boto3-builder (version 8.12.0).

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to get a type-hinted CodeDeploy client and use it to list applications. It includes explicit type annotations for `CodeDeployClient` and a response `TypeDef` to leverage the type stubs effectively.

import boto3
from typing import TYPE_CHECKING
from os import environ

if TYPE_CHECKING:
    from mypy_boto3_codedeploy.client import CodeDeployClient
    from mypy_boto3_codedeploy.type_defs import ListApplicationsOutputTypeDef

def get_codedeploy_client() -> CodeDeployClient:
    """Returns a type-hinted CodeDeploy client."""
    session = boto3.session.Session(
        aws_access_key_id=environ.get('AWS_ACCESS_KEY_ID', ''),
        aws_secret_access_key=environ.get('AWS_SECRET_ACCESS_KEY', ''),
        aws_session_token=environ.get('AWS_SESSION_TOKEN', ''),
        region_name=environ.get('AWS_REGION', 'us-east-1')
    )
    return session.client("codedeploy")

def list_codedeploy_applications():
    client: CodeDeployClient = get_codedeploy_client()
    response: ListApplicationsOutputTypeDef = client.list_applications()
    print("CodeDeploy Applications:")
    for app_name in response.get("applications", []):
        print(f"- {app_name}")

if __name__ == "__main__":
    list_codedeploy_applications()

view raw JSON →