mypy-boto3-appstream Type Annotations
mypy-boto3-appstream provides comprehensive type annotations for the `boto3` AWS AppStream service, enhancing static analysis with tools like Mypy, Pyright, VSCode, and PyCharm. It is automatically generated by the `mypy-boto3-builder` and aims to keep pace with `boto3` updates, typically releasing new versions in alignment with `boto3`'s release cadence. The current version is 1.42.82.
Warnings
- breaking Support for Python 3.8 was removed from `mypy-boto3-builder` (which generates these stubs). Using `mypy-boto3-appstream` with Python 3.8 will no longer receive updates or guaranteed compatibility.
- breaking Type definition (TypeDef) names for packed method arguments may have changed for some services, using shorter names (e.g., `CreateDistributionRequestRequestTypeDef` -> `CreateDistributionRequestTypeDef`). While not specific to `AppStream` in the reported changes, this indicates a pattern for future breaking changes across services.
- gotcha For Pylint compatibility, if you use `mypy-boto3` stubs with `pylint`, you might encounter false positives (e.g., undefined variables). It is recommended to wrap stub imports or type assignments in a `TYPE_CHECKING` block to avoid these errors in runtime code.
- gotcha While PyCharm and Mypy often automatically discover types for `boto3.client()` calls, VSCode users might need to explicitly annotate the client variable for full auto-completion and type inference support.
Install
-
pip install mypy-boto3-appstream boto3 -
pip install 'boto3-stubs[appstream]' boto3
Imports
- AppStreamClient
from mypy_boto3_appstream import AppStreamClient
- AccessEndpointTypeDef
from mypy_boto3_appstream.type_defs import AccessEndpointTypeDef
- AccessEndpointTypeType
from mypy_boto3_appstream.literals import AccessEndpointTypeType
- FleetStartedWaiter
from mypy_boto3_appstream.waiter import FleetStartedWaiter
Quickstart
import boto3
from mypy_boto3_appstream import AppStreamClient
from mypy_boto3_appstream.type_defs import DescribeFleetsResultTypeDef
def get_appstream_fleets() -> DescribeFleetsResultTypeDef:
client: AppStreamClient = boto3.client('appstream')
response = client.describe_fleets()
print(f"Found {len(response['Fleets'])} AppStream fleets.")
return response
if __name__ == '__main__':
# This quickstart assumes AWS credentials are configured (e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION_NAME env vars)
# or ~/.aws/credentials and ~/.aws/config files.
# Replace with actual usage or mock for testing if needed.
# Example of using environment variables for auth (for demonstration, actual auth depends on boto3 setup):
# import os
# if not os.environ.get('AWS_ACCESS_KEY_ID'):
# os.environ['AWS_ACCESS_KEY_ID'] = 'AKIA...'
# if not os.environ.get('AWS_SECRET_ACCESS_KEY'):
# os.environ['AWS_SECRET_ACCESS_KEY'] = 'secret...'
# if not os.environ.get('AWS_REGION_NAME'):
# os.environ['AWS_REGION_NAME'] = 'us-east-1'
try:
fleets_data = get_appstream_fleets()
# Further processing with type-hinted data, e.g., fleets_data['Fleets'][0]['DisplayName']
except Exception as e:
print(f"Error fetching AppStream fleets: {e}")