mypy-boto3-codestar-connections
mypy-boto3-codestar-connections provides type annotations for the boto3 CodeStar Connections service. It is part of the mypy-boto3 project, which generates a full set of type stubs for boto3 services to enhance static analysis with tools like Mypy. The project releases frequently, keeping pace with boto3 updates and Python ecosystem changes, and is currently at version 1.42.3.
Warnings
- breaking Python 3.8 support was removed in `mypy-boto3-builder` 8.12.0 (and subsequently generated stub packages like this one). The `mypy-boto3-codestar-connections` library now requires Python 3.9 or newer.
- gotcha `mypy-boto3-codestar-connections` provides *type stubs only*. You must install the `boto3` library separately for runtime functionality. For example: `pip install boto3 mypy-boto3-codestar-connections`.
- gotcha To ensure accurate type checking, keep your `mypy-boto3-codestar-connections` version in sync with your `boto3` version. Significant version mismatches can lead to incorrect or missing type hints.
- breaking As of `mypy-boto3-builder` 8.12.0, all generated stub packages (including this one) migrated to be proper PEP 561 packages. While generally an improvement, this might affect how `mypy` locates stubs in complex project configurations or non-standard `MYPYPATH` setups.
Install
-
pip install mypy-boto3-codestar-connections boto3
Imports
- CodeStarConnectionsClient
from mypy_boto3_codestar_connections.client import CodeStarConnectionsClient
- ConnectionTypeDef
from mypy_boto3_codestar_connections.type_defs import ConnectionTypeDef
Quickstart
import boto3
from mypy_boto3_codestar_connections.client import CodeStarConnectionsClient
from typing import TYPE_CHECKING
import os
# Ensure boto3 is installed: pip install boto3 mypy-boto3-codestar-connections
# Provide dummy AWS credentials for the quickstart to pass basic boto3 checks.
# In a real application, boto3 will pick up credentials from env vars,
# ~/.aws/credentials, or IAM roles.
# These are placeholder values and will likely result in an 'InvalidClientTokenId'
# or 'AccessDenied' error if used without proper configuration.
# It's intended to demonstrate type-checking and basic client interaction.
os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY_ID')
os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET_ACCESS_KEY')
os.environ['AWS_DEFAULT_REGION'] = os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
# Use TYPE_CHECKING for type hints that are only relevant for static analysis
if TYPE_CHECKING:
client: CodeStarConnectionsClient = boto3.client("codestar-connections")
else:
client = boto3.client("codestar-connections")
try:
# Example: List up to 1 CodeStar Connections
print("Attempting to list CodeStar Connections...")
response = client.list_connections(MaxResults=1)
print("Successfully listed CodeStar Connections (if configured and permissions allow):")
for conn in response.get("Connections", []):
print(f" Connection ARN: {conn.get('ConnectionArn')}")
except client.exceptions.CodeStarConnectionsException as e:
print(f"AWS CodeStar Connections error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")