{"id":3364,"library":"mypy-boto3-health","title":"mypy-boto3-health type annotations","description":"mypy-boto3-health provides type annotations (stubs) for the AWS Boto3 Health service. It enables static type checking with tools like MyPy, improving code quality and catching potential errors for applications interacting with AWS Health. The library is actively maintained and releases frequently, often in sync with new `boto3` versions or `mypy-boto3-builder` updates.","status":"active","version":"1.42.59","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","mypy","type-hints","health","aws-health"],"install":[{"cmd":"pip install mypy-boto3-health","lang":"bash","label":"Install library"}],"dependencies":[{"reason":"Provides the actual AWS SDK runtime; mypy-boto3-health only provides type hints for it.","package":"boto3","optional":false},{"reason":"The static type checker that utilizes these type annotations.","package":"mypy","optional":true}],"imports":[{"note":"Type hints for Boto3 clients are provided by mypy-boto3 packages, not directly from boto3 itself.","wrong":"from boto3.client import HealthClient","symbol":"HealthClient","correct":"from mypy_boto3_health.client import HealthClient"},{"note":"Specific TypeDefs for service responses or input parameters are within the mypy-boto3 service package.","wrong":"from boto3.health.type_defs import DescribeEventsResponseTypeDef","symbol":"DescribeEventsResponseTypeDef","correct":"from mypy_boto3_health.type_defs import DescribeEventsResponseTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_health.client import HealthClient\nfrom mypy_boto3_health.type_defs import DescribeEventsResponseTypeDef\nimport os\n\n# Instantiate a typed Boto3 Health client\n# Ensure AWS_REGION is set in your environment or passed explicitly\nregion = os.environ.get(\"AWS_REGION\", \"us-east-1\")\nhealth_client: HealthClient = boto3.client(\"health\", region_name=region)\n\nprint(f\"Fetching health events in {region}...\")\n\ntry:\n    # Use a typed method and receive a typed response\n    response: DescribeEventsResponseTypeDef = health_client.describe_events(\n        filter={\n            \"eventStatusCodes\": [\"open\"],\n        }\n    )\n    events = response.get(\"events\", [])\n    if events:\n        print(f\"Found {len(events)} open health events:\")\n        for event in events:\n            print(f\"  Event ARN: {event['eventArn']}, Type: {event['eventTypeCategory']}\")\n    else:\n        print(\"No open health events found.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to obtain a typed Boto3 Health client and use its methods with full type hint support. It includes an example of calling `describe_events` and accessing the typed response."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer. Ensure your type checker (e.g., MyPy) is configured to correctly find PEP 561-compliant packages.","message":"Python 3.8 support has been removed across all `mypy-boto3` packages, and all packages have migrated to PEP 561. This may require upgrading your Python environment and reviewing how stubs are resolved by your type checker.","severity":"breaking","affected_versions":">=8.12.0"},{"fix":"Review your code for any direct references to `CreateDistributionRequestRequestTypeDef` (now `CreateDistributionRequestTypeDef`) or `CreateDistributionExtraRequestTypeDef` (now `CreateDistributionRequestExtraTypeDef`) and similar patterns, and update them accordingly.","message":"TypeDef naming conventions changed for packed method arguments and conflict resolution. This primarily impacts users relying on specific TypeDef names for complex input/output structures within the stubs.","severity":"breaking","affected_versions":">=8.9.0"},{"fix":"Ensure `pip install boto3` is part of your project's dependencies alongside `mypy-boto3-health`.","message":"This package provides *only* type annotations. You must install `boto3` separately for your application to actually interact with AWS services at runtime.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Periodically check the official AWS documentation and `mypy-boto3` release notes for changes in service names or preferred alternatives. If a service package seems outdated, verify if a newer or renamed package exists.","message":"AWS service names and their corresponding `mypy-boto3` package names can sometimes change or be deprecated (e.g., `sms-voice` replaced by `pinpoint-sms-voice`). Ensure you are using the correct and most up-to-date service name.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}