mypy-boto3-migration-hub-refactor-spaces Type Stubs
This package provides type annotations for the `boto3` AWS Migration Hub Refactor Spaces service (version 1.42.3), generated by the `mypy-boto3-builder`. It enables static type checking with tools like `mypy` and enhances autocompletion and error detection in IDEs for `boto3` users. The library is actively maintained, with updates typically mirroring `boto3` releases and the `mypy-boto3-builder`'s development cadence.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 or older will need to upgrade their Python version.
- breaking The `mypy-boto3-builder` (version 8.12.0) migrated to PEP 561 compliant packages. While this is largely an internal change, it ensures better compatibility and discovery by type checkers. Older, non-compliant configurations might require updates.
- gotcha This package provides *only* type annotations. You must install `boto3` separately (e.g., `pip install boto3`) for your code to run at runtime. Without `boto3`, type checking will work, but runtime execution will fail.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` version 8.9.0. TypeDefs for packed arguments use shorter names, and conflicting `Extra` postfixes were moved. If you directly import specific TypeDefs, their names might have changed.
- gotcha While `mypy-boto3` stubs enable auto-discovery for `boto3.client()` calls, explicit type annotations for the client variable (e.g., `client: MigrationHubRefactorSpacesClient = boto3.client(...)`) are highly recommended for optimal IDE autocompletion and more robust type checking, especially in VSCode and PyCharm.
Install
-
pip install mypy-boto3-migration-hub-refactor-spaces boto3 mypy
Imports
- MigrationHubRefactorSpacesClient
from mypy_boto3_migration_hub_refactor_spaces.client import MigrationHubRefactorSpacesClient
- ListEnvironmentsOutputTypeDef
from mypy_boto3_migration_hub_refactor_spaces.type_defs import ListEnvironmentsOutputTypeDef
- EnvironmentStatusType
from mypy_boto3_migration_hub_refactor_spaces.literals import EnvironmentStatusType
Quickstart
import boto3
from mypy_boto3_migration_hub_refactor_spaces.client import MigrationHubRefactorSpacesClient
from mypy_boto3_migration_hub_refactor_spaces.type_defs import ListEnvironmentsOutputTypeDef
from mypy_boto3_migration_hub_refactor_spaces.literals import EnvironmentStatusType
def get_typed_client() -> MigrationHubRefactorSpacesClient:
"""Returns a type-annotated Migration Hub Refactor Spaces client."""
# boto3 is the actual runtime library, mypy-boto3-migration-hub-refactor-spaces provides type hints
client: MigrationHubRefactorSpacesClient = boto3.client("migration-hub-refactor-spaces")
return client
if __name__ == "__main__":
refactor_client = get_typed_client()
try:
# Example: List environments with type-checked response
environments: ListEnvironmentsOutputTypeDef = refactor_client.list_environments(
# Add optional filters for type-checking
MaxResults=100
)
print(f"Found {len(environments.get('EnvironmentSummaryList', []))} environments.")
# Example of using a literal for a parameter
# This is a placeholder as list_environments doesn't have a status filter directly
# if environments.get('EnvironmentSummaryList'):
# first_env = environments['EnvironmentSummaryList'][0]
# if first_env.get('Status') == EnvironmentStatusType.ACTIVE:
# print(f"First environment '{first_env.get('Name')}' is active.")
except refactor_client.exceptions.ResourceNotFoundException:
print("No Refactor Spaces environments found.")
except Exception as e:
print(f"An unexpected error occurred: {e}")