mypy-boto3-neptunedata Type Annotations
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
- breaking Support for Python 3.8 was removed. Projects requiring type annotations for `boto3` will need to upgrade to Python 3.9 or newer.
- breaking The builder migrated to PEP 561 compliant packages. While beneficial, this might impact how `mypy` or other tooling discovers and processes these stubs if they relied on specific older package structures or `mypy` configurations.
- breaking TypeDefs for packed method arguments use shorter names if possible, and conflicting TypeDef `Extra` postfix moved to the end. This can break code that directly imported or referenced these specific TypeDef names.
- gotcha This library provides type stubs only. You must also install the `boto3` runtime library for your application to function at runtime. `mypy-boto3-neptunedata` is not a replacement for `boto3`.
- gotcha For optimal type checking accuracy, the `mypy-boto3-neptunedata` package version should ideally align closely with your installed `boto3` version. Significant version mismatches can lead to incorrect type hints due to API differences.
Install
-
pip install mypy-boto3-neptunedata -
pip install boto3 -
pip install mypy
Imports
- NeptuneDataClient
from mypy_boto3_neptunedata.client import NeptuneDataClient
- ListGremlinQueriesOutputTypeDef
from mypy_boto3_neptunedata.type_defs import ListGremlinQueriesOutputTypeDef
Quickstart
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}")