mypy-boto3-iot-jobs-data Type Annotations
mypy-boto3-iot-jobs-data provides type annotations for the `boto3` IoTJobsDataPlane service. It aims to enhance development experience by enabling static type checking with tools like MyPy, PyRight, and improved autocomplete in IDEs such as VSCode and PyCharm. The library is actively maintained, with frequent updates tied to new releases of `mypy-boto3-builder`, ensuring compatibility with the latest `boto3` versions. [3, 4, 7]
Warnings
- breaking Support for Python 3.8 has been removed in `mypy-boto3-builder` version 8.12.0 and subsequent generated packages. Projects targeting `mypy-boto3-iot-jobs-data` must use Python 3.9 or newer.
- breaking Type definition (TypeDef) names for packed method arguments were shortened, and conflicting 'Extra' postfixes were moved. This can break code that explicitly imports or references these TypeDefs by their old names.
- gotcha PyCharm users may experience slow performance or high CPU usage due to `Literal` overloads in `mypy-boto3` packages. This is a known issue (PY-40997).
- gotcha While `mypy-boto3` aims for implicit type discovery, explicit type annotations for `boto3.client()` calls (e.g., `client: IoTJobsDataPlaneClient = boto3.client(...)`) are often necessary for optimal code completion and type checking in IDEs like VSCode and PyCharm.
Install
-
pip install mypy-boto3-iot-jobs-data boto3
Imports
- IoTJobsDataPlaneClient
from mypy_boto3_iot_jobs_data.client import IoTJobsDataPlaneClient
- DescribeJobExecutionResponseTypeDef
from mypy_boto3_iot_jobs_data.type_defs import DescribeJobExecutionResponseTypeDef
Quickstart
import boto3
from typing import TYPE_CHECKING
from mypy_boto3_iot_jobs_data.client import IoTJobsDataPlaneClient
from mypy_boto3_iot_jobs_data.type_defs import DescribeJobExecutionResponseTypeDef
# Boto3 client without type annotations
# client = boto3.client("iot-jobs-data")
# Boto3 client with explicit type annotations for better IDE support and static analysis
if TYPE_CHECKING:
client: IoTJobsDataPlaneClient = boto3.client("iot-jobs-data")
else:
client = boto3.client("iot-jobs-data")
try:
# Example: Describe a job execution
job_id = "your-job-id"
thing_name = "your-thing-name"
# The response object will be implicitly typed due to the client annotation
response: DescribeJobExecutionResponseTypeDef = client.describe_job_execution(
jobId=job_id,
thingName=thing_name
)
print(f"Job Execution Status: {response.get('execution', {}).get('status')}")
except client.exceptions.ResourceNotFoundException:
print(f"Job execution for Job ID '{job_id}' and Thing Name '{thing_name}' not found.")
except Exception as e:
print(f"An error occurred: {e}")