Skip to content

Examples#

Index > Keyspaces > Examples

Auto-generated documentation for Keyspaces type annotations stubs module mypy-boto3-keyspaces.

Client#

Implicit type annotations#

Can be used with boto3-stubs[keyspaces] package installed.

Write your Keyspaces code as usual, type checking and code completion should work out of the box.

# KeyspacesClient usage example

from boto3.session import Session


session = Session()

client = session.client("keyspaces")  # (1)
result = client.create_keyspace()  # (2)
  1. client: KeyspacesClient
  2. result: CreateKeyspaceResponseTypeDef
# ListKeyspacesPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("keyspaces")  # (1)

paginator = client.get_paginator("list_keyspaces")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: KeyspacesClient
  2. paginator: ListKeyspacesPaginator
  3. item: ListKeyspacesResponseTypeDef

Explicit type annotations#

With boto3-stubs-lite[keyspaces] or a standalone mypy_boto3_keyspaces package, you have to explicitly specify client: KeyspacesClient type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# KeyspacesClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_keyspaces.client import KeyspacesClient
from mypy_boto3_keyspaces.type_defs import CreateKeyspaceResponseTypeDef
from mypy_boto3_keyspaces.type_defs import CreateKeyspaceRequestRequestTypeDef


session = Session()

client: KeyspacesClient = session.client("keyspaces")

kwargs: CreateKeyspaceRequestRequestTypeDef = {...}
result: CreateKeyspaceResponseTypeDef = client.create_keyspace(**kwargs)
# ListKeyspacesPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_keyspaces.client import KeyspacesClient
from mypy_boto3_keyspaces.paginator import ListKeyspacesPaginator
from mypy_boto3_keyspaces.type_defs import ListKeyspacesResponseTypeDef


session = Session()
client: KeyspacesClient = session.client("keyspaces")

paginator: ListKeyspacesPaginator = client.get_paginator("list_keyspaces")
for item in paginator.paginate(...):
    item: ListKeyspacesResponseTypeDef
    print(item)