mypy-boto3-neptunedata Type Annotations

1.42.78 · active · verified Sat Apr 11

mypy-boto3-neptunedata provides type annotations for the `boto3` NeptuneData service, generated by `mypy-boto3-builder`. It enhances development with `boto3` by enabling static type checking for NeptuneData client methods and response/request structures. The current version is 1.42.78, with new releases frequently, often mirroring `boto3` and `botocore` updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a type-hinted `boto3` client for the NeptuneData service and use it with type-safe operations. It highlights how response structures are automatically typed, allowing for static analysis by `mypy`. Remember that `boto3` itself needs to be installed, and AWS credentials configured for actual execution.

import boto3
from mypy_boto3_neptunedata.client import NeptuneDataClient
from mypy_boto3_neptunedata.type_defs import (
    ListGremlinQueriesOutputTypeDef,
    GremlinQueryStatusTypeDef
)
import os

def get_neptune_query_status() -> ListGremlinQueriesOutputTypeDef:
    """
    Demonstrates using typed boto3 client for NeptuneData service.
    Requires 'boto3' and 'mypy-boto3-neptunedata' installed.
    """
    # Create a typed NeptuneData client
    client: NeptuneDataClient = boto3.client(
        "neptunedata",
        region_name=os.environ.get("AWS_REGION", "us-east-1")
    )

    # Example: List active Gremlin queries
    # The return type will be correctly inferred as ListGremlinQueriesOutputTypeDef
    response = client.list_gremlin_queries(
        includeWaitingQueries=True
    )

    # Type checking ensures correct access to dictionary keys and values
    for query in response.get("queries", []):
        status: GremlinQueryStatusTypeDef = query.get("status")
        query_id: str = query.get("queryId")
        print(f"Query ID: {query_id}, Status: {status}")

    return response

# To type-check this code, run `mypy your_script.py`
# To run this code, ensure AWS credentials are configured for your environment.
# if __name__ == "__main__":
#     try:
#         result = get_neptune_query_status()
#         print(f"Listed {len(result.get('queries', []))} queries.")
#     except Exception as e:
#         print(f"Error calling NeptuneData: {e}")

view raw JSON →