mypy-boto3-migrationhuborchestrator Type Annotations
mypy-boto3-migrationhuborchestrator provides type annotations for the `boto3` AWS Migration Hub Orchestrator service, enhancing static analysis and IDE autocompletion for Python projects. It is generated by the `mypy-boto3-builder` and is currently at version 1.42.3, with releases closely tracking `boto3` updates to ensure compatibility and comprehensive type coverage.
Warnings
- breaking Starting with `mypy-boto3-builder` version 8.12.0 (which generated this package), Python 3.8 is no longer supported for generated stub packages.
- breaking In `mypy-boto3-builder` version 8.9.0, type definition (TypeDef) naming conventions changed. This includes shorter names for packed method arguments and revised postfix handling for conflicting `TypeDef` names (e.g., `CreateDistributionExtraRequestTypeDef` became `CreateDistributionRequestExtraTypeDef`).
- gotcha Type imports from `mypy_boto3_*` packages should ideally be placed within `if TYPE_CHECKING:` blocks. This ensures that these stub packages are only used by static analysis tools (like mypy) and are not treated as runtime dependencies by your application, reducing the deployed package size.
- gotcha Following the migration to PEP 561 packages in `mypy-boto3-builder` 8.12.0, ensure your `mypy` or other type checker is up-to-date. Older versions might not correctly discover or utilize the stubs, leading to `Missing type stub` errors or incorrect type inference.
Install
-
pip install mypy-boto3-migrationhuborchestrator -
pip install 'boto3-stubs[migrationhuborchestrator]'
Imports
- MigrationHubOrchestratorClient
from typing import TYPE_CHECKING if TYPE_CHECKING: from mypy_boto3_migrationhuborchestrator import MigrationHubOrchestratorClient - TemplateSummaryTypeDef
from typing import TYPE_CHECKING if TYPE_CHECKING: from mypy_boto3_migrationhuborchestrator.type_defs import TemplateSummaryTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
# Best practice: guard type imports with if TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_migrationhuborchestrator import MigrationHubOrchestratorClient
from mypy_boto3_migrationhuborchestrator.type_defs import TemplateSummaryTypeDef
# Initialize a boto3 client for Migration Hub Orchestrator
client: MigrationHubOrchestratorClient = boto3.client('migrationhuborchestrator')
# Use a method and check its return type
try:
response = client.list_templates(maxResults=5)
templates: list[TemplateSummaryTypeDef] = response['Templates']
for template in templates:
print(f"Template ID: {template['Id']}, Name: {template['Name']}")
except client.exceptions.AccessDeniedException:
print("Access denied. Please check your AWS credentials and permissions.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
# To run mypy:
# 1. pip install mypy boto3 mypy-boto3-migrationhuborchestrator
# 2. mypy your_script_name.py