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.
Client method usage example#
# KeyspacesClient usage example
from boto3.session import Session
session = Session()
client = session.client("keyspaces") # (1)
result = client.create_keyspace() # (2)
- client: KeyspacesClient
- result: CreateKeyspaceResponseTypeDef
Paginator usage example#
# 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)
- client: KeyspacesClient
- paginator: ListKeyspacesPaginator
- 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.
Client method usage example#
# 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 CreateKeyspaceRequestTypeDef
session = Session()
client: KeyspacesClient = session.client("keyspaces")
kwargs: CreateKeyspaceRequestTypeDef = {...}
result: CreateKeyspaceResponseTypeDef = client.create_keyspace(**kwargs)
Paginator usage example#
# 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)