Skip to content

Examples#

Index > Neptune > Examples

Auto-generated documentation for Neptune type annotations stubs module mypy-boto3-neptune.

Client#

Implicit type annotations#

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

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

# NeptuneClient usage example

from boto3.session import Session


session = Session()

client = session.client("neptune")  # (1)
result = client.add_role_to_db_cluster()  # (2)
  1. client: NeptuneClient
  2. result: EmptyResponseMetadataTypeDef
# DescribeDBClusterEndpointsPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("describe_db_cluster_endpoints")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: NeptuneClient
  2. paginator: DescribeDBClusterEndpointsPaginator
  3. item: DBClusterEndpointMessageTypeDef
# DBInstanceAvailableWaiter usage example

from boto3.session import Session


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

waiter = client.get_waiter("db_instance_available")  # (2)
waiter.wait()
  1. client: NeptuneClient
  2. waiter: DBInstanceAvailableWaiter

Explicit type annotations#

With boto3-stubs-lite[neptune] or a standalone mypy_boto3_neptune package, you have to explicitly specify client: NeptuneClient 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.

# NeptuneClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_neptune.client import NeptuneClient
from mypy_boto3_neptune.type_defs import EmptyResponseMetadataTypeDef
from mypy_boto3_neptune.type_defs import AddRoleToDBClusterMessageRequestTypeDef


session = Session()

client: NeptuneClient = session.client("neptune")

kwargs: AddRoleToDBClusterMessageRequestTypeDef = {...}
result: EmptyResponseMetadataTypeDef = client.add_role_to_db_cluster(**kwargs)
# DescribeDBClusterEndpointsPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_neptune.client import NeptuneClient
from mypy_boto3_neptune.paginator import DescribeDBClusterEndpointsPaginator
from mypy_boto3_neptune.type_defs import DBClusterEndpointMessageTypeDef


session = Session()
client: NeptuneClient = session.client("neptune")

paginator: DescribeDBClusterEndpointsPaginator = client.get_paginator("describe_db_cluster_endpoints")
for item in paginator.paginate(...):
    item: DBClusterEndpointMessageTypeDef
    print(item)
# DBInstanceAvailableWaiter usage example with type annotations

from boto3.session import Session

from mypy_boto3_neptune.client import NeptuneClient
from mypy_boto3_neptune.waiter import DBInstanceAvailableWaiter

session = Session()
client: NeptuneClient = session.client("neptune")

waiter: DBInstanceAvailableWaiter = client.get_waiter("db_instance_available")
waiter.wait()