{"id":3059,"library":"mypy-boto3-cognito-sync","title":"mypy-boto3-cognito-sync Type Stubs for boto3 CognitoSync","description":"mypy-boto3-cognito-sync provides type annotations (stubs) for the boto3 AWS SDK, specifically for the Cognito Sync service. It is part of the larger mypy-boto3 project, which automatically generates these stubs in sync with boto3 releases to ensure up-to-date type checking for AWS services. The current version is 1.42.3, generated with mypy-boto3-builder 8.12.0.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","types","type-hinting","cognito","cognito-sync"],"install":[{"cmd":"pip install mypy-boto3-cognito-sync","lang":"bash","label":"Install standalone package"},{"cmd":"pip install 'boto3-stubs[cognito-sync]'","lang":"bash","label":"Install as boto3-stubs extra"}],"dependencies":[{"reason":"This package provides type stubs for boto3; boto3 itself must be installed for runtime functionality.","package":"boto3","optional":false},{"reason":"Requires Python 3.9 or higher.","package":"python","optional":false}],"imports":[{"note":"Used for explicit type annotation of the boto3 Cognito Sync client.","symbol":"CognitoSyncClient","correct":"from mypy_boto3_cognito_sync import CognitoSyncClient"},{"note":"Example of importing a Literal type for stricter type checking of allowed string values.","symbol":"BulkPublishStatusType","correct":"from mypy_boto3_cognito_sync.literals import BulkPublishStatusType"},{"note":"Example of importing a TypedDict for type-checking input/output shapes.","symbol":"BulkPublishRequestTypeDef","correct":"from mypy_boto3_cognito_sync.type_defs import BulkPublishRequestTypeDef"}],"quickstart":{"code":"from typing import TYPE_CHECKING\nimport boto3\n\nif TYPE_CHECKING:\n    from mypy_boto3_cognito_sync import CognitoSyncClient\n    from mypy_boto3_cognito_sync.type_defs import DatasetTypeDef\n\n# Initialize a boto3 session and client\nsession = boto3.session.Session()\nclient: \"CognitoSyncClient\" = session.client(\"cognito-sync\")\n\n# Example: List Identity Pools (Cognito Sync operations often tie to Identity Pools)\n# Note: Cognito Sync operations are typically tied to specific identities or datasets.\n# This example is illustrative for client type-checking.\ntry:\n    # Placeholder for actual Cognito Sync operation, as ListIdentityPools is CognitoIdentity\n    # A more realistic CognitoSync operation would be something like list_records\n    # For this example, we'll simulate a call that uses the client.\n    # In a real scenario, you'd provide IdentityPoolId, IdentityId, DatasetName, etc.\n    # For demonstration, we'll use a dummy call that the client can execute.\n    # (Note: CognitoSync doesn't have a simple 'list all' like many services)\n    \n    # A common operation is to list datasets for an identity.\n    identity_pool_id = os.environ.get('COGNITO_IDENTITY_POOL_ID', 'us-east-1:xxxx-xxxx-xxxx') # Dummy ID\n    identity_id = os.environ.get('COGNITO_IDENTITY_ID', 'us-east-1:xxxx-xxxx-xxxx') # Dummy ID\n    \n    response = client.list_datasets(\n        IdentityPoolId=identity_pool_id,\n        IdentityId=identity_id\n    )\n    \n    print(\"Datasets:\")\n    for dataset in response.get(\"Datasets\", []):\n        # dataset is type-checked as DatasetTypeDef\n        dataset_typed: \"DatasetTypeDef\" = dataset\n        print(f\"  Dataset Name: {dataset_typed['DatasetName']}, Num Records: {dataset_typed['NumRecords']}\")\n\nexcept client.exceptions.ResourceNotFoundException:\n    print(f\"Identity Pool or Identity not found for ID: {identity_pool_id}, {identity_id}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to use the `CognitoSyncClient` type annotation with a boto3 Cognito Sync client. The `TYPE_CHECKING` guard is a best practice to avoid importing the stubs at runtime, making them purely a development dependency. The example shows a typical `list_datasets` operation, which benefits from type hints on client methods and response structures."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"Python 3.8 support was removed for all `mypy-boto3` packages (including this one) in `mypy-boto3-builder` version 8.12.0. Projects must use Python 3.9 or newer.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0"},{"fix":"No direct code change required, but verify your `mypy` setup recognizes the stubs correctly. Most modern tooling handles PEP 561 automatically.","message":"All `mypy-boto3` packages migrated to PEP 561, changing how type checkers discover packages. Ensure your `mypy` configuration (if any) is compatible with standard PEP 561 stub discovery.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0"},{"fix":"Review and update `TypeDef` imports and usage patterns in your code to match the new, shorter names where applicable.","message":"TypedDict argument names for packed methods were shortened (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes were reordered in `mypy-boto3-builder 8.9.0`. This can break explicit `TypeDef` imports or usage if not updated.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0"},{"fix":"Ensure `pip install boto3` is part of your project's runtime dependencies.","message":"This package provides only type stubs for `boto3-stubs`. You must install the actual `boto3` library separately for your application to run. `mypy-boto3-cognito-sync` is a development dependency, not a runtime dependency.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To strictly pin the version, install the specific `mypy-boto3-cognito-sync` package directly with `pip install mypy-boto3-cognito-sync==X.Y.Z` in addition to or instead of the `boto3-stubs` extra.","message":"When installing `boto3-stubs` with service-specific extras (e.g., `boto3-stubs[cognito-sync]`), the version of the individual `mypy-boto3-*` sub-package might not be strictly locked to the specified `boto3-stubs` version. This can lead to unexpected type-checking errors if the installed sub-package is significantly newer than anticipated.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider installing `boto3-stubs-lite[cognito-sync]` instead, or disable PyCharm's internal type checker and use an external tool like `mypy` or `pyright`.","message":"Using `Literal` type overloads can cause slow performance and high CPU usage in PyCharm (issue PY-40997). For PyCharm users, `boto3-stubs-lite` is recommended as an alternative for better IDE responsiveness.","severity":"gotcha","affected_versions":"All versions (specific to PyCharm)"},{"fix":"Implement conditional type assignment, e.g., `if TYPE_CHECKING: from mypy_boto3_cognito_sync import CognitoSyncClient else: CognitoSyncClient = object`.","message":"When using `Pylint` with `TYPE_CHECKING` blocks for conditional stub imports, `Pylint` may complain about undefined variables. This requires setting the conditionally imported types to `object` in the non-`TYPE_CHECKING` branch.","severity":"gotcha","affected_versions":"All versions (specific to Pylint)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}