Registry / type-stubs / mypy-boto3-cloudtrail

mypy-boto3-cloudtrail

JSON →
library1.43.0pypypi✓ verified 23d ago

mypy-boto3-cloudtrail provides comprehensive type annotations for the boto3 CloudTrail service, enhancing developer experience with static analysis tools like mypy, pyright, and various IDEs (VSCode, PyCharm). It ensures type-safe interactions with AWS CloudTrail APIs by providing precise type hints for clients, paginators, and service-specific TypedDicts. This package is generated by `mypy-boto3-builder` and is currently at version 1.42.3, following the corresponding boto3 version. New releases are frequent, typically aligning with boto3 updates.

pip install mypy-boto3-cloudtrail
INSTALL
IMPORT
SIG · MYPY-BOTO3-CLOUDTR
M
mypy-boto3-cloudtrail
type-stubspythonv1.43.0
Install
3.4s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.43.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.4s · import 0.000s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CloudTrailClient
from mypy_boto3_cloudtrail import CloudTrailClient
from mypy_boto3_cloudtrail import CloudTrailClient
CloudTrailServiceResource
from mypy_boto3_cloudtrail import CloudTrailServiceResource
Client
from mypy_boto3_cloudtrail import Client

This quickstart demonstrates how to instantiate a boto3 CloudTrail client and use the `mypy-boto3-cloudtrail` type hints for methods and response structures. It includes an example of looking up events and iterating through the typed response. The `TYPE_CHECKING` block ensures that these stub imports are only used by type checkers and not during runtime, making it safe for production.

import boto3 from typing import TYPE_CHECKING, List, Dict, Any if TYPE_CHECKING: from mypy_boto3_cloudtrail.client import CloudTrailClient from mypy_boto3_cloudtrail.type_defs import EventTypeDef, LookupEventsResponseTypeDef def list_cloudtrail_events(client: 'CloudTrailClient') -> List['EventTypeDef']: """Lists recent CloudTrail events with type hints.""" # Example of a typed client call response: 'LookupEventsResponseTypeDef' = client.lookup_events(MaxResults=5) events: List['EventTypeDef'] = response.get('Events', []) for event in events: print(f"Event Name: {event.get('EventName')}, Event ID: {event.get('EventId')}") return events if __name__ == "__main__": # In a real application, credentials would be configured via environment variables, ~/.aws/credentials, etc. # For this example, we assume default configuration. boto_session = boto3.Session() # The type hint here ensures static analysis tools understand the client's methods and return types cloudtrail_client: 'CloudTrailClient' = boto_session.client('cloudtrail') print("Listing CloudTrail events (first 5):") try: listed_events = list_cloudtrail_events(cloudtrail_client) if not listed_events: print("No events found.") except Exception as e: print(f"Error listing events: {e}")
Debug
Known issues
breakingSupport for Python 3.8 and older was removed in `mypy-boto3-builder` version 8.12.0. All generated `mypy-boto3-*` packages, including `mypy-boto3-cloudtrail`, now require Python >= 3.9.
fix
Upgrade your Python environment to 3.9 or newer.
affects: >=8.12.0 (builder), >=1.42.0 (stubs)
breakingIn `mypy-boto3-builder` 8.9.0, there were changes to how TypeDef names are generated, specifically for packed method arguments (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`) and conflicting `Extra` postfixes (`CreateDistributionExtraRequestTypeDef` to `CreateDistributionRequestExtraTypeDef`). While `cloudtrail` specific types might not match these exact examples, similar renamings could apply to other service `TypeDef`s.
fix
Review your `TypeDef` imports and usage after upgrading, as some names might have been shortened or reordered. Consult the `mypy-boto3` documentation for specific services.
affects: >=8.9.0 (builder)
gotchaPyCharm users might experience slow performance with Literal overloads (issue PY-40997). The recommendation is to use `boto3-stubs-lite` (e.g., `pip install 'boto3-stubs-lite[cloudtrail]'`) or disable PyCharm's internal type checker and rely on `mypy` or `pyright`.
fix
Install `boto3-stubs-lite[cloudtrail]` instead of `boto3-stubs[cloudtrail]` or `mypy-boto3-cloudtrail` if performance is an issue in PyCharm, or configure your IDE to use an external type checker.
affects: All versions with PyCharm
gotchaWhen using `TYPE_CHECKING` blocks for conditional imports to avoid runtime dependencies (common for stub packages), Pylint might complain about undefined variables. To fix this, set variables inside the `TYPE_CHECKING` block to `object` in the `else` branch.
fix
Wrap your type-hinted variable declarations with an `if TYPE_CHECKING:` block and assign `object` in the `else` branch, as shown in the quickstart example (e.g., `if TYPE_CHECKING: from mypy_boto3_cloudtrail.client import CloudTrailClient else: CloudTrailClient = object`).
affects: All versions with Pylint
breakingThe `mypy-boto3-builder` migrated to PEP 561 compliant packages in version 8.12.0. While designed to be backward compatible for standard usage, this fundamental change in packaging type information might affect highly customized build systems or older `mypy`/`pip` versions that relied on pre-PEP 561 behavior.
fix
Ensure your `pip` and `mypy` versions are up-to-date. If encountering issues with type discovery in complex environments, verify the `py.typed` marker file is correctly recognized by your tooling.
affects: >=8.12.0 (builder), >=1.42.0 (stubs)
Upgrade
Version history
1.43.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
boto3requiredRuntime dependency for AWS SDK functionality, `mypy-boto3-cloudtrail` provides type stubs for it.
mypyoptionalPrimary static type checker to leverage these annotations.
typing-extensionsoptionalRequired for some type features on older Python versions, though typically handled automatically by `boto3-stubs`'s `install_requires`.
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
mypy-boto3-cloudtrail — pip install mypy-boto3-cloudtrail · libregistry