Type annotations for boto3 CodeDeploy
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
- breaking Python 3.8 support was removed starting with `mypy-boto3-builder` version 8.12.0 and affects all generated `mypy-boto3-*` packages, including `mypy-boto3-codedeploy`.
- breaking In `mypy-boto3-builder` version 8.9.0, there were breaking changes to TypeDef naming conventions. Specifically, `TypeDefs` for packed method arguments use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`).
- deprecated The standalone `mypy-boto3` package (e.g., `pip install mypy-boto3`) is considered legacy. Users are encouraged to install service-specific packages like `mypy-boto3-codedeploy` directly, or use the `boto3-stubs` package with service-specific extras (`pip install 'boto3-stubs[codedeploy]'`).
- gotcha When using PyCharm, performance issues with `Literal` overloads have been reported (PY-40997). This can lead to slow IDE performance when using full `boto3-stubs` packages.
Install
-
pip install mypy-boto3-codedeploy -
pip install 'boto3-stubs[codedeploy]' # Requires boto3-stubs>=8.9.0
Imports
- CodeDeployClient
from mypy_boto3_codedeploy.client import CodeDeployClient
- DeploymentInfoTypeDef
from mypy_boto3_codedeploy.type_defs import DeploymentInfoTypeDef
Quickstart
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()