Type annotations for boto3 CloudWatchObservabilityAccessManager
mypy-boto3-oam provides type annotations for the boto3 CloudWatchObservabilityAccessManager service, enabling static type checking and improved IDE support for AWS SDK for Python (boto3) users. It is generated with `mypy-boto3-builder 8.12.0` and currently stands at version 1.42.3, aligning with the versioning of `boto3` for which it provides stubs. The `mypy-boto3` project actively releases updates, often in sync with `boto3` and `botocore` releases, as well as `mypy-boto3-builder` updates.
Warnings
- breaking Support for Python 3.8 has been removed across all `mypy-boto3` packages, including `mypy-boto3-oam`. Users on Python 3.8 will need to upgrade to Python 3.9 or newer.
- breaking The `mypy-boto3-builder` (which generates this stub) introduced changes to TypeDef naming conventions in version 8.9.0. Specifically, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`, and `Extra` postfixes moved (`CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`). While this package's core Client type is stable, explicit references to generated TypeDefs might require updates if you're using older code with newer stubs.
- gotcha `mypy-boto3` migrated to PEP 561 packages, which is the standard for distributing type information. While this improves compatibility, users of older `mypy` or `IDE` versions might experience issues recognizing type stubs. Ensure your type checking tools are up-to-date.
- gotcha For optimal IDE auto-completion and type inference (especially in VSCode and PyCharm), it is often recommended to use explicit type annotations when instantiating `boto3` clients, even though `mypy-boto3` aims for automatic type discovery. This can prevent cases where the IDE struggles to infer the correct `boto3` client type.
- gotcha When using `mypy-boto3-oam` with Pylint, if you conditionally import type stubs using `if TYPE_CHECKING: ... else: ...`, Pylint might report `undefined variable` errors for the runtime `object` assignments. This is a known issue with Pylint's interaction with `TYPE_CHECKING` guards.
Install
-
pip install mypy-boto3-oam boto3
Imports
- CloudWatchObservabilityAccessManagerClient
from mypy_boto3_oam.client import CloudWatchObservabilityAccessManagerClient
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_oam.client import CloudWatchObservabilityAccessManagerClient
def get_oam_client() -> 'CloudWatchObservabilityAccessManagerClient':
"""Gets a type-hinted CloudWatch Observability Access Manager client."""
# In a real application, credentials would be managed by boto3's configuration
# or environment variables.
client: CloudWatchObservabilityAccessManagerClient = boto3.client(
"oam",
region_name="us-east-1",
aws_access_key_id="{}".format(os.environ.get('AWS_ACCESS_KEY_ID', '')) if os.environ.get('AWS_ACCESS_KEY_ID') else None,
aws_secret_access_key="{}".format(os.environ.get('AWS_SECRET_ACCESS_KEY', '')) if os.environ.get('AWS_SECRET_ACCESS_KEY') else None
)
return client
# Example usage (will not actually call AWS without valid credentials)
oam_client = get_oam_client()
print(f"Client type: {type(oam_client)}")
# mypy will now correctly infer methods like oam_client.list_attachments()
# without requiring a runtime call.