mypy-boto3-fis
mypy-boto3-fis provides comprehensive type annotations for the AWS FIS (Fault Injection Service) client in boto3. It is part of the `boto3-stubs` ecosystem, actively generated and maintained by `mypy-boto3-builder` (version 8.12.0), with frequent releases that align with boto3 updates to ensure up-to-date type checking capabilities for Python >=3.9.
Warnings
- breaking Support for Python 3.8 was removed in `mypy-boto3-builder` version 8.12.0, affecting all generated `mypy-boto3-*` packages. Ensure your projects use Python 3.9 or higher.
- breaking TypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Specifically, redundant `Request` postfixes were removed (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`), and `Extra` postfixes moved to the end of the name. This impacts imports and usage of generated TypeDefs.
- gotcha For optimal IDE autocomplete and `mypy` checks, explicitly type-annotate `boto3.client()` and `boto3.session.client()` calls with the imported client type (e.g., `client: FISClient = boto3.client('fis')`). While `mypy` often auto-discovers types, explicit hints provide the best experience across all tools.
- gotcha The `mypy-boto3-fis` package provides type stubs, but `mypy` itself (the static type checker) is not a dependency and must be installed and configured separately in your project.
- gotcha When integrating with tools like Pylint, it's recommended to guard stub imports using `if TYPE_CHECKING:` to avoid runtime dependencies in production, as Pylint might otherwise complain about undefined variables if the stubs are not present at runtime.
- gotcha PyCharm has known performance issues with `Literal` overloads. If you experience slow performance, consider using the `boto3-stubs-lite` version (e.g., `pip install 'boto3-stubs-lite[fis]'`), which is more RAM-friendly but requires more explicit type annotations.
Install
-
pip install mypy-boto3-fis -
pip install 'boto3-stubs[fis]'
Imports
- FISClient
from mypy_boto3_fis import FISClient
- ListExperimentTemplatesPaginator
from mypy_boto3_fis.paginator import ListExperimentTemplatesPaginator
- ActionParameterTypeDef
from mypy_boto3_fis.type_defs import ActionParameterTypeDef
- AccountTargetingType
from mypy_boto3_fis.literals import AccountTargetingType
Quickstart
import boto3
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from mypy_boto3_fis import FISClient
from mypy_boto3_fis.type_defs import ListExperimentsOutputTypeDef
# Example of a TypedDict for a specific request parameter
from mypy_boto3_fis.type_defs import ExperimentTemplateSummaryTypeDef
def list_fis_experiments() -> list['ExperimentTemplateSummaryTypeDef']:
client: FISClient = boto3.client('fis')
response: ListExperimentsOutputTypeDef = client.list_experiments()
return response.get('experimentSummaries', [])
# Example usage (will not be type-checked at runtime by mypy-boto3-fis)
if __name__ == "__main__":
try:
experiments = list_fis_experiments()
print(f"Found {len(experiments)} FIS experiments.")
for experiment in experiments:
print(f" - {experiment.get('id')}: {experiment.get('state', {}).get('status')}")
except Exception as e:
print(f"Error listing FIS experiments: {e}")