mypy-boto3-neptune Type Annotations
mypy-boto3-neptune provides comprehensive type annotations for the AWS Neptune service within the `boto3` library, ensuring type safety and enhanced developer experience in environments like mypy, VSCode, and PyCharm. It is currently at version 1.42.57 and is part of a frequently updated ecosystem, with releases often tied to new `boto3` versions and updates to the `mypy-boto3-builder` tool.
Warnings
- breaking Starting with `mypy-boto3-builder` version 8.12.0 (which generates these stubs), Python 3.8 is no longer supported. Projects must use Python 3.9 or newer.
- breaking The `mypy-boto3-builder` (from version 8.12.0) migrated to PEP 561 package format, which may change how some environments or older type checkers discover and interpret the stubs. Ensure your type checker is up-to-date.
- gotcha For optimal autocomplete and type checking in some IDEs (like older VSCode or PyCharm without the `mypy` plugin configured optimally), explicit type annotations for `boto3.client()` and `boto3.resource()` calls are highly recommended or even necessary.
- gotcha Pylint might report `undefined variable` warnings when using `TYPE_CHECKING` guards. This is a known compatibility issue.
- breaking In `mypy-boto3-builder` 8.9.0, there were breaking changes to the naming conventions of TypeDefs (e.g., shorter names for packed method arguments, `Extra` postfix moved to the end). This could affect users who directly import and use generated TypeDefs.
Install
-
pip install mypy-boto3-neptune -
pip install 'boto3-stubs[neptune]'
Imports
- NeptuneClient
from mypy_boto3_neptune.client import NeptuneClient
- NeptuneServiceResource
from mypy_boto3_neptune.service_resource import NeptuneServiceResource
- NeptuneWaiter
from mypy_boto3_neptune.waiter import SomeWaiter
- NeptunePaginator
from mypy_boto3_neptune.paginator import SomePaginator
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_neptune.client import NeptuneClient
def get_neptune_client() -> NeptuneClient:
"""Gets a typed Neptune client."""
# boto3 automatically picks up credentials from environment variables or ~/.aws/credentials
client: NeptuneClient = boto3.client("neptune")
return client
if __name__ == "__main__":
neptune_client = get_neptune_client()
# Example usage (uncomment to run, requires AWS credentials)
# try:
# response = neptune_client.describe_db_instances()
# print("Neptune DB Instances:")
# for db_instance in response.get("DBInstances", []):
# print(f"- {db_instance['DBInstanceIdentifier']}")
# except Exception as e:
# print(f"Error describing DB instances: {e}")
print(f"Successfully retrieved Neptune client: {neptune_client.__class__.__name__}")