{"id":6280,"library":"types-aiobotocore-sts","title":"Type Annotations for aiobotocore STS","description":"This library provides type annotations for the `aiobotocore` STS (Security Token Service) client, currently at version 3.4.0. Generated by `mypy-boto3-builder 8.12.0`, it enables static type checking with tools like MyPy and PyRight, and offers enhanced IDE auto-completion for `aiobotocore`'s asynchronous AWS client, covering STS client methods, literals, and type definitions.","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["type-hints","aws","aiobotocore","sts","async","mypy","pyright","stubs"],"install":[{"cmd":"pip install types-aiobotocore-sts","lang":"bash","label":"Install specific STS types"},{"cmd":"pip install 'types-aiobotocore[sts]'","lang":"bash","label":"Install STS types as part of the main types-aiobotocore package"}],"dependencies":[{"reason":"This package provides type hints for aiobotocore. It is required at runtime for the code to function, though not a direct installation dependency of types-aiobotocore-sts itself (which is 'stubs only').","package":"aiobotocore","optional":true}],"imports":[{"symbol":"STSClient","correct":"from types_aiobotocore_sts.client import STSClient"},{"symbol":"STSServiceName","correct":"from types_aiobotocore_sts.literals import STSServiceName"},{"note":"Example for a specific TypedDict. Other TypeDefs are available in `type_defs`.","symbol":"AssumeRoleResponseTypeDef","correct":"from types_aiobotocore_sts.type_defs import AssumeRoleResponseTypeDef"}],"quickstart":{"code":"import asyncio\nfrom typing import TYPE_CHECKING\n\nfrom aiobotocore.session import get_session\n\n# Recommended: Import types only for type checking\nif TYPE_CHECKING:\n    from types_aiobotocore_sts.client import STSClient\n    from types_aiobotocore_sts.type_defs import GetCallerIdentityResponseTypeDef\n\nasync def get_aws_caller_identity():\n    session = get_session()\n    async with session.create_client(\"sts\") as client:\n        # Explicit type annotation for client for best IDE support\n        if TYPE_CHECKING:\n            client: STSClient\n\n        print(\"Getting caller identity...\")\n        response: GetCallerIdentityResponseTypeDef = await client.get_caller_identity()\n        print(f\"AWS Account: {response.get('Account')}\")\n        print(f\"AWS User ARN: {response.get('Arn')}\")\n\nif __name__ == \"__main__\":\n    # This example requires valid AWS credentials configured (e.g., via environment variables or ~/.aws/credentials)\n    # It does not explicitly use os.environ.get for credentials, assuming aiobotocore handles it.\n    asyncio.run(get_aws_caller_identity())","lang":"python","description":"This example demonstrates how to use `types-aiobotocore-sts` to add static type checking to your `aiobotocore` STS client. The `STSClient` and `GetCallerIdentityResponseTypeDef` are imported under `TYPE_CHECKING` to ensure they are only used during type analysis, avoiding a runtime dependency if desired. When running, `aiobotocore` will automatically pick up AWS credentials from standard locations (environment variables, `~/.aws/credentials`)."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Support for Python 3.8 was removed starting with `mypy-boto3-builder 8.12.0` (which generated `types-aiobotocore-sts 3.4.0`). Projects using Python 3.8 will need to upgrade to Python 3.9 or later.","severity":"breaking","affected_versions":">=3.4.0 (generated by mypy-boto3-builder >=8.12.0)"},{"fix":"Ensure `aiobotocore` is installed alongside `types-aiobotocore-sts` (e.g., `pip install aiobotocore types-aiobotocore-sts`).","message":"`types-aiobotocore-sts` is a 'stubs only' package. It provides type annotations but does not install `aiobotocore` itself or any other runtime dependencies. Your project must explicitly install `aiobotocore` (e.g., `pip install aiobotocore`) for the code to run.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Keep `types-aiobotocore-sts` and `aiobotocore` versions synchronized, or use the `types-aiobotocore` umbrella package with service extras to manage compatibility (e.g., `pip install 'types-aiobotocore[sts]'`).","message":"For optimal type checking, the version of `types-aiobotocore-sts` should ideally match or be compatible with your installed `aiobotocore` version. Mismatched versions might lead to incorrect or missing type hints, especially after significant AWS API changes.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement the `if TYPE_CHECKING: ... else: var = object` pattern to satisfy Pylint, as shown in the package's documentation.","message":"When using `Pylint` with type annotations imported under `typing.TYPE_CHECKING`, Pylint might report 'undefined variables'. The recommended workaround is to explicitly set the type-hinted variables to `object` in the `else` branch of the `TYPE_CHECKING` block.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}