mypy-boto3-iotfleetwise type stubs
mypy-boto3-iotfleetwise provides type annotations for the `boto3` AWS IoT FleetWise service, ensuring static type checking with tools like `mypy` and enhancing IDE auto-completion for `boto3` clients. It is currently at version 1.42.3, in sync with `boto3` releases, and is generated by `mypy-boto3-builder 8.12.0` which has a frequent release cadence, often aligning with new `boto3` versions.
Warnings
- breaking Python 3.8 support was removed for all `mypy-boto3` stub packages, including `mypy-boto3-iotfleetwise`, starting with `mypy-boto3-builder` version 8.12.0. Users on Python 3.8 must upgrade to Python 3.9+ or pin an older version of the stub package.
- breaking `mypy-boto3` packages migrated to PEP 561 compliant distribution in `mypy-boto3-builder` version 8.12.0. While this improves standard compatibility, users with highly customized `mypy` configurations or unusual import patterns might need to adjust their setup.
- breaking TypeDef naming conventions were changed in `mypy-boto3-builder` version 8.9.0. This includes shortening some TypeDef names (e.g., `CreateDistributionRequestRequestTypeDef` to `CreateDistributionRequestTypeDef`) and moving postfixes (e.g., `CreateDistributionExtraRequestTypeDef` to `CreateDistributionRequestExtraTypeDef`). Code explicitly importing or referencing these `TypedDict` names will break.
- gotcha These packages provide only type stubs for `boto3`; they do not include the `boto3` runtime library itself. `boto3` must be installed separately for your Python code to execute successfully.
- gotcha For optimal type inference and auto-completion, especially in certain IDEs (e.g., older VS Code setups) or when using `boto3-stubs-lite`, explicit type annotations for `boto3.client()` and `boto3.session.client()` calls are recommended.
Install
-
pip install mypy-boto3-iotfleetwise boto3
Imports
- IoTFleetWiseClient
from mypy_boto3_iotfleetwise.client import IoTFleetWiseClient
- CreateFleetRequestTypeDef
from mypy_boto3_iotfleetwise.type_defs import CreateFleetRequestTypeDef
Quickstart
import boto3
from mypy_boto3_iotfleetwise.client import IoTFleetWiseClient
from mypy_boto3_iotfleetwise.type_defs import CreateFleetRequestTypeDef, CreateFleetResponseTypeDef
def create_iot_fleet(fleet_id: str, fleet_description: str, tags: list[dict]) -> CreateFleetResponseTypeDef:
client: IoTFleetWiseClient = boto3.client("iotfleetwise")
request_payload: CreateFleetRequestTypeDef = {
"fleetId": fleet_id,
"description": fleet_description,
"tags": tags,
}
try:
response: CreateFleetResponseTypeDef = client.create_fleet(**request_payload)
print(f"Successfully created fleet: {response['fleetArn']}")
return response
except client.exceptions.ConflictException:
print(f"Fleet '{fleet_id}' already exists.")
# Handle the case where the fleet already exists, e.g., get its details
return client.get_fleet(fleetId=fleet_id)
except Exception as e:
print(f"Error creating fleet: {e}")
raise
# Example usage (requires AWS credentials configured)
# Replace with actual desired values
# try:
# fleet_response = create_iot_fleet(
# fleet_id="my-example-fleet",
# fleet_description="Fleet for testing purposes",
# tags=[{"key": "Environment", "value": "Dev"}]
# )
# print(f"Fleet details: {fleet_response}")
# except Exception as e:
# print(f"An error occurred: {e}")