{"id":3118,"library":"mypy-boto3-neptune","title":"mypy-boto3-neptune Type Annotations","description":"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.","status":"active","version":"1.42.57","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["type hinting","boto3","aws","neptune","mypy","stubs"],"install":[{"cmd":"pip install mypy-boto3-neptune","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install 'boto3-stubs[neptune]'","lang":"bash","label":"Install via boto3-stubs extras"}],"dependencies":[{"reason":"Provides runtime functionality; mypy-boto3-neptune provides type hints for this library.","package":"boto3","optional":false},{"reason":"The tool used to generate these type annotations; relevant if generating stubs locally or understanding versioning.","package":"mypy-boto3-builder","optional":true}],"imports":[{"symbol":"NeptuneClient","correct":"from mypy_boto3_neptune.client import NeptuneClient"},{"symbol":"NeptuneServiceResource","correct":"from mypy_boto3_neptune.service_resource import NeptuneServiceResource"},{"note":"Import specific waiters as needed, e.g., for 'DBInstanceAvailableWaiter'","symbol":"NeptuneWaiter","correct":"from mypy_boto3_neptune.waiter import SomeWaiter"},{"note":"Import specific paginators as needed, e.g., for 'DescribeDBInstancesPaginator'","symbol":"NeptunePaginator","correct":"from mypy_boto3_neptune.paginator import SomePaginator"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_neptune.client import NeptuneClient\n\ndef get_neptune_client() -> NeptuneClient:\n    \"\"\"Gets a typed Neptune client.\"\"\"\n    # boto3 automatically picks up credentials from environment variables or ~/.aws/credentials\n    client: NeptuneClient = boto3.client(\"neptune\")\n    return client\n\nif __name__ == \"__main__\":\n    neptune_client = get_neptune_client()\n    # Example usage (uncomment to run, requires AWS credentials)\n    # try:\n    #     response = neptune_client.describe_db_instances()\n    #     print(\"Neptune DB Instances:\")\n    #     for db_instance in response.get(\"DBInstances\", []):\n    #         print(f\"- {db_instance['DBInstanceIdentifier']}\")\n    # except Exception as e:\n    #     print(f\"Error describing DB instances: {e}\")\n    print(f\"Successfully retrieved Neptune client: {neptune_client.__class__.__name__}\")\n","lang":"python","description":"This quickstart demonstrates how to obtain a type-hinted AWS Neptune client using `boto3` and `mypy-boto3-neptune`. The `TYPE_CHECKING` block ensures that the type import is only used during static analysis, avoiding runtime dependencies. The client will automatically use AWS credentials configured in your environment."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or later. If you need Python 3.8 support, pin `mypy-boto3-builder` to `<8.12.0` and ensure your `mypy-boto3-neptune` version is compatible with an older builder.","message":"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.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0 (affects all generated stubs)"},{"fix":"Update your type checker (e.g., `mypy`) to a recent version. If encountering issues, verify package installation and type checker configuration.","message":"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.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.12.0 (affects all generated stubs)"},{"fix":"Always use explicit type annotations, e.g., `client: NeptuneClient = boto3.client(\"neptune\")`, as shown in the quickstart.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To fix this, set all type-imported variables to `object` in the `else` block of your `TYPE_CHECKING` guard: `if TYPE_CHECKING: from mypy_boto3_neptune.client import NeptuneClient else: NeptuneClient = object`.","message":"Pylint might report `undefined variable` warnings when using `TYPE_CHECKING` guards. This is a known compatibility issue.","severity":"gotcha","affected_versions":"All versions with Pylint"},{"fix":"Review your code for direct imports of TypeDefs and update their names according to the new conventions as needed.","message":"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.","severity":"breaking","affected_versions":"mypy-boto3-builder >=8.9.0 (affects generated TypeDefs)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}