mypy-boto3-rbin: Type Annotations for AWS Recycle Bin
mypy-boto3-rbin provides static type annotations for the AWS boto3 Recycle Bin (rbin) service, generated by `mypy-boto3-builder`. It enhances development with `boto3` by offering type hints for clients, waiters, paginators, and service-specific TypeDefs. The library is actively maintained and frequently updated to synchronize with new `boto3` releases and AWS service changes, currently at version 1.42.3, reflecting the latest `mypy-boto3-builder` updates.
Warnings
- breaking Python 3.8 is no longer supported for any `mypy-boto3` packages since `mypy-boto3-builder` 8.12.0. Projects using these stubs must upgrade their Python environment to 3.9 or newer.
- gotcha `mypy-boto3-rbin` provides only type stubs; you must install `boto3` separately for runtime functionality. These packages are not replacements for the actual AWS SDK.
- gotcha The installed package name uses hyphens (`mypy-boto3-rbin`), but the Python import path uses underscores (`mypy_boto3_rbin`). Attempting to import `mypy-boto3-rbin` directly will result in an `ImportError`.
- breaking TypeDef naming conventions changed significantly in `mypy-boto3-builder` 8.9.0. TypeDefs for packed method arguments now use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). Conflicting `Extra` postfixes moved to the end. This may require updating existing type annotations in your codebase.
- gotcha When using type annotations with `boto3.client()`, it's recommended to use a `typing.TYPE_CHECKING` block. This prevents runtime dependency on the stub packages and avoids potential issues in environments where type checking is not performed.
Install
-
pip install mypy-boto3-rbin -
pip install boto3 mypy-boto3-rbin
Imports
- RecycleBinClient
from mypy_boto3_rbin.client import RecycleBinClient
- ListRulesResponseTypeDef
from mypy_boto3_rbin.type_defs import ListRulesResponseTypeDef
Quickstart
import boto3
from mypy_boto3_rbin.client import RecycleBinClient
from typing import TYPE_CHECKING
# It's recommended to use TYPE_CHECKING guard for type stubs
if TYPE_CHECKING:
# mypy will use RecycleBinClient for type checking here
rbin_client: RecycleBinClient = boto3.client("rbin")
else:
# At runtime, it's just a regular boto3 client
rbin_client = boto3.client("rbin")
# Example: List all recovery rules
try:
print("Listing RBin recovery rules...")
response = rbin_client.list_rules()
rules = response.get("Rules", [])
print(f"Found {len(rules)} recovery rules.")
for rule in rules:
print(f" - Rule ID: {rule['Id']}, ARN: {rule['RuleArn']}")
except Exception as e:
print(f"Error listing RBin rules: {e}")