{"id":5667,"library":"mypy-boto3","title":"mypy-boto3 (Legacy Boto3 Type Stubs)","description":"This package provides legacy type annotations for the `boto3` AWS SDK. As of version `1.42.3`, it is officially deprecated in favor of `types-boto3`. It enhances `boto3` code with static type checking capabilities (e.g., with MyPy) by providing a single package with stubs for all AWS services. The recommended successor, `types-boto3`, offers more granular, service-specific stub packages and is actively maintained.","status":"deprecated","version":"1.42.3","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["boto3","aws","mypy","type-hints","stubs","legacy","deprecated"],"install":[{"cmd":"pip install mypy-boto3 boto3","lang":"bash","label":"Legacy installation (Deprecated)"},{"cmd":"pip install 'types-boto3[all]' boto3","lang":"bash","label":"Recommended alternative for all services"},{"cmd":"pip install 'types-boto3[s3,lambda]' boto3","lang":"bash","label":"Recommended alternative for specific services (best practice)"}],"dependencies":[{"reason":"Runtime dependency for type stubs; mypy-boto3 provides types for boto3.","package":"boto3","optional":false}],"imports":[{"note":"mypy-boto3 is a stub package and not directly imported. Its presence enables type checking for standard boto3 imports.","symbol":"boto3.client","correct":"import boto3\n\ns3_client = boto3.client('s3')"}],"quickstart":{"code":"import boto3\nfrom typing import Optional\n\ndef get_s3_bucket_location(bucket_name: str) -> Optional[str]:\n    s3_client = boto3.client('s3')\n    # The response type from get_bucket_location will be fully type-hinted\n    response = s3_client.get_bucket_location(Bucket=bucket_name)\n    location = response.get('LocationConstraint')\n    return location\n\n# Example usage (requires AWS credentials configured and bucket to exist)\n# try:\n#     # For a bucket like 'your-unique-test-bucket-123'\n#     location = get_s3_bucket_location('your-unique-test-bucket-123')\n#     if location is not None:\n#         print(f\"Bucket location: {location}\")\n#     else:\n#         print(\"Bucket location is 'us-east-1' (default) or not set.\")\n# except Exception as e:\n#     print(f\"Error fetching bucket location: {e}\")","lang":"python","description":"This quickstart demonstrates how `mypy-boto3` (or its successor `types-boto3`) enhances standard `boto3` usage with type annotations. Installing the stubs allows static analysis tools like MyPy and IDEs to provide accurate type information, autocomplete, and error checking for `boto3` client methods and their responses."},"warnings":[{"fix":"Uninstall `mypy-boto3` (`pip uninstall mypy-boto3`). Install `types-boto3` or specific service packages (e.g., `pip install types-boto3-s3`). Refer to `types-boto3` documentation for details.","message":"The `mypy-boto3` package is officially deprecated and no longer actively maintained. Users are strongly advised to migrate to `types-boto3` and its service-specific sub-packages for current features, bug fixes, and active support.","severity":"breaking","affected_versions":"1.x.x (all versions of mypy-boto3)"},{"fix":"Identify the specific AWS services your project uses and install only the corresponding `types-boto3-<service>` packages (e.g., `pip install types-boto3-s3 types-boto3-lambda`) or `pip install 'types-boto3[all]'` if all stubs are needed.","message":"Unlike `mypy-boto3`, which provided all service stubs in a single package, `types-boto3` promotes a modular approach with separate packages for each AWS service (e.g., `types-boto3-s3`, `types-boto3-lambda`). This reduces dependency footprint and improves type checking performance but requires installing each service individually or using the `[all]` extra.","severity":"gotcha","affected_versions":"1.x.x (mypy-boto3 users migrating to types-boto3)"},{"fix":"Upgrade your Python environment to 3.9 or a newer version to maintain compatibility with the actively maintained `types-boto3` package line.","message":"While `mypy-boto3` version 1.x.x itself requires Python `3.9` or newer, the successor `types-boto3` versions (8.12.0+) have explicitly dropped support for Python 3.8. Ensure your development and deployment environments are running Python 3.9 or newer to be compatible with `types-boto3`.","severity":"gotcha","affected_versions":"1.x.x (mypy-boto3 users considering or undergoing migration)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}