mypy-boto3-odb Type Stubs
mypy-boto3-odb provides static type annotations for the boto3 Odb service client, enhancing development with type checking, auto-completion, and error detection in IDEs and with tools like Mypy. It is part of the 'mypy-boto3' ecosystem, automatically generated by `mypy-boto3-builder`, and is currently at version 1.42.80. The library receives frequent updates to align with upstream boto3 releases.
Warnings
- breaking The `mypy-boto3-builder` (which generates these stubs) migrated to PEP 561 compliant packages and removed support for Python 3.8.
- breaking TypeDef names for packed method arguments were shortened (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`), and conflicting `Extra` postfixes moved to the end.
- deprecated The `sms-voice` service is no longer supported and has been excluded from builds. Use `pinpoint-sms-voice` instead.
- gotcha These are type stubs only; the actual `boto3` library must be installed separately in your environment for runtime functionality.
- gotcha In some IDEs (e.g., VSCode without Pylance, or older PyCharm versions), explicit type annotations for `boto3.client()` or `boto3.resource()` calls might be required to enable full autocomplete and type checking.
- gotcha For Pylint compatibility and to avoid a runtime dependency on stubs in production, it is recommended to wrap stub imports within `typing.TYPE_CHECKING` blocks.
Install
-
pip install mypy-boto3-odb -
pip install 'boto3-stubs[odb]'
Imports
- OdbClient
from mypy_boto3_odb import OdbClient
- GetProfileOutputTypeDef
from mypy_boto3_odb.type_defs import GetProfileOutputTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_odb import OdbClient
from mypy_boto3_odb.type_defs import GetProfileOutputTypeDef
def get_odb_profile(profile_id: str) -> GetProfileOutputTypeDef:
# Initialize an Odb client with type hints
client: OdbClient = boto3.client("odb")
# Example API call (replace with actual Odb service calls)
# The actual Odb service is not widely known; this is illustrative.
response: GetProfileOutputTypeDef = client.get_profile(ProfileId=profile_id)
print(f"Retrieved Odb profile for {profile_id}: {response.get('Name')}")
return response
# Example usage (requires AWS credentials configured for boto3)
if __name__ == "__main__":
# In a real scenario, profile_id would come from input or configuration
sample_profile_id = "some-odb-profile-id"
try:
# This call will fail at runtime if the 'odb' service or 'get_profile' API
# does not exist or if credentials are not configured correctly.
# The purpose here is to demonstrate type hinting at static analysis time.
# response_data = get_odb_profile(sample_profile_id)
print("Type hinting for OdbClient and response types demonstrated.")
print("To run, ensure 'boto3' is installed and AWS credentials are configured.")
print("Note: 'odb' is a less common AWS service; adjust API calls as needed.")
except Exception as e:
print(f"An error occurred: {e}")