{"id":10314,"library":"types-aiobotocore-cognito-idp","title":"Type annotations for aiobotocore CognitoIdentityProvider","description":"This package provides PEP 561-compatible type annotations for the `aiobotocore` library's CognitoIdentityProvider service client. It is generated by `mypy-boto3-builder` and ensures type safety for `aiobotocore` calls, enhancing developer experience with static analysis tools like MyPy. The current version is 3.4.0, aligning with a specific `aiobotocore` service version, and it releases frequently to match upstream AWS API changes and builder updates.","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aiobotocore","aws","cognito","types","mypy","static-analysis","typings","pyi"],"install":[{"cmd":"pip install types-aiobotocore-cognito-idp","lang":"bash","label":"Install package"}],"dependencies":[{"reason":"Runtime dependency for the actual AWS API calls. This package only provides type stubs.","package":"aiobotocore","optional":false}],"imports":[{"symbol":"CognitoIdentityProviderClient","correct":"from types_aiobotocore_cognito_idp.client import CognitoIdentityProviderClient"},{"symbol":"ListUsersResponseTypeDef","correct":"from types_aiobotocore_cognito_idp.type_defs import ListUsersResponseTypeDef"},{"symbol":"ListUsersPaginator","correct":"from types_aiobotocore_cognito_idp.paginator import ListUsersPaginator"}],"quickstart":{"code":"import asyncio\nimport os\nimport aiobotocore\nfrom types_aiobotocore_cognito_idp.client import CognitoIdentityProviderClient\nfrom types_aiobotocore_cognito_idp.type_defs import ListUsersResponseTypeDef\n\nasync def main():\n    # Ensure AWS credentials are set up (e.g., via environment variables, ~/.aws/credentials)\n    # This example assumes you have valid credentials for Cognito User Pools.\n\n    # Using aiobotocore.get_session() is the recommended way for aiobotocore\n    session = aiobotocore.get_session()\n\n    async with session.create_client(\n        \"cognito-idp\",\n        region_name=os.environ.get(\"AWS_REGION\", \"us-east-1\"),\n        aws_access_key_id=os.environ.get(\"AWS_ACCESS_KEY_ID\", \"\"), # Provide actual credentials or rely on env/config\n        aws_secret_access_key=os.environ.get(\"AWS_SECRET_ACCESS_KEY\", \"\"), # Provide actual credentials or rely on env/config\n    ) as client:\n        # The client object will be correctly typed as CognitoIdentityProviderClient\n        # by type checkers like MyPy due to the installed stubs.\n        typed_client: CognitoIdentityProviderClient = client\n\n        user_pool_id = os.environ.get(\"COGNITO_USER_POOL_ID\", \"\") # Replace with your User Pool ID\n\n        if not user_pool_id:\n            print(\"Error: COGNITO_USER_POOL_ID environment variable not set.\")\n            return\n\n        try:\n            response: ListUsersResponseTypeDef = await typed_client.list_users(\n                UserPoolId=user_pool_id,\n                Limit=2\n            )\n            print(f\"Successfully listed users in User Pool '{user_pool_id}':\")\n            for user in response.get(\"Users\", []):\n                print(f\"  - Username: {user.get('Username')}, Status: {user.get('UserStatus')}\")\n            if \"PaginationToken\" in response:\n                print(f\"  (Next token: {response['PaginationToken']})\")\n\n        except Exception as e:\n            print(f\"Error listing users: {e}\")\n            print(\"Ensure COGNITO_USER_POOL_ID and AWS credentials are correctly set and have permissions.\")\n\nif __name__ == \"__main__\":\n    # To run this example, set environment variables:\n    # export AWS_REGION=\"your-aws-region\"\n    # export AWS_ACCESS_KEY_ID=\"your-access-key\"\n    # export AWS_SECRET_ACCESS_KEY=\"your-secret-key\"\n    # export COGNITO_USER_POOL_ID=\"your-cognito-user-pool-id\"\n    asyncio.run(main())","lang":"python","description":"This quickstart demonstrates how to use `aiobotocore` with `types-aiobotocore-cognito-idp` for type-safe interaction with AWS Cognito Identity Provider. It creates a client, then calls `list_users` to retrieve user information, leveraging the provided type hints for client methods and response structures. Remember to configure your AWS credentials and a Cognito User Pool ID."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. The minimum required Python version is now 3.9.","message":"Starting with `mypy-boto3-builder` version 8.12.0 (which generated `types-aiobotocore-cognito-idp` 3.4.0), Python 3.8 is no longer supported for any generated packages.","severity":"breaking","affected_versions":">=3.4.0 (for this package), >=8.12.0 (for builder)"},{"fix":"Ensure you have `aiobotocore` installed in your project: `pip install aiobotocore`.","message":"This package provides *only* type annotations (stubs) for `aiobotocore`. It does not contain any runtime code for interacting with AWS. You must install `aiobotocore` separately for your application to function.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install types-aiobotocore-cognito-idp`.","cause":"The `types-aiobotocore-cognito-idp` package has not been installed in your environment.","error":"ModuleNotFoundError: No module named 'types_aiobotocore_cognito_idp'"},{"fix":"Ensure `types-aiobotocore-cognito-idp` is installed and your type checker is configured correctly (e.g., for MyPy, ensure it's run without `--ignore-missing-imports` for `aiobotocore` and that the stubs are in `sys.path`). Make sure `aiobotocore` itself is installed.","cause":"The `aiobotocore` library is installed, but the corresponding type stub package `types-aiobotocore-cognito-idp` is either missing or not being picked up by your type checker (e.g., MyPy).","error":"error: Module 'aiobotocore.client' has no attribute 'CognitoIdentityProviderClient' [attr-defined] or similar type errors for aiobotocore methods."},{"fix":"Instead of `CognitoIdentityProviderClient()`, create the client using `aiobotocore.get_session().create_client('cognito-idp')`. The `CognitoIdentityProviderClient` import is used only for type hints, e.g., `client: CognitoIdentityProviderClient = ...`.","cause":"You are trying to instantiate `CognitoIdentityProviderClient` directly. This is a type alias/interface for type checking, not a concrete class that can be instantiated at runtime.","error":"error: Name \"CognitoIdentityProviderClient\" is not defined [name-not-defined] (when attempting `client = CognitoIdentityProviderClient()`)"}]}