Registry / type-stubs / types-zstd

types-zstd

JSON →
library1.5.7.3.20260408pypypiunverified

The `types-zstd` library provides static type annotations for the `python-zstandard` compression library, enabling type checkers like MyPy to validate the correct usage of `zstd` in Python projects. It is part of the `typeshed` project, which regularly updates stubs to reflect changes in popular Python libraries and new Python versions. The current version is 1.5.7.3.20260408.

pip install types-zstd
INSTALL
IMPORT
SIG · TYPES-ZSTD
T
types-zstd
type-stubspythonv1.5.7.3.20260408
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.7.3.20260408 · 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 · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

zstd-stubs
import zstd_stubs
import zstd-stubs

This quickstart demonstrates how to use the `zstd` library (from `python-zstandard`) with type hints. Installing `types-zstd` allows type checkers like MyPy to validate the arguments and return types of these `zstd` calls, catching potential errors before runtime. Remember to install `python-zstandard` for the runtime functionality.

import zstd from typing import Optional # Ensure python-zstandard is installed: pip install python-zstandard def compress_data(data: bytes, level: Optional[int] = None) -> bytes: """Compresses bytes using zstd.""" if level is not None: return zstd.compress(data, level) return zstd.compress(data) def decompress_data(compressed_data: bytes) -> bytes: """Decompresses bytes using zstd.""" return zstd.decompress(compressed_data) if __name__ == '__main__': original_data = b"This is some data to be compressed by zstd! " * 100 # Use type-checked functions compressed = compress_data(original_data, level=3) decompressed = decompress_data(compressed) print(f"Original size: {len(original_data)} bytes") print(f"Compressed size: {len(compressed)} bytes") print(f"Decompressed matches original: {original_data == decompressed}") # Example of using the streaming API (also type-checked) compressor = zstd.ZstdCompressor(level=1) decompressor = zstd.ZstdDecompressor() with compressor.stream_writer() as writer: writer.write(b"Hello ") writer.write(b"World!") compressed_stream = writer.read() with decompressor.stream_reader(compressed_stream) as reader: decompressed_stream = reader.read() print(f"Stream compression works: {decompressed_stream == b'Hello World!'}")
Debug
Known issues
gotcha`types-zstd` only provides type hints; it does not install the actual `zstd` compression library. For runtime functionality, you must install `python-zstandard` separately.
fix
Ensure you run `pip install python-zstandard` in addition to `pip install types-zstd`.
affects: All versions
gotchaTo benefit from `types-zstd`, you need a static type checker (e.g., MyPy) configured to analyze your Python code. Without a type checker, the stubs have no effect.
fix
Install and configure a type checker (e.g., `pip install mypy`) and run it (e.g., `mypy your_script.py`) on your project.
affects: All versions
breakingIf the underlying `python-zstandard` library introduces significant API changes, `types-zstd` will eventually be updated to reflect these changes. This might cause type errors in your existing code if it relies on an older `zstd` API but you've updated `types-zstd`.
fix
Keep `types-zstd` and `python-zstandard` versions in sync, or pin specific versions that are known to be compatible. Review `python-zstandard` release notes for breaking changes and adapt your code accordingly.
affects: Dependent on `python-zstandard` API changes
Upgrade
Version history
1.5.7.3.20260408latest on PyPI · released Apr 8, 2026
Audit
Dependencies
python-zstandardrequiredProvides the actual zstd compression/decompression functionality that these stubs type-check. `types-zstd` is only for type hints, not runtime functionality.
Agent activity
34 hits · last 30 days
node
30
OpenAI (training)
1
Resources
types-zstd — pip install types-zstd · libregistry