Registry / type-stubs / types-cryptography

types-cryptography

JSON →
library3.3.23.2pypypi✓ verified 25d ago

This package provides static type checking stubs for the `cryptography` library, enabling tools like MyPy to verify type correctness in Python code that uses `cryptography`. It is part of the broader Typeshed project, which maintains a repository of type stubs for many popular Python libraries. As of this entry, the current version is 3.3.23.2, with updates typically following `cryptography` releases.

pip install types-cryptography
INSTALL
IMPORT
SIG · TYPES-CRYPTOGRAPHY
T
types-cryptography
type-stubspythonv3.3.23.2
Install
1.6s 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 v3.3.23.2 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

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

Fernet
from cryptography.fernet import Fernet
from cryptography-stubs.fernet import Fernet

This quickstart demonstrates a basic usage of the `cryptography` library. `types-cryptography` is installed to allow static type checkers like MyPy to verify the type correctness of this code. After installing `cryptography`, `types-cryptography`, and `mypy`, you can run `mypy <your_script_name>.py` to check for type errors.

import os from cryptography.fernet import Fernet # Example usage of cryptography, for which types-cryptography provides stubs key = Fernet.generate_key() f = Fernet(key) message: bytes = b"my secret data" encrypted_message: bytes = f.encrypt(message) decrypted_message: bytes = f.decrypt(encrypted_message) print(f"Original: {message}") print(f"Encrypted: {encrypted_message}") print(f"Decrypted: {decrypted_message}") # To type-check this file: # 1. pip install cryptography types-cryptography mypy # 2. mypy your_script_name.py
Debug
Known issues
gotcha`types-cryptography` only provides type hints. You *must* install the actual `cryptography` library (`pip install cryptography`) for your code to run.
fix
Ensure both `cryptography` and `types-cryptography` are installed in your environment.
affects: All versions
gotchaDo not attempt to import symbols directly from `types_cryptography` or `cryptography-stubs`. This package is purely for type checkers and does not expose runtime objects. Imports should always be from `cryptography` itself.
fix
Always import from `cryptography` (e.g., `from cryptography.fernet import Fernet`). Type checkers will automatically discover the stubs provided by `types-cryptography`.
affects: All versions
gotchaThe version of `types-cryptography` might not always be perfectly in sync with the very latest release of `cryptography`. This can occasionally lead to minor type checking errors (e.g., missing attributes for newly added features) until the stubs are updated.
fix
If you encounter type errors for new `cryptography` features, check for an updated `types-cryptography` version or consider using `type: ignore` comments as a temporary workaround until stubs are released.
affects: All versions, especially with new `cryptography` releases
Upgrade
Version history
3.3.23.2latest on PyPI · released Nov 8, 2022
Audit
Dependencies
cryptographyrequiredThis package provides type hints for the `cryptography` library; `cryptography` itself must be installed to run the code you are type-checking.
Agent activity
39 hits · last 30 days
node
30
OpenAI (training)
1
Resources
types-cryptography — pip install types-cryptography · libregistry