mypy-boto3-m2 Type Stubs for AWS Mainframe Modernization
mypy-boto3-m2 provides type annotations for the AWS Mainframe Modernization (M2) service within the boto3 library. These stubs enable static type checking for M2 clients and resources, enhancing developer productivity and catching type-related errors early. The current version is 1.42.3, generated by the mypy-boto3-builder, which maintains a regular release cadence to keep pace with boto3 updates.
Warnings
- breaking Python 3.8 support was removed from mypy-boto3-builder (version 8.12.0) and consequently from all generated stub packages, including mypy-boto3-m2 1.42.3 and newer.
- breaking The `mypy-boto3-builder` migrated to PEP 561 packaging (implicit namespace packages) starting with version 8.12.0. This change affects how type checkers discover and load stubs.
- gotcha These packages provide only type stubs. You must install the actual `boto3` library for your code to run at runtime.
- gotcha Each `mypy-boto3-<service_name>` package provides stubs only for its specific AWS service. If you use multiple AWS services, you need to install stubs for each of them.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0 to resolve conflicts and shorten names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`). If you explicitly import TypeDefs, their names might have changed.
Install
-
pip install boto3 mypy-boto3-m2
Imports
- MainframeModernizationClient
from mypy_boto3_m2.client import MainframeModernizationClient
- CreateEnvironmentInputRequestTypeDef
from mypy_boto3_m2.type_defs import CreateEnvironmentInputRequestTypeDef
Quickstart
import boto3
from mypy_boto3_m2.client import MainframeModernizationClient
# Note: In a real application, consider using AWS STS or environment variables for credentials.
# For a quickstart example, boto3 uses default credential chain (env vars, ~/.aws/credentials, etc.)
# Get a typed M2 client
m2_client: MainframeModernizationClient = boto3.client("m2", region_name="us-east-1")
try:
# Example: List environments (replace with an actual M2 operation you'd perform)
response = m2_client.list_environments(
maxResults=10
)
print(f"Successfully listed {len(response.get('environments', []))} M2 environments.")
# Type checkers will validate arguments and response structure due to stubs
except Exception as e:
print(f"Error listing M2 environments: {e}")