{"id":2608,"library":"mypy-boto3-sagemaker","title":"Type annotations for boto3 SageMaker","description":"mypy-boto3-sagemaker provides type annotations for the boto3 SageMaker service. These stubs are generated with mypy-boto3-builder to offer type checking and IDE auto-completion for your boto3 SageMaker clients. The library is actively maintained with frequent releases, currently at version 1.42.88, ensuring compatibility with the latest boto3 versions and Python type-hinting standards.","status":"active","version":"1.42.88","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["AWS","boto3","mypy","type-hinting","SageMaker","stubs","typing"],"install":[{"cmd":"pip install mypy-boto3-sagemaker","lang":"bash","label":"Install standalone SageMaker stubs"},{"cmd":"pip install 'boto3-stubs[sagemaker]'","lang":"bash","label":"Install SageMaker stubs via boto3-stubs extras"}],"dependencies":[{"reason":"This package provides type annotations for the 'boto3' library; 'boto3' itself is required for runtime AWS interaction.","package":"boto3"}],"imports":[{"symbol":"SageMakerClient","correct":"from mypy_boto3_sagemaker.client import SageMakerClient"},{"note":"While 'from mypy_boto3_sagemaker.client import SagemakerClient' technically works, the top-level import is idiomatic and often sufficient for the primary client type.","wrong":"from mypy_boto3_sagemaker.client import SagemakerClient","symbol":"SagemakerClient","correct":"from mypy_boto3_sagemaker import SagemakerClient"}],"quickstart":{"code":"import boto3\nfrom boto3.session import Session\nfrom mypy_boto3_sagemaker.client import SagemakerClient\n\ndef get_sagemaker_client() -> SagemakerClient:\n    # boto3 automatically picks up credentials from environment variables or AWS config.\n    # For local testing without actual AWS calls, ensure 'boto3' is configured.\n    session = Session()\n    client: SagemakerClient = session.client(\"sagemaker\")\n    return client\n\n# Example usage (will only run if AWS credentials are set up)\nif __name__ == \"__main__\":\n    try:\n        sagemaker_client = get_sagemaker_client()\n        # Access type-hinted methods, e.g., sagemaker_client.list_training_jobs()\n        print(f\"Successfully created SageMaker client: {sagemaker_client.meta.region_name}\")\n        # Uncomment below to make an actual API call (requires permissions)\n        # response = sagemaker_client.list_training_jobs(MaxResults=1)\n        # print(f\"Training jobs: {response.get('TrainingJobSummaries')}\")\n    except Exception as e:\n        print(f\"Error creating SageMaker client or making call: {e}\")","lang":"python","description":"This quickstart demonstrates how to instantiate a type-hinted SageMaker client using `boto3` and `mypy-boto3-sagemaker`. The `SageMakerClient` type provides comprehensive type checking and auto-completion for all available SageMaker API operations and their parameters."},"warnings":[{"fix":"Ensure your project uses Python 3.9 or higher. For older Python versions, use an older `mypy-boto3-sagemaker` release compatible with Python 3.8 (e.g., from `mypy-boto3-builder < 8.12.0`).","message":"Starting with `mypy-boto3-builder` version 8.12.0 (which generates these stubs), Python 3.8 support has been removed across all packages. Additionally, packages migrated to follow PEP 561 distribution standards.","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.12.0 (generating mypy-boto3-sagemaker >= 1.42.88)"},{"fix":"Review and update explicit `TypeDef` imports and usage if you were relying on the older naming conventions. Refer to the specific service module's `type_defs` for the updated names.","message":"Breaking changes in TypeDef naming conventions were introduced in `mypy-boto3-builder` 8.9.0. This includes shorter names for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`) and moving `Extra` postfixes in conflicting TypeDefs (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`).","severity":"breaking","affected_versions":"mypy-boto3-builder >= 8.9.0 (generating mypy-boto3-sagemaker >= 1.42.88)"},{"fix":"To fix this, explicitly set types to `object` in the `else` branch of the `TYPE_CHECKING` block. Example: `if TYPE_CHECKING: from mypy_boto3_sagemaker.client import SagemakerClient else: SagemakerClient = object`.","message":"Pylint may issue `undefined-variable` warnings when using `TYPE_CHECKING` blocks to conditionally import `mypy-boto3-*` types. This is a known issue with Pylint's handling of `TYPE_CHECKING`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If experiencing performance issues in PyCharm, consider installing the 'lite' version of `boto3-stubs` (e.g., `pip install boto3-stubs-lite[sagemaker]`) which provides type annotations without session.client/resource overloads but requires more explicit type annotations.","message":"PyCharm users might experience slow performance with Literal overloads in `boto3-stubs`. This is a known IDE issue (PY-40997).","severity":"gotcha","affected_versions":"All versions, specific to PyCharm IDE"},{"fix":"If you were using stubs for `sms-voice`, switch to using stubs for `pinpoint-sms-voice` instead.","message":"The `sms-voice` service was deprecated and removed from `mypy-boto3-builder` in version 8.11.0. Users of this service should migrate to `pinpoint-sms-voice`.","severity":"deprecated","affected_versions":"mypy-boto3-builder >= 8.11.0"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}