mypy-boto3-trustedadvisor Type Stubs
mypy-boto3-trustedadvisor provides type annotations for the boto3 TrustedAdvisorPublicAPI service, ensuring static type checking and improved IDE autocomplete for AWS Trusted Advisor operations. It is generated by the mypy-boto3-builder, which frequently releases updates to keep pace with new boto3 versions and service changes, often on a weekly or bi-weekly cadence.
Warnings
- breaking Support for Python 3.8 was removed in mypy-boto3-builder version 8.12.0, which generated this stub. Users on Python 3.8 will need to upgrade their Python version to 3.9 or newer.
- breaking The mypy-boto3-builder migrated to PEP 561 compliant packages in version 8.12.0. This change affects how type checkers resolve modules and might require updates to mypy configuration or development environment setups, especially when mixing older and newer stub versions.
- breaking Beginning with mypy-boto3-builder 8.9.0, TypeDef naming conventions were changed. Arguments like `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`, and `Extra` postfixes moved (`CreateDistributionExtraRequestTypeDef` to `CreateDistributionRequestExtraTypeDef`). This affects all generated service stubs, including Trusted Advisor.
- gotcha PyCharm might experience slow performance with Literal overloads when using boto3-stubs. It is recommended to use `boto3-stubs-lite` if performance issues are encountered. Alternatively, disable PyCharm's internal type checker and rely on external tools like mypy or pyright.
- gotcha For standalone packages like `mypy-boto3-trustedadvisor`, explicit type annotations are often required for `boto3.client` calls to leverage the type stubs effectively. Automatic type discovery may not work without the full `boto3-stubs` umbrella package.
- gotcha Service names within the AWS ecosystem can be renamed or deprecated (e.g., `sms-voice` to `pinpoint-sms-voice` in older releases of mypy-boto3-builder). While not specific to TrustedAdvisor, this pattern means users should be aware that the corresponding stub package name might change in the future if AWS renames the service.
Install
-
pip install mypy-boto3-trustedadvisor -
pip install 'boto3-stubs[trustedadvisor]'
Imports
- TrustedAdvisorPublicAPIClient
from mypy_boto3_trustedadvisor.client import TrustedAdvisorPublicAPIClient
Quickstart
import boto3
from mypy_boto3_trustedadvisor.client import TrustedAdvisorPublicAPIClient
from mypy_boto3_trustedadvisor.type_defs import DescribeAccountRecommendationsResponseTypeDef
def get_trustedadvisor_client() -> TrustedAdvisorPublicAPIClient:
# Assuming AWS credentials are configured (e.g., via environment variables, ~/.aws/credentials)
session = boto3.session.Session()
client: TrustedAdvisorPublicAPIClient = session.client('trustedadvisor')
return client
if __name__ == '__main__':
trustedadvisor_client = get_trustedadvisor_client()
# Example API call with type hints
response: DescribeAccountRecommendationsResponseTypeDef = trustedadvisor_client.describe_account_recommendations()
print(response)