{"id":3605,"library":"mypy-boto3-keyspaces","title":"mypy-boto3-keyspaces Type Stubs for AWS Keyspaces","description":"mypy-boto3-keyspaces provides precise type annotations for the `boto3` AWS SDK, specifically for the Keyspaces (for Apache Cassandra) service. This library enables static type checking with tools like `mypy`, improving code reliability and developer experience when interacting with AWS Keyspaces. The current version is 1.42.31, released frequently to align with `boto3` and `botocore` updates.","status":"active","version":"1.42.31","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-hints","stubs","keyspaces","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-keyspaces","lang":"bash","label":"Install service stubs"},{"cmd":"pip install boto3 mypy","lang":"bash","label":"Install runtime and type checker"}],"dependencies":[{"reason":"This package provides type stubs for boto3's Keyspaces service client. boto3 itself is required for runtime execution.","package":"boto3"},{"reason":"mypy is the static type checker that utilizes these stubs. It is a tool dependency, not a runtime dependency.","package":"mypy","optional":true}],"imports":[{"symbol":"KeyspacesClient","correct":"from mypy_boto3_keyspaces.client import KeyspacesClient"},{"note":"Pre-8.9.0 builder versions used shorter names; current versions often append 'Request' or other suffixes for clarity.","wrong":"from mypy_boto3_keyspaces.type_defs import CreateTableRequestTypeDef","symbol":"CreateTableRequestRequestTypeDef","correct":"from mypy_boto3_keyspaces.type_defs import CreateTableRequestRequestTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_keyspaces.client import KeyspacesClient\nfrom typing import TYPE_CHECKING\nimport os\n\n# Configure AWS credentials and region if not already set via environment variables or ~/.aws/credentials\n# For example, using environment variables:\n# os.environ['AWS_ACCESS_KEY_ID'] = 'YOUR_ACCESS_KEY'\n# os.environ['AWS_SECRET_ACCESS_KEY'] = 'YOUR_SECRET_KEY'\n# os.environ['AWS_REGION'] = 'us-east-1'\n\nif TYPE_CHECKING:\n    # mypy will use these imports for type checking\n    client: KeyspacesClient = boto3.client(\"keyspaces\", region_name=os.environ.get('AWS_REGION', 'us-east-1'))\n    \n    # Example: List tables (requires appropriate IAM permissions)\n    try:\n        response = client.list_tables(keyspaceName='my_keyspace')\n        print(\"Tables:\", response.get(\"TableNames\"))\n    except Exception as e:\n        print(f\"Error listing tables: {e}\")\n\nelse:\n    # Runtime code doesn't strictly need the mypy-boto3 imports\n    client = boto3.client(\"keyspaces\", region_name=os.environ.get('AWS_REGION', 'us-east-1'))\n    \n    # Example: List tables\n    try:\n        response = client.list_tables(keyspaceName='my_keyspace')\n        print(\"Tables:\", response.get(\"TableNames\"))\n    except Exception as e:\n        print(f\"Error listing tables: {e}\")\n\nprint(\"Code execution finished. Run `mypy your_script.py` for type checking.\")","lang":"python","description":"This quickstart demonstrates how to use `mypy-boto3-keyspaces` with `boto3`. The `if TYPE_CHECKING:` block ensures that the type stub imports are only processed by static analysis tools like `mypy`, avoiding any runtime overhead. Remember to replace `my_keyspace` with an actual Keyspaces keyspace and ensure AWS credentials are configured for the `boto3` client to function correctly."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher. Alternatively, pin your `mypy-boto3-keyspaces` version to an older release compatible with Python 3.8.","message":"Support for Python 3.8 was removed starting with `mypy-boto3-builder` version 8.12.0. If you are using `mypy-boto3-keyspaces` generated by this builder version or later, Python 3.9+ is required.","severity":"breaking","affected_versions":">=8.12.0 (builder version, affects generated packages)"},{"fix":"Update your import paths and variable annotations to match the new TypeDef names. Refer to the specific service's documentation on the `mypy-boto3` GitHub for exact changes.","message":"TypeDef naming conventions changed significantly with `mypy-boto3-builder` version 8.9.0. Many TypeDefs that previously had a `Request` suffix at the end (e.g., `CreateDistributionRequestRequestTypeDef`) were shortened or had suffixes moved for consistency.","severity":"breaking","affected_versions":">=8.9.0 (builder version, affects generated packages)"},{"fix":"Always install the specific service stub package relevant to your `boto3` client calls, e.g., `pip install mypy-boto3-keyspaces`.","message":"For type checking a specific AWS service (like Keyspaces), you must install its dedicated `mypy-boto3-servicename` package (e.g., `mypy-boto3-keyspaces`), not just `boto3-stubs` or `mypy-boto3-builder`.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure `mypy` is installed (`pip install mypy`) and run it from your project root: `mypy your_script.py` or `mypy .`.","message":"Type checking only occurs when `mypy` is explicitly run on your code. Installing `mypy-boto3-keyspaces` provides the stubs, but `mypy` must be installed and executed for static analysis.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}