mypy-boto3-backupsearch Type Stubs

1.42.3 · active · verified Sat Apr 11

mypy-boto3-backupsearch provides type annotations for the `boto3` AWS BackupSearch service (version 1.42.3), generated by the `mypy-boto3-builder` (version 8.12.0). It enhances static type checking and IDE auto-completion for `boto3` client and resource operations, addressing the dynamic nature of `boto3` to improve code quality and prevent runtime errors. The library follows the release cadence of `boto3` and `botocore` services.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `boto3` BackupSearch client and apply explicit type annotations using `mypy-boto3-backupsearch` for enhanced static analysis. It also shows an example of using a generated `TypedDict` for response structures. The `TYPE_CHECKING` block ensures these type hints are only present during static analysis and do not add runtime dependencies.

import boto3
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from mypy_boto3_backupsearch.client import BackupSearchClient

session = boto3.session.Session()

# Explicit type annotation for the client
client: "BackupSearchClient" = session.client("backupsearch", region_name="us-east-1")

# Example of a client method call (type-hinted)
response = client.list_search_jobs()
print(f"Listed BackupSearch Jobs: {len(response.get('SearchJobs', []))}")

# Example with a TypedDict for a more complex response part
if TYPE_CHECKING:
    from mypy_boto3_backupsearch.type_defs import SearchJobTypeDef

jobs: list["SearchJobTypeDef"] = response.get('SearchJobs', [])
if jobs:
    print(f"First job ID: {jobs[0].get('BackupVaultName')}")

view raw JSON →