mypy-boto3-mgn
mypy-boto3-mgn provides type annotations for the AWS Migration Hub rehost service (MGN) within `boto3`. It enhances development with static type checking for clients, paginators, waiters, literals, and type definitions, compatible with tools like mypy, pyright, VSCode, and PyCharm. The package is automatically generated by `mypy-boto3-builder` and is frequently updated to align with `boto3` releases.
Warnings
- breaking Python 3.8 support has been removed in `mypy-boto3-builder` version 8.12.0 and later. Projects using `mypy-boto3-mgn` now require Python 3.9 or higher.
- breaking Breaking changes to `TypeDef` naming conventions occurred in `mypy-boto3-builder` version 8.9.0. Some TypeDefs for method arguments or conflicting names might have been shortened or had postfixes rearranged (e.g., `*RequestRequestTypeDef` to `*RequestTypeDef`).
- gotcha PyCharm users may experience slow performance or high CPU usage due to `Literal` overloads. This is a known upstream issue (PY-40997).
- gotcha For production deployments, `mypy-boto3-mgn` should typically be a development-only dependency. To prevent runtime import errors or `pylint` complaints about undefined variables, use `if TYPE_CHECKING:` blocks.
Install
-
pip install mypy-boto3-mgn -
pip install 'boto3-stubs[mgn]'
Imports
- MgnClient
from mypy_boto3_mgn import MgnClient
- ListWavesResponseTypeDef
from mypy_boto3_mgn.type_defs import ListWavesResponseTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_mgn import MgnClient
from mypy_boto3_mgn.type_defs import ListWavesResponseTypeDef
# Instantiate the boto3 client with type hinting
client: MgnClient = boto3.client("mgn")
try:
# Example API call with typed response
response: ListWavesResponseTypeDef = client.list_waves(
maxResults=10
)
print("Successfully listed waves:")
for wave in response.get("items", []):
print(f" - Wave ID: {wave.get('waveID')}, Name: {wave.get('name')}")
except client.exceptions.ResourceNotFoundException:
print("No waves found or region misconfigured.")
except Exception as e:
print(f"An error occurred: {e}")