{"id":5532,"library":"types-boto","title":"Type Stubs for Boto (AWS SDK v2)","description":"types-boto provides static type annotations for the `boto` library (version 2.x), enabling type checkers like MyPy to validate `boto` code. It is part of the community-driven `typeshed` project and is updated regularly to match `boto`'s API, though `boto` itself is an older AWS SDK. The current version is 2.49.18.20241019, with its release cadence following `typeshed`'s updates.","status":"active","version":"2.49.18.20241019","language":"en","source_language":"en","source_url":"https://github.com/python/typeshed","tags":["typing","stubs","boto","aws","type-hints"],"install":[{"cmd":"pip install types-boto","lang":"bash","label":"Install types-boto"}],"dependencies":[{"reason":"Runtime library for which types-boto provides stubs. The stubs themselves don't have a hard runtime dependency, but are useless without boto installed.","package":"boto","optional":false}],"imports":[{"note":"`types-boto` provides static type hints for symbols from the `boto` library. It does not provide any symbols for direct runtime import.","symbol":"S3Connection","correct":"from boto.s3.connection import S3Connection"}],"quickstart":{"code":"import os\nimport boto.s3.connection\nimport boto.ec2.connection\n\n# types-boto provides type hints for these objects,\n# allowing type checkers like MyPy to validate your code.\n\n# Credentials should ideally come from environment variables or a secure configuration.\n# For a runnable example, we use os.environ.get with placeholders.\naws_access_key = os.environ.get('AWS_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY_GOES_HERE')\naws_secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY', 'YOUR_SECRET_KEY_GOES_HERE')\n\ntry:\n    # Example: S3 connection with type hint from types-boto\n    s3_conn: boto.s3.connection.S3Connection = boto.s3.connection.S3Connection(\n        aws_access_key_id=aws_access_key,\n        aws_secret_access_key=aws_secret_key\n    )\n    print(f\"S3 connection created (type checked by types-boto): {s3_conn}\")\n\n    # Example: EC2 connection with type hint from types-boto\n    ec2_conn: boto.ec2.connection.EC2Connection = boto.ec2.connection.EC2Connection(\n        aws_access_key_id=aws_access_key,\n        aws_secret_access_key=aws_secret_key\n    )\n    print(f\"EC2 connection created (type checked by types-boto): {ec2_conn}\")\n\n    # In a real application, you would perform operations here, e.g.:\n    # buckets = s3_conn.get_all_buckets()\n    # print(f\"Found {len(buckets)} S3 buckets.\")\n\nexcept Exception as e:\n    print(f\"Failed to create boto connections. Ensure 'boto' is installed and credentials are set: {e}\")\n    print(\"Note: types-boto only provides type hints, it does not enable runtime functionality.\")","lang":"python","description":"This quickstart demonstrates importing and instantiating `boto` (v2) connections. `types-boto` provides the type hints for `boto.s3.connection.S3Connection` and `boto.ec2.connection.EC2Connection`, enabling static type checkers to validate your code. Remember to replace placeholder credentials with actual ones or environment variables."},"warnings":[{"fix":"For `boto3` projects, use `pip install types-boto3`.","message":"`types-boto` provides stubs for the older `boto` library (version 2.x). If you are using the modern AWS SDK for Python (`boto3`), you should install `types-boto3` instead.","severity":"gotcha","affected_versions":"All versions of `types-boto`"},{"fix":"Integrate a type checker (e.g., `mypy`) into your development workflow and configure it to check your project.","message":"This library provides static type hints only. It does not add any runtime functionality or change how `boto` behaves at execution. A type checker like MyPy or pyright is required to utilize these stubs for code validation.","severity":"gotcha","affected_versions":"All versions of `types-boto`"},{"fix":"For new development, consider migrating to `boto3` and using `types-boto3`. For existing projects, be aware that `boto` receives minimal updates.","message":"The `boto` library itself (version 2.x), for which `types-boto` provides stubs, is considered legacy. AWS recommends `boto3` for new development. While `types-boto` helps maintain older `boto` code, new projects should generally use `boto3`.","severity":"deprecated","affected_versions":"All versions of `types-boto` (reflects status of underlying `boto` library)"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}