{"id":4458,"library":"boto3-stubs-lite","title":"boto3-stubs-lite","description":"boto3-stubs-lite provides lightweight type annotations for the boto3 library (version 1.42.88 at time of writing), generated by mypy-boto3-builder. It enhances static analysis for boto3 code without requiring installation of full service-specific stub packages, receiving frequent updates aligned with boto3 and mypy-boto3-builder releases.","status":"active","version":"1.42.88","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","type hints","mypy","static analysis","cloud"],"install":[{"cmd":"pip install boto3-stubs-lite","lang":"bash","label":"Install core stubs"}],"dependencies":[{"reason":"Provides type annotations for the boto3 library.","package":"boto3","optional":false},{"reason":"Required for Python versions prior to 3.11 for certain type features.","package":"typing-extensions","optional":true}],"imports":[{"note":"boto3-stubs-lite provides type annotations for standard boto3 imports and methods. No direct imports from 'boto3-stubs-lite' are made at runtime.","symbol":"Session","correct":"import boto3\nsession = boto3.session.Session()"},{"note":"boto3-stubs-lite makes standard boto3 clients and their methods type-checked. For full, service-specific type definitions (e.g., S3Client), consider `mypy-boto3-s3` within a `TYPE_CHECKING` block.","symbol":"Client","correct":"import boto3\ns3_client = boto3.client('s3')"}],"quickstart":{"code":"import boto3\nimport os\n\n# boto3-stubs-lite provides type hints for this standard boto3 usage\nsession = boto3.session.Session(\n    aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),\n    aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),\n    region_name=os.environ.get('AWS_REGION', 'us-east-1')\n)\n\ns3_client = session.client('s3')\n\ntry:\n    # This call is type-checked by boto3-stubs-lite\n    response = s3_client.list_buckets()\n    print(f\"Successfully listed {len(response.get('Buckets', []))} buckets.\")\nexcept Exception as e:\n    print(f\"Error listing buckets: {e}\")\n\n# Example of using a resource (also typed)\n# s3_resource = session.resource('s3')\n# bucket = s3_resource.Bucket('my-example-bucket')\n# print(f\"Bucket name: {bucket.name}\")\n","lang":"python","description":"This quickstart demonstrates basic boto3 client usage. When `boto3-stubs-lite` is installed, type checkers like MyPy will provide type hints and error checking for `session`, `s3_client`, and their methods, even without explicit type imports."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or higher.","message":"Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0 (which generates `boto3-stubs-lite`). Users on Python 3.8 will need to upgrade to Python 3.9 or newer.","severity":"breaking","affected_versions":">=8.12.0"},{"fix":"Migrate your code to use the `pinpoint-sms-voice` client instead of `sms-voice`.","message":"The `sms-voice` AWS service was removed in `mypy-boto3-builder` version 8.11.0. Its functionality has been replaced by `pinpoint-sms-voice`.","severity":"breaking","affected_versions":">=8.11.0"},{"fix":"If you require detailed TypedDicts and comprehensive type checking for specific AWS services, install the corresponding `mypy-boto3-servicename` package (e.g., `pip install mypy-boto3-s3`) and use its types within `if TYPE_CHECKING:` blocks.","message":"boto3-stubs-lite provides 'lite' type annotations. This means complex TypedDicts for request/response parameters might be simplified or represented as `Any`. For comprehensive, service-specific type definitions with full detail, install `mypy-boto3-servicename` packages (e.g., `mypy-boto3-s3`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Only import types from `mypy_boto3_*` packages within `if TYPE_CHECKING:` blocks, or rely on `boto3-stubs-lite` to provide the base type information implicitly to your type checker.","message":"Attempting to import types from `mypy_boto3_servicename` (e.g., `from mypy_boto3_s3.client import S3Client`) outside of `if TYPE_CHECKING:` blocks for runtime use will result in `ModuleNotFoundError`, as these modules only contain type stubs, not executable code.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}