Examples#
Auto-generated documentation for Redshift type annotations stubs module mypy-boto3-redshift.
Client#
Implicit type annotations#
Can be used with boto3-stubs[redshift]
package installed.
Write your Redshift
code as usual,
type checking and code completion should work out of the box.
# RedshiftClient usage example
from boto3.session import Session
session = Session()
client = session.client("redshift") # (1)
result = client.accept_reserved_node_exchange() # (2)
- client: RedshiftClient
- result: AcceptReservedNodeExchangeOutputMessageTypeDef
# DescribeClusterDbRevisionsPaginator usage example
from boto3.session import Session
session = Session()
client = session.client("redshift") # (1)
paginator = client.get_paginator("describe_cluster_db_revisions") # (2)
for item in paginator.paginate(...):
print(item) # (3)
- client: RedshiftClient
- paginator: DescribeClusterDbRevisionsPaginator
- item: ClusterDbRevisionsMessageTypeDef
# ClusterAvailableWaiter usage example
from boto3.session import Session
session = Session()
client = session.client("redshift") # (1)
waiter = client.get_waiter("cluster_available") # (2)
waiter.wait()
- client: RedshiftClient
- waiter: ClusterAvailableWaiter
Explicit type annotations#
With boto3-stubs-lite[redshift]
or a standalone mypy_boto3_redshift
package, you have to explicitly specify client: RedshiftClient
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.
# RedshiftClient usage example with type annotations
from boto3.session import Session
from mypy_boto3_redshift.client import RedshiftClient
from mypy_boto3_redshift.type_defs import AcceptReservedNodeExchangeOutputMessageTypeDef
from mypy_boto3_redshift.type_defs import AcceptReservedNodeExchangeInputMessageRequestTypeDef
session = Session()
client: RedshiftClient = session.client("redshift")
kwargs: AcceptReservedNodeExchangeInputMessageRequestTypeDef = {...}
result: AcceptReservedNodeExchangeOutputMessageTypeDef = client.accept_reserved_node_exchange(**kwargs)
# DescribeClusterDbRevisionsPaginator usage example with type annotations
from boto3.session import Session
from mypy_boto3_redshift.client import RedshiftClient
from mypy_boto3_redshift.paginator import DescribeClusterDbRevisionsPaginator
from mypy_boto3_redshift.type_defs import ClusterDbRevisionsMessageTypeDef
session = Session()
client: RedshiftClient = session.client("redshift")
paginator: DescribeClusterDbRevisionsPaginator = client.get_paginator("describe_cluster_db_revisions")
for item in paginator.paginate(...):
item: ClusterDbRevisionsMessageTypeDef
print(item)
# ClusterAvailableWaiter usage example with type annotations
from boto3.session import Session
from mypy_boto3_redshift.client import RedshiftClient
from mypy_boto3_redshift.waiter import ClusterAvailableWaiter
session = Session()
client: RedshiftClient = session.client("redshift")
waiter: ClusterAvailableWaiter = client.get_waiter("cluster_available")
waiter.wait()