Install & Compatibility
Where this runs
tested against v1.43.38 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.666s · 52.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.0s · import 0.618s · 53MB
51MB installed
● package 51MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CodeBuildClient
✓ from mypy_boto3_codebuild.client import CodeBuildClient
ProjectTypeDef
✓ from mypy_boto3_codebuild.type_defs import ProjectTypeDef
Import specific TypedDicts for detailed type annotations of service responses/parameters.
This quickstart demonstrates how to initialize a `boto3` CodeBuild client with type hints from `mypy-boto3-codebuild` and perform basic operations like listing projects and retrieving project details. It includes error handling for common `boto3` authentication issues, expecting AWS credentials to be configured via standard `boto3` mechanisms (environment variables, config files, IAM roles).
import boto3
from mypy_boto3_codebuild.client import CodeBuildClient
from typing import TYPE_CHECKING
import os
from botocore.exceptions import ClientError
# Dummy variables to satisfy the instruction, though boto3 typically
# reads these implicitly if set in the environment (e.g., AWS_ACCESS_KEY_ID).
# Setting them to empty strings ensures the example runs without immediately
# failing if actual env vars are missing, but the boto3 client will still
# attempt to find valid credentials via its standard chain.
access_key_id = os.environ.get('AWS_ACCESS_KEY_ID', '')
secret_access_key = os.environ.get('AWS_SECRET_ACCESS_KEY', '')
session_token = os.environ.get('AWS_SESSION_TOKEN', '')
if TYPE_CHECKING:
# These imports are only for type checking and will not be used at runtime
from mypy_boto3_codebuild.type_defs import ProjectTypeDef
try:
# Initialize a CodeBuild client with type hints.
# Boto3 will automatically use credentials from environment variables,
# shared config, or IAM roles.
# If explicit credentials were desired, one might do:
# client: CodeBuildClient = boto3.client(
# "codebuild",
# aws_access_key_id=access_key_id,
# aws_secret_access_key=secret_access_key,
# aws_session_token=session_token
# )
# But for a quickstart, implicit loading is more common and robust.
client: CodeBuildClient = boto3.client("codebuild")
# Example: List CodeBuild projects
print("Listing CodeBuild projects:")
response = client.list_projects()
projects: list[str] = response["projects"]
for project_name in projects:
print(f"- {project_name}")
# Example: Get details for a specific project (if any exist)
if projects:
project_name = projects[0]
print(f"\nGetting details for project: {project_name}")
project_details_response = client.batch_get_projects(names=[project_name])
if project_details_response and project_details_response["projects"]:
project: ProjectTypeDef = project_details_response["projects"][0]
print(f" Project ARN: {project.get('arn')}")
print(f" Project Status: {project.get('build', {}).get('status')}")
else:
print("\nNo CodeBuild projects found to display details.")
except ClientError as e:
error_code = e.response.get("Error", {}).get("Code")
if error_code in ["UnrecognizedClientException", "InvalidClientTokenId", "ExpiredToken", "NoCredentialsError"]: # Added NoCredentialsError for common boto3 errors
print(f"Authentication failed. Please ensure AWS credentials (e.g., via environment variables "
f"AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) are configured correctly. Error: {e}")
else:
print(f"An AWS client error occurred: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingPython 3.8 support has been removed. Projects using `mypy-boto3-codebuild` or other `mypy-boto3` family stubs must upgrade to Python 3.9 or newer.fixUpgrade your Python environment to 3.9 or higher.
affects: Versions generated by `mypy-boto3-builder` 8.12.0 and later.
breakingTypeDef naming conventions were changed, potentially affecting code that directly imports and references specific TypedDicts. For example, `CreateDistributionRequestRequestTypeDef` might become `CreateDistributionRequestTypeDef`.fixReview your explicit `from mypy_boto3_codebuild.type_defs import ...` statements and adjust TypedDict names according to the latest package structure.
affects: Versions generated by `mypy-boto3-builder` 8.9.0 and later.
gotchaThese type stubs are for static analysis by tools like MyPy and do not alter the runtime behavior of `boto3`. Incorrectly configured MyPy or expecting runtime changes based on stub updates can lead to confusion.fixEnsure `mypy` is installed and configured to check your project. Remember that stubs only provide compile-time benefits, not runtime functionality.
affects: All versions
gotchaAWS service names can change or be deprecated (e.g., `sms-voice` replaced by `pinpoint-sms-voice` in `mypy-boto3-builder` 8.11.0). This can lead to `ModuleNotFoundError` or incorrect type hints if the underlying `boto3` service name changes and the stubs are not updated accordingly.fixStay up-to-date with `mypy-boto3-builder` releases and `boto3` documentation for service name changes. If a service is renamed, update your `mypy-boto3-*` package import accordingly.
affects: All versions, as service names can evolve.
gotchaWhen using `boto3.resource` or `boto3.client`, make sure the `service_name` string argument is correctly spelled and matches the stub package. A typo will bypass type checking for that client/resource.fixAlways use string literals for `service_name` (e.g., `boto3.client("codebuild")`) and ensure they match the service you intend to type-check. IDEs with LSP support often highlight mismatches if stubs are correctly installed. affects: All versions
Upgrade
Version history
1.43.38latest on PyPI · released Jun 30, 2026
Audit
Dependencies
boto3requiredRuntime dependency for AWS SDK operations.