{"id":2604,"library":"mypy-boto3-events","title":"mypy-boto3-events","description":"mypy-boto3-events provides type annotations for the `boto3` AWS EventBridge service client. It enhances code completion and static type checking for `boto3` interactions, ensuring better code quality and developer experience. This library is part of the `mypy-boto3-builder` project, which frequently updates to match `boto3` and `aioboto3` changes. The current version is 1.42.3.","status":"active","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","mypy","type-hints","eventbridge","stubs","static-analysis"],"install":[{"cmd":"pip install mypy-boto3-events","lang":"bash","label":"Install service-specific stubs"},{"cmd":"pip install boto3-stubs[events]","lang":"bash","label":"Install as part of boto3-stubs (recommended)"}],"dependencies":[{"reason":"Provides the underlying AWS SDK for Python that these stubs type-hint.","package":"boto3","optional":false},{"reason":"Static type checker to leverage the annotations.","package":"mypy","optional":true},{"reason":"Alternative static type checker to leverage the annotations.","package":"pyright","optional":true}],"imports":[{"note":"Client types are nested under the 'client' submodule for clarity and organization.","wrong":"from mypy_boto3_events import EventBridgeClient","symbol":"EventBridgeClient","correct":"from mypy_boto3_events.client import EventBridgeClient"},{"note":"Paginator types are available in the 'paginator' submodule.","symbol":"ListRulesPaginator","correct":"from mypy_boto3_events.paginator import ListRulesPaginator"},{"note":"Service-specific TypeDefs for request/response payloads are in 'type_defs'.","symbol":"PutRuleRequestRequestTypeDef","correct":"from mypy_boto3_events.type_defs import PutRuleRequestRequestTypeDef"}],"quickstart":{"code":"import boto3\nfrom typing import TYPE_CHECKING\n\nif TYPE_CHECKING:\n    from mypy_boto3_events.client import EventBridgeClient\n    from mypy_boto3_events.type_defs import PutRuleResponseTypeDef, PutRuleRequestRequestTypeDef\n\ndef get_eventbridge_client() -> 'EventBridgeClient':\n    \"\"\"Initializes and returns a type-hinted EventBridge client.\"\"\"\n    # boto3.client implicitly returns Any, mypy-boto3 provides the type stubs\n    client: EventBridgeClient = boto3.client('events')\n    return client\n\ndef put_example_rule():\n    client = get_eventbridge_client()\n    \n    rule_params: PutRuleRequestRequestTypeDef = {\n        \"Name\": \"MyTestRule\",\n        \"EventPattern\": \"{\\\"source\\\":[\\\"aws.ec2\\\"]}\",\n        \"State\": \"ENABLED\"\n    }\n    \n    response: PutRuleResponseTypeDef = client.put_rule(**rule_params)\n    print(f\"Rule ARN: {response.get('RuleArn')}\")\n\nif __name__ == \"__main__\":\n    put_example_rule()","lang":"python","description":"This quickstart demonstrates how to get a type-hinted EventBridge client and use a method with its corresponding TypeDefs. The `TYPE_CHECKING` block ensures that `mypy-boto3-events` is only a dev dependency. Note the explicit type annotation for `boto3.client` is often required for full IDE auto-completion."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. If stuck on Python 3.8, pin `mypy-boto3-events` to a version older than 1.42.3 (e.g., `mypy-boto3-events<1.42.3`).","message":"Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequently across all generated `mypy-boto3-*` packages. Python 3.9 or higher is now required.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder and derived packages"},{"fix":"Ensure your `mypy` configuration (e.g., `pyproject.toml`) and environment are set up to correctly discover installed PEP 561 packages. For most users, this will work automatically with recent `mypy` versions.","message":"The project migrated to PEP 561 compliant packages in `mypy-boto3-builder` version 8.12.0. This change affects how type stubs are discovered and might require adjustments in some build systems or explicit `mypy` configurations.","severity":"breaking","affected_versions":">=8.12.0 of mypy-boto3-builder and derived packages"},{"fix":"Update any explicit imports or references to TypeDefs in your code to reflect the new naming conventions. Consult the specific service's documentation for the exact new names.","message":"TypeDef names for packed method arguments were shortened (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`) in `mypy-boto3-builder` version 8.9.0. Conflicting TypeDefs also had their 'Extra' postfix moved to the end.","severity":"breaking","affected_versions":">=8.9.0 of mypy-boto3-builder and derived packages"},{"fix":"Explicitly annotate the return type of `boto3.client('service')` with the corresponding `ServiceClient` type (e.g., `client: EventBridgeClient = boto3.client('events')`).","message":"For optimal auto-completion and type inference in some IDEs (e.g., VSCode) and type checkers, explicit type annotations for `boto3.client()`, `boto3.session.client()`, `client.get_waiter()`, and `client.get_paginator()` calls are often recommended, despite the stubs providing implicit discovery.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Wrap your `mypy-boto3` imports in a `if TYPE_CHECKING:` block and define placeholder `object` types for runtime when `TYPE_CHECKING` is false. This makes `mypy-boto3-events` a dev-only dependency and satisfies Pylint.","message":"When using Pylint, it may report 'undefined variable' errors for type-hinted imports (e.g., `from mypy_boto3_events.client import EventBridgeClient`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Regularly check release notes for `mypy-boto3-builder` and `mypy-boto3-events` for any service name changes or package renames, and update import paths accordingly.","message":"Service names within the `mypy-boto3` ecosystem can change (e.g., `sms-voice` became `pinpoint-sms-voice`). While not directly affecting `events` currently, this indicates a potential for future updates to require changes to import paths for specific services.","severity":"gotcha","affected_versions":"All versions (ecosystem-wide)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}