{"id":3115,"library":"mypy-boto3-mgh","title":"Type annotations for boto3 MigrationHub","description":"mypy-boto3-mgh provides type annotations for the boto3 MigrationHub service, enhancing static type checking for AWS SDK usage in Python. It is currently at version 1.42.3 and follows the release cadence of `mypy-boto3-builder`, which often aligns with `boto3` releases or significant internal changes, leading to frequent updates across many stub packages.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","mypy","type-hints","aws","migrationhub"],"install":[{"cmd":"pip install mypy-boto3-mgh","lang":"bash","label":"Install service stub"},{"cmd":"pip install boto3","lang":"bash","label":"Install boto3 runtime (required)"},{"cmd":"pip install mypy","lang":"bash","label":"Install Mypy (optional, for type checking)"}],"dependencies":[{"reason":"Runtime dependency for AWS SDK functionality. The stub package provides type hints for this library.","package":"boto3","optional":false},{"reason":"Development dependency for static type checking. Other type checkers like pyright can also be used.","package":"mypy","optional":true},{"reason":"Requires Python 3.9 or newer.","package":"python","optional":false}],"imports":[{"note":"Client types are located in the '.client' submodule for direct import.","wrong":"from mypy_boto3_mgh import MigrationHubClient","symbol":"MigrationHubClient","correct":"from mypy_boto3_mgh.client import MigrationHubClient"},{"note":"Literal types for service names are useful for precise overloading.","symbol":"MigrationHubServiceName","correct":"from mypy_boto3_mgh.literals import MigrationHubServiceName"}],"quickstart":{"code":"import os\nimport boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_mgh.client import MigrationHubClient\n\ndef get_migrationhub_client() -> \"MigrationHubClient\":\n    \"\"\"\n    Retrieves a typed boto3 MigrationHub client.\n    \"\"\"\n    # boto3 automatically picks up credentials from environment variables,\n    # shared credential files, or IAM roles.\n    # For a quickstart, we assume credentials are set up.\n    session = boto3.Session(region_name=os.environ.get(\"AWS_REGION\", \"us-east-1\"))\n    client: \"MigrationHubClient\" = session.client(\"migrationhub\")\n    \n    return client\n\nif __name__ == \"__main__\":\n    # This example requires AWS credentials configured in your environment\n    # (e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)\n    # or via ~/.aws/credentials.\n    \n    # Try to get a client\n    mgh_client = get_migrationhub_client()\n    print(f\"Successfully obtained MigrationHub client: {mgh_client}\")\n    \n    # You can now use mgh_client with full type hints, e.g.:\n    # response = mgh_client.list_application_states()\n    # print(response)\n","lang":"python","description":"This quickstart demonstrates how to obtain a type-hinted MigrationHub client using `boto3` and `mypy-boto3-mgh`. The `TYPE_CHECKING` block is a common pattern to avoid importing stubs in production environments."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Beginning with `mypy-boto3-builder` version 8.12.0 (and consequently all generated stub packages, including `mypy-boto3-mgh` 1.42.3), Python 3.8 is no longer supported. Projects targeting Python 3.8 will fail to type-check or even install these stubs.","severity":"breaking","affected_versions":">=8.12.0 of `mypy-boto3-builder` (corresponds to `mypy-boto3-mgh` versions generated by it, e.g., 1.42.3)"},{"fix":"Update your code to use the new TypeDef names. Refer to the specific service module's documentation for exact naming, or rely on IDE auto-completion.","message":"The `mypy-boto3-builder` (from version 8.9.0) introduced breaking changes to TypeDef naming conventions. Argument TypeDefs now use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes are moved to the end (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). This affects all generated service stubs.","severity":"breaking","affected_versions":">=8.9.0 of `mypy-boto3-builder` (corresponds to `mypy-boto3-mgh` versions generated by it, including 1.42.3)"},{"fix":"Explicitly annotate the return type of `boto3.client('service')` calls, e.g., `client: MigrationHubClient = boto3.client('migrationhub')`. If using PyCharm and experiencing performance issues, consider `mypy-boto3-lite` or check for IDE updates.","message":"While `mypy-boto3` aims for automatic type discovery, some IDEs (like VSCode) may require explicit type annotations for `boto3.client()`, `session.client()`, `.get_waiter()`, and `.get_paginator()` calls to provide full auto-completion and type checking. PyCharm users are sometimes recommended to use `mypy-boto3-lite` to avoid performance issues with `Literal` overloads.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}