mypy-boto3-cognito-idp

1.42.59 · active · verified Fri Apr 10

mypy-boto3-cognito-idp provides comprehensive type annotations for the `boto3` library's Cognito Identity Provider service. It enables static type checking with tools like mypy and pyright, offering enhanced auto-completion and early error detection in IDEs for `boto3` calls related to Cognito IDP. The library, currently at version 1.42.59, is auto-generated by `mypy-boto3-builder` and frequently updated to synchronize with `boto3` releases, ensuring up-to-date and accurate type definitions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to obtain a type-hinted `CognitoIdentityProviderClient` using `boto3.session.Session().client()` with explicit type annotations for static analysis. This pattern allows IDEs and type checkers to provide full autocompletion and validation for Cognito IDP service methods and their parameters.

import boto3
from boto3.session import Session
from mypy_boto3_cognito_idp.client import CognitoIdentityProviderClient


def get_cognito_idp_client(region_name: str = 'us-east-1') -> CognitoIdentityProviderClient:
    """Returns a type-hinted CognitoIdentityProvider client."""
    # Actual boto3 client (runtime)
    session: Session = boto3.session.Session()
    client: CognitoIdentityProviderClient = session.client(
        "cognito-idp", 
        region_name=region_name,
        aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''),
        aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', '')
    )
    return client

# Example usage
if __name__ == "__main__":
    import os
    os.environ['AWS_ACCESS_KEY_ID'] = os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY')
    os.environ['AWS_SECRET_ACCESS_KEY'] = os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY')

    cognito_client = get_cognito_idp_client()
    # You now have auto-completion and type checking for cognito_client methods
    # For example, cognito_client.list_user_pools() will show correct types.
    # response = cognito_client.list_user_pools(MaxResults=10)
    print(f"Client type: {type(cognito_client)}")
    # This client object now benefits from mypy-boto3 type hints.

view raw JSON →