Registry / type-stubs / mypy-boto3-logs

mypy-boto3-logs

JSON →
library1.43.82pypypi✓ verified 23d ago

mypy-boto3-logs provides static type annotations for the `boto3` CloudWatchLogs service, enhancing code quality and developer experience. It is generated by the `mypy-boto3-builder` project and is compatible with various type checkers like mypy and pyright, as well as IDEs like VSCode and PyCharm. The current version is 1.42.83, with frequent updates aligning with `boto3` releases and builder improvements.

pip install mypy-boto3-logs boto3 mypy
INSTALL
IMPORT
SIG · MYPY-BOTO3-LOGS
M
mypy-boto3-logs
type-stubspythonv1.43.82
Install
6.6s avg
Import
691ms
Disk
82MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.43.82 · 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.716s · 84.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 6.6s · import 0.666s · 82MB
82MB installed
● package 82MB
Code
Verified usage

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

CloudWatchLogsClient
from mypy_boto3_logs.client import CloudWatchLogsClient
from boto3.session import Session; client: Session().client('logs')
Directly importing from boto3 does not provide type hints; the stub package provides the specific client type.
CloudWatchLogsServiceResource
from mypy_boto3_logs.service_resource import CloudWatchLogsServiceResource
Use this for service resources, if available for CloudWatchLogs (less common for logs).
PutLogEventsRequestRequestTypeDef
from mypy_boto3_logs.type_defs import PutLogEventsRequestRequestTypeDef
TypedDicts for request/response bodies are found in type_defs.

This quickstart demonstrates how to obtain a type-hinted CloudWatchLogs client and use it with type-safe operations. The `TYPE_CHECKING` block ensures that `mypy-boto3-logs` is only a development dependency. Replace placeholder credentials with actual AWS configuration for real-world usage.

from typing import TYPE_CHECKING import boto3 if TYPE_CHECKING: from mypy_boto3_logs.client import CloudWatchLogsClient from mypy_boto3_logs.type_defs import PutLogEventsResponseTypeDef def get_logs_client() -> 'CloudWatchLogsClient': """Returns a type-hinted CloudWatchLogs client.""" session = boto3.Session( aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID', ''), aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY', ''), region_name=os.environ.get('AWS_REGION', 'us-east-1') ) return session.client('logs') def put_log_events_example(): """Example of using the type-hinted CloudWatchLogs client.""" client = get_logs_client() response: PutLogEventsResponseTypeDef = client.put_log_events( logGroupName='my-log-group', logStreamName='my-log-stream', logEvents=[ {'timestamp': 1678886400000, 'message': 'Hello from mypy-boto3-logs!'} ] ) print(f"Sequence Token: {response.get('nextSequenceToken')}") if __name__ == '__main__': import os # Set dummy AWS credentials for local testing or ensure they are in env vars # For actual use, configure boto3 credentials securely if not os.environ.get('AWS_ACCESS_KEY_ID'): os.environ['AWS_ACCESS_KEY_ID'] = 'TEST_ACCESS_KEY' os.environ['AWS_SECRET_ACCESS_KEY'] = 'TEST_SECRET_KEY' os.environ['AWS_REGION'] = 'us-east-1' put_log_events_example()
Debug
Known issues
breakingPython 3.8 support has been removed as of `mypy-boto3-builder` version 8.12.0. All `mypy-boto3-*` packages now require Python 3.9 or newer.
fix
Upgrade your Python environment to 3.9 or a newer version.
affects: mypy-boto3-builder >= 8.12.0, mypy-boto3-logs >= 1.42.83
breakingTypeDef naming conventions changed in `mypy-boto3-builder` 8.9.0. Method argument TypeDefs may use shorter names, and conflicting `Extra` postfixes were moved to the end. This may require updating import paths or references to specific TypedDicts.
fix
Refer to the specific service's documentation or use IDE auto-completion to find the updated TypeDef names for requests and responses.
affects: mypy-boto3-builder >= 8.9.0
gotcha`mypy-boto3-*` packages migrated to PEP 561. While beneficial, this might impact older `mypy` configurations. Stub-only packages, per PEP 561, cannot be found via `MYPYPATH` and must be installed directly in the environment `mypy` inspects.
fix
Ensure `mypy-boto3-logs` is installed in the same Python environment used for `mypy` execution. Avoid relying on `MYPYPATH` for these stub packages.
affects: mypy-boto3-builder >= 8.12.0
gotchaPyCharm users may experience slow performance or high CPU usage due to Literal overloads. The `boto3-stubs-lite` packages are recommended as a workaround, or disable PyCharm's internal type checker and use `mypy` or `pyright` instead.
fix
Install `boto3-stubs-lite[logs]` (`pip install 'boto3-stubs-lite[logs]'`) or disable PyCharm's type checking.
affects: All versions with PyCharm
gotchaWhen using `TYPE_CHECKING` for conditional imports, Pylint may incorrectly report undefined variables. A workaround is to assign `object` to the type hints in the non-`TYPE_CHECKING` branch.
fix
Implement the following pattern: `if TYPE_CHECKING: from mypy_boto3_logs.client import CloudWatchLogsClient else: CloudWatchLogsClient = object`
affects: All versions with Pylint
Upgrade
Version history
1.43.82latest on PyPI · released Aug 27, 2026
Audit
Dependencies
boto3requiredProvides the AWS SDK for Python that these stubs annotate.
mypyoptionalThe primary static type checker this library is designed for.
pythonrequiredRequires Python 3.9 or newer.
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
mypy-boto3-logs — pip install mypy-boto3-logs · libregistry