{"id":9379,"library":"types-pyjwt","title":"Type Stubs for PyJWT","description":"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.","status":"deprecated","version":"1.7.1","language":"python","source_language":"en","source_url":"https://github.com/python/typeshed/tree/master/stubs/PyJWT","tags":["typing","stubs","pyjwt","type-checking","mypy","pyright"],"install":[{"cmd":"pip install types-pyjwt","lang":"bash","label":"Install types-pyjwt"}],"dependencies":[{"reason":"This package provides type stubs for the PyJWT library. It is designed to be used alongside PyJWT versions older than 2.0.0.","package":"PyJWT","optional":false}],"imports":[{"wrong":"import jwt-stubs","symbol":"jwt-stubs","correct":"import jwt_stubs"}],"quickstart":{"code":"import jwt\nfrom typing import Dict, Any\n\ndef create_and_decode_token(payload: Dict[str, Any], secret: str) -> Dict[str, Any]:\n    # This example assumes PyJWT < 2.0.0 would use types-pyjwt for type hints.\n    # For PyJWT >= 2.0.0, the types are bundled.\n    encoded_jwt = jwt.encode(payload, secret, algorithm=\"HS256\")\n    decoded_payload = jwt.decode(encoded_jwt, secret, algorithms=[\"HS256\"])\n    return decoded_payload\n\nif __name__ == \"__main__\":\n    my_payload = {\"user_id\": 123, \"name\": \"test_user\"}\n    jwt_secret = \"super-secret-key\"\n    \n    # Run a type checker like MyPy on this file to see types-pyjwt in action (if PyJWT < 2.0.0)\n    # Or, if PyJWT >= 2.0.0, to see PyJWT's bundled types.\n    result = create_and_decode_token(my_payload, jwt_secret)\n    print(f\"Decoded payload: {result}\")\n    # Expected output for type checking (e.g., with mypy): No issues if types are correctly applied.","lang":"python","description":"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."},"warnings":[{"fix":"Uninstall `types-pyjwt`: `pip uninstall types-pyjwt`","message":"The `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.","severity":"breaking","affected_versions":"PyJWT >= 2.0.0"},{"fix":"Upgrade to `PyJWT` version 2.0.0 or newer and uninstall `types-pyjwt`.","message":"`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.","severity":"deprecated","affected_versions":"All versions of `types-pyjwt`"},{"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`.","message":"When `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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'-2021':69 '1.7.1':61 '2.0.0':83 '561':11 'analysi':38 'annot':19,80 'auto':48 'auto-gener':47 'check':28,90 'code':40 'communiti':53 'community-maintain':52 'compliant':12 'enabl':25 'generat':49 'includ':76 'librari':23,74 'like':30 'maintain':54 'mid':68 'mypi':31,91 'onward':84 'packag':15,44 'pep':10 'perform':36 'provid':16 'pycharm':34 'pyjwt':4,7,22,42,73,87 'pypi':59 'pyright':32,92 'repositori':56 'seen':65 'sinc':67 'start':75 'static':17,37 'stub':2,14,86 'tool':29 'type':1,6,13,18,27,79,85,89 'type-check':26,88 'types-pyjwt':5 'typesh':55 'updat':66 'upstream':72 'use':41 'version':60,82","created_at":"2026-04-16T18:49:54.385869+00:00","updated_at":"2026-04-16T18:49:54.385869+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nModuleNotFoundError: No module named 'jwt_stubs'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.7.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/python/typeshed","docs":null,"changelog":null,"pypi":"https://pypi.org/project/types-pyjwt/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs","auth-security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}