mypy-boto3-fsx type annotations

1.42.3 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a boto3 FSx client and apply type hints using `mypy-boto3-fsx`. The `if TYPE_CHECKING:` block ensures that the type imports are only processed by static analysis tools like Mypy, preventing runtime overhead or import errors if the stub package isn't installed in the runtime environment. Replace 'DUMMY_KEY' and 'DUMMY_SECRET' with actual AWS credentials for runtime execution.

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.")

view raw JSON →