mypy-boto3-fsx type annotations
mypy-boto3-fsx provides PEP 561 compliant type annotations for the AWS FSx service client in boto3. It is part of the larger mypy-boto3-builder project, which frequently releases updates to keep pace with new boto3 versions and AWS service changes. The current version of mypy-boto3-fsx is 1.42.3, corresponding to a specific boto3 version.
Warnings
- breaking Python 3.8 support has been removed in mypy-boto3-builder version 8.12.0. All generated type stub packages, including mypy-boto3-fsx, now require Python 3.9 or higher.
- breaking As of mypy-boto3-builder 8.12.0, all generated packages are now PEP 561 compliant. While this improves standard stub discovery, users relying on older `mypy` configurations or custom stub paths might need to verify their setup.
- gotcha The version of `mypy-boto3-fsx` (e.g., `1.42.3`) should ideally match the version of `boto3` you have installed. Installing a mismatched version can lead to incorrect or missing type definitions, as the stubs are generated specifically for a particular boto3 API version.
- gotcha `mypy-boto3-fsx` provides only type stubs, not a functional client. You must have `boto3` installed for the code to run at runtime. The stubs are only for static type checking.
Install
-
pip install mypy-boto3-fsx boto3 mypy
Imports
- FSxClient
from mypy_boto3_fsx.client import FSxClient
- Client
from mypy_boto3_fsx.client import FSxClient
Quickstart
from typing import TYPE_CHECKING
import boto3
import os
if TYPE_CHECKING:
from mypy_boto3_fsx.client import FSxClient
session = boto3.Session(
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', 'DUMMY_KEY'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', 'DUMMY_SECRET'),
region_name=os.environ.get('AWS_REGION', 'us-east-1')
)
# Instantiate the FSx client with type hinting
fsx_client: FSxClient = session.client("fsx")
# Example usage (runtime check)
try:
response = fsx_client.describe_file_systems()
print("Successfully described FSx file systems (runtime check passed).")
# For type checking purposes, you can inspect 'response' type here
# For example: print(response.get('FileSystems'))
except Exception as e:
print(f"Runtime error during FSx client call: {e}")
# Type checking example (this block is only for mypy)
if TYPE_CHECKING:
# mypy will verify the type of 'fsx_client'
# For example, it will suggest methods like 'create_file_system'
_ = fsx_client.create_file_system
print("FSxClient type definitions available for mypy.")