Registry / type-stubs / types-pyjwt

types-pyjwt

JSON →
library1.7.1pypypiunverified

types-pyjwt is a PEP 561 compliant type stub package providing static type annotations for the PyJWT library. It enables type-checking tools like MyPy, Pyright, and PyCharm to perform static analysis on code using PyJWT. The package itself is auto-generated from the community-maintained typeshed repository. As of PyPI version 1.7.1, it has not seen updates since mid-2021, as the upstream PyJWT library started including its own type annotations from version 2.0.0 onwards.

pip install types-pyjwt
INSTALL
IMPORT
SIG · TYPES-PYJWT
T
types-pyjwt
type-stubspythonv1.7.1
Install
1.6s avg
Import
—
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.7.1 · 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.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibc
py 3.10–3.910 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.

jwt-stubs
✓ import jwt_stubs
✗ import jwt-stubs

This quickstart demonstrates a basic usage of PyJWT with type hints. When types-pyjwt is installed alongside PyJWT (specifically PyJWT versions prior to 2.0.0), a static type checker would use the stubs from `types-pyjwt` to validate the types in this code. For PyJWT versions 2.0.0 and newer, PyJWT includes its own `py.typed` file and inline annotations, making `types-pyjwt` unnecessary and potentially problematic.

import jwt from typing import Dict, Any def create_and_decode_token(payload: Dict[str, Any], secret: str) -> Dict[str, Any]: # This example assumes PyJWT < 2.0.0 would use types-pyjwt for type hints. # For PyJWT >= 2.0.0, the types are bundled. encoded_jwt = jwt.encode(payload, secret, algorithm="HS256") decoded_payload = jwt.decode(encoded_jwt, secret, algorithms=["HS256"]) return decoded_payload if __name__ == "__main__": my_payload = {"user_id": 123, "name": "test_user"} jwt_secret = "super-secret-key" # Run a type checker like MyPy on this file to see types-pyjwt in action (if PyJWT < 2.0.0) # Or, if PyJWT >= 2.0.0, to see PyJWT's bundled types. result = create_and_decode_token(my_payload, jwt_secret) print(f"Decoded payload: {result}") # Expected output for type checking (e.g., with mypy): No issues if types are correctly applied.
Debug
Known issues
breakingThe `PyJWT` library itself includes type annotations starting from version 2.0.0. If you are using `PyJWT` version 2.0.0 or newer, you MUST uninstall `types-pyjwt` to avoid type conflicts, incorrect type checking results, or outdated stub definitions.
fix
Uninstall `types-pyjwt`: `pip uninstall types-pyjwt`
affects: PyJWT >= 2.0.0
deprecated`types-pyjwt` has not been updated since mid-2021 (version 1.7.1) and is effectively deprecated due to `PyJWT`'s self-typing. Further type improvements or fixes for `PyJWT` are now made directly within the `PyJWT` project.
fix
Upgrade to `PyJWT` version 2.0.0 or newer and uninstall `types-pyjwt`.
affects: All versions of `types-pyjwt`
gotchaWhen `types-pyjwt` is installed, type checkers may prefer its stubs over inline annotations in `PyJWT < 2.0.0`. However, for `PyJWT >= 2.0.0`, the presence of `types-pyjwt` can cause confusing errors or `mypy` to complain about duplicate definitions.
fix
Consistently use either `types-pyjwt` (for `PyJWT < 2.0.0`) or PyJWT's built-in types (for `PyJWT >= 2.0.0`). The recommended approach is to upgrade `PyJWT` and remove `types-pyjwt`.
affects: All versions
Upgrade
Version history
1.7.1latest on PyPI · released Jun 17, 2021
Audit
Dependencies
PyJWTrequiredThis package provides type stubs for the PyJWT library. It is designed to be used alongside PyJWT versions older than 2.0.0.
Agent activity
55 hits · last 30 days
node
51
OpenAI (training)
1
Resources
types-pyjwt — pip install types-pyjwt · libregistry