Type Annotations for boto3 EventBridgeScheduler
mypy-boto3-scheduler provides type annotations for the boto3 EventBridgeScheduler service, currently at version 1.42.3. These stubs are generated by mypy-boto3-builder (version 8.12.0) and are designed to enhance type checking for boto3 code with tools like mypy, pyright, and various IDEs. The mypy-boto3-builder project has a rapid release cadence, frequently updating stubs to match boto3 releases and introducing new features or breaking changes.
Warnings
- breaking The `mypy-boto3-builder` (which generates this stub) removed support for Python 3.8. All generated stubs from builder version 8.12.0 onwards require Python 3.9 or newer.
- breaking The `mypy-boto3-builder 8.9.0` introduced breaking changes in how TypeDef names are generated. Type definitions for packed method arguments might have shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`). Conflicting `Extra` postfixes were also moved to the end.
- deprecated The `sms-voice` service was removed from the `mypy-boto3` ecosystem in `mypy-boto3-builder 8.11.0`. Users should switch to `pinpoint-sms-voice` instead. While this specifically impacts `sms-voice` stubs, it's a relevant deprecation policy for the broader `mypy-boto3` project.
- gotcha When using `typing.TYPE_CHECKING` guards to conditionally import stubs for Pylint, it might report undefined variables. To resolve this, ensure that types are set to `object` in the non-`TYPE_CHECKING` branch.
- gotcha For `mypy-boto3-lite` or standalone packages like this one, explicit type annotations are often necessary for `boto3.Session().client()` and `boto3.Session().resource()` calls to ensure full IDE auto-completion and type inference, even if `mypy` might sometimes infer them.
Install
-
pip install mypy-boto3-scheduler -
pip install 'boto3-stubs[scheduler]'
Imports
- EventBridgeSchedulerClient
from mypy_boto3_scheduler import EventBridgeSchedulerClient
Quickstart
import boto3
from mypy_boto3_scheduler import EventBridgeSchedulerClient
def get_scheduler_client() -> EventBridgeSchedulerClient:
"""Returns a type-hinted EventBridgeScheduler client."""
# boto3.client('scheduler') without explicit type annotation
# would return a 'Client' type, losing type-checking benefits.
client: EventBridgeSchedulerClient = boto3.client("scheduler")
return client
if __name__ == "__main__":
# Example usage: List schedules
scheduler_client = get_scheduler_client()
try:
response = scheduler_client.list_schedules(MaxResults=1)
print("Successfully listed schedules.")
for schedule in response.get('Schedules', []):
print(f" - {schedule.get('Name')}")
except Exception as e:
print(f"Error listing schedules: {e}")