mypy-boto3-evidently Type Annotations
mypy-boto3-evidently provides static type annotations for the `boto3` AWS CloudWatch Evidently service client, enhancing development with type-checking capabilities. It is generated by the `mypy-boto3-builder` project and is currently at version 1.42.35. Releases are frequent, typically in sync with `boto3` updates and `mypy-boto3-builder` enhancements.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0, affecting all generated `mypy-boto3-*` packages, including `mypy-boto3-evidently`.
- breaking TypeDef naming conventions were changed in `mypy-boto3-builder` version 8.9.0. Specifically, argument TypeDefs use shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`), and conflicting TypeDef `Extra` postfixes were moved (e.g., `CreateDistributionExtraRequestTypeDef` -> `CreateDistributionRequestExtraTypeDef`).
- gotcha The `mypy-boto3` ecosystem migrated to PEP 561 compliant packages in `mypy-boto3-builder` version 8.12.0. While generally transparent, this changes how type checkers discover and use the stubs.
- gotcha The `mypy-boto3` project distinguishes between general `boto3-stubs` (the full collection, formerly `mypy-boto3`) and individual service stubs like `mypy-boto3-evidently`. From `mypy-boto3-builder` 8.9.0, 'Legacy `mypy-boto3` moved to a separate product and is no longer generated along with `boto3-stubs`'.
Install
-
pip install boto3 mypy-boto3-evidently
Imports
- EvidentlyClient
from mypy_boto3_evidently import EvidentlyClient
- Service Resource types (e.g., 'ExperimentTypeDef')
from mypy_boto3_evidently.type_defs import ExperimentTypeDef
Quickstart
import boto3
from mypy_boto3_evidently import EvidentlyClient
from mypy_boto3_evidently.type_defs import CreateExperimentResponseTypeDef
# Initialize a boto3 client (ensure boto3 is installed and configured)
client: EvidentlyClient = boto3.client("evidently")
# Example usage with type hints
try:
# This call is type-checked against the EvidentlyClient interface
response: CreateExperimentResponseTypeDef = client.create_experiment(
name="MyFeatureExperiment",
project="MyProject",
# Add other required parameters here, for example:
# treatments=[{ 'feature': 'feature-name', 'treatmentName': 'control' }],
# onlineAbConfig={ 'treatmentWeights': {'control': 100} }
)
print(f"Experiment created: {response.get('arn')}")
except client.exceptions.ConflictException:
print("Experiment already exists.")
except Exception as e:
print(f"An error occurred: {e}")