Install & Compatibility
Where this runs
tested against v1.43.27 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.770s · 117.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 6.0s · import 0.696s · 115MB
115MB installed
● package 115MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
LightsailClient
✓ from mypy_boto3_lightsail.client import LightsailClient
CreateDistributionRequestTypeDef
✓ from mypy_boto3_lightsail.type_defs import CreateDistributionRequestTypeDef
boto3.client('lightsail')
✓
✗ client = boto3.client('lightsail')
Without explicit type annotation, static type checkers cannot infer the specific LightsailClient type, limiting autocompletion and error checking. Always add a type hint: `client: LightsailClient = boto3.client('lightsail')`.
This quickstart demonstrates how to use `mypy-boto3-lightsail` to add type hints for the Lightsail client and its response types. It includes a `TYPE_CHECKING` guard for runtime compatibility and shows how to retrieve Lightsail distributions with type safety. Remember to have AWS credentials configured for actual execution.
import boto3
from typing import TYPE_CHECKING
from mypy_boto3_lightsail.client import LightsailClient
from mypy_boto3_lightsail.type_defs import GetDistributionsResultTypeDef
import os
# Ensure boto3 is installed: pip install boto3 mypy-boto3-lightsail
if TYPE_CHECKING:
# This block is only processed by type checkers
client: LightsailClient = boto3.client("lightsail")
else:
# This block runs at runtime
client = boto3.client("lightsail")
def get_lightsail_distributions() -> GetDistributionsResultTypeDef:
try:
response = client.get_distributions()
print(f"Successfully retrieved {len(response.get('distributions', []))} distributions.")
return response
except Exception as e:
print(f"Error retrieving Lightsail distributions: {e}")
raise
if __name__ == "__main__":
# Make sure your AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars)
# For a quick local test without actual AWS interaction, you can mock boto3 or ensure credentials are set.
# Example of calling the function:
# distributions = get_lightsail_distributions()
# if distributions:
# for dist in distributions.get('distributions', []):
# print(f" Distribution: {dist.get('name')}, Status: {dist.get('status')}")
print("Quickstart example set up. Run `mypy <filename>.py` for type checking.")
print("To execute, uncomment `get_lightsail_distributions()` call and ensure AWS credentials are set.")
Debug
Known issues
breakingPython 3.8 support has been removed for `mypy-boto3-builder` (which generates `mypy-boto3-lightsail`) and its generated packages.fixUpgrade your Python environment to version 3.9 or higher.
affects: mypy-boto3-builder 8.12.0+ and subsequently generated mypy-boto3-* packages.
breakingThe naming convention for `TypeDef` objects was changed, potentially leading to import or name resolution errors if you explicitly imported them.fixReview and update `TypeDef` imports and names in your code. For example, `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`.
affects: mypy-boto3-builder 8.9.0+ and subsequently generated mypy-boto3-* packages.
gotchaInstalling `mypy-boto3-lightsail` only provides type stubs. The actual `boto3` library is still required at runtime to interact with AWS services.fixEnsure `pip install boto3` is part of your project's dependencies.
affects: All versions
gotchaFor comprehensive type checking across multiple AWS services, consider installing `boto3-stubs[full]` or specific `boto3-stubs` extras (e.g., `boto3-stubs[lightsail]`) instead of individual `mypy-boto3-*` packages, as `mypy-boto3-lightsail` only covers the Lightsail service.fixAssess your type checking needs: use `pip install boto3-stubs[full]` for all services or `pip install 'boto3-stubs[lightsail]'` for service-specific coverage with integrated overloads.
affects: All versions
gotchaWhen using Pylint with type hints inside `if TYPE_CHECKING:` blocks, Pylint might report `undefined variable` errors at runtime. This is due to Pylint not always correctly interpreting the `TYPE_CHECKING` guard.fixImplement a runtime fallback: `if TYPE_CHECKING: from mypy_boto3_lightsail.client import LightsailClient else: LightsailClient = object`
affects: All versions
Upgrade
Version history
1.43.27latest on PyPI · released Jun 10, 2026
Audit
Dependencies
boto3requiredProvides the actual AWS SDK runtime functionality; mypy-boto3-lightsail only provides type stubs.
mypyrequiredThe static type checker that utilizes these type stubs.
typing-extensionsoptionalRequired for some type features on older Python versions (pre-3.9), though typically auto-managed.