mypy-boto3-backupsearch Type Stubs
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
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 will need to upgrade their Python version to 3.9 or higher. `mypy` itself also no longer supports Python 3.8.
- breaking As of `mypy-boto3-builder` 8.12.0, packages migrated to PEP 561, using `py.typed` marker files. This might affect how type checkers discover and interpret the stubs in certain environments or older toolchains.
- breaking In `mypy-boto3-builder` 8.9.0, there were breaking changes to `TypeDef` naming conventions (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). While this example is not for BackupSearch, similar renames might apply to BackupSearch `TypeDefs`.
- gotcha This package provides *only* type annotations. The actual `boto3` library is a mandatory runtime dependency and must be installed separately to execute any AWS API calls.
- gotcha The `mypy-boto3` stub versions are typically aligned with `boto3` versions. Using a stub package version that significantly deviates from your installed `boto3` runtime version can lead to type mismatches or incorrect hints.
- gotcha For compatibility with `pylint` and to avoid unnecessary runtime dependencies, it is recommended to conditionally import type hints using `if TYPE_CHECKING:`.
Install
-
pip install mypy-boto3-backupsearch boto3 mypy
Imports
- BackupSearchClient
from mypy_boto3_backupsearch.client import BackupSearchClient
- Session
from boto3.session import Session
- BackupCreationTimeFilterOutputTypeDef
from mypy_boto3_backupsearch.type_defs import BackupCreationTimeFilterOutputTypeDef
Quickstart
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')}")