Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.20.0
hooks:
- id: pyupgrade
name: Enforce Python 3.9+ idioms
args: ["--py39-plus"]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.9.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Added
- Docs: Add example of using leeway with nbf by @djw8605 in `#1034 <https://github.com/jpadilla/pyjwt/pull/1034>`__
- Docs: Refactored docs with ``autodoc``; added ``PyJWS`` and ``jwt.algorithms`` docs by @pachewise in `#1045 <https://github.com/jpadilla/pyjwt/pull/1045>`__
- Docs: Documentation improvements for "sub" and "jti" claims by @cleder in `#1088 <https://github.com/jpadilla/pyjwt/pull/1088>`__
- Development: Add pyupgrade as a pre-commit hook by @kurtmckee in `#1109 <https://github.com/jpadilla/pyjwt/pull/1109>`__

`v2.10.1 <https://github.com/jpadilla/pyjwt/compare/2.10.0...2.10.1>`__
-----------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion jwt/api_jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import json
import time
from typing import Any, Iterator
from collections.abc import Iterator
from typing import Any

from .algorithms import get_default_algorithms, has_crypto, requires_cryptography
from .exceptions import (
Expand Down
4 changes: 2 additions & 2 deletions jwt/api_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import os
import warnings
from calendar import timegm
from collections.abc import Iterable, Sequence
from collections.abc import Container, Iterable, Sequence
from datetime import datetime, timedelta, timezone
from typing import TYPE_CHECKING, Any, Container
from typing import TYPE_CHECKING, Any

from . import api_jws
from .exceptions import (
Expand Down
3 changes: 1 addition & 2 deletions jwt/help.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import platform
import sys
from typing import Dict

from . import __version__ as pyjwt_version

Expand All @@ -13,7 +12,7 @@
cryptography_version = ""


def info() -> Dict[str, Dict[str, str]]:
def info() -> dict[str, dict[str, str]]:
"""
Generate information for a bug report.
Based on the requests package help utility module.
Expand Down
12 changes: 6 additions & 6 deletions jwt/jwks_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import urllib.request
from functools import lru_cache
from ssl import SSLContext
from typing import Any, Dict, List, Optional
from typing import Any
from urllib.error import URLError

from .api_jwk import PyJWK, PyJWKSet
Expand All @@ -21,14 +21,14 @@ def __init__(
max_cached_keys: int = 16,
cache_jwk_set: bool = True,
lifespan: float = 300,
headers: Optional[Dict[str, Any]] = None,
headers: dict[str, Any] | None = None,
timeout: float = 30,
ssl_context: Optional[SSLContext] = None,
ssl_context: SSLContext | None = None,
):
if headers is None:
headers = {}
self.uri = uri
self.jwk_set_cache: Optional[JWKSetCache] = None
self.jwk_set_cache: JWKSetCache | None = None
self.headers = headers
self.timeout = timeout
self.ssl_context = ssl_context
Expand Down Expand Up @@ -82,7 +82,7 @@ def get_jwk_set(self, refresh: bool = False) -> PyJWKSet:

return PyJWKSet.from_dict(data)

def get_signing_keys(self, refresh: bool = False) -> List[PyJWK]:
def get_signing_keys(self, refresh: bool = False) -> list[PyJWK]:
jwk_set = self.get_jwk_set(refresh)
signing_keys = [
jwk_set_key
Expand Down Expand Up @@ -117,7 +117,7 @@ def get_signing_key_from_jwt(self, token: str | bytes) -> PyJWK:
return self.get_signing_key(header.get("kid"))

@staticmethod
def match_kid(signing_keys: List[PyJWK], kid: str) -> Optional[PyJWK]:
def match_kid(signing_keys: list[PyJWK], kid: str) -> PyJWK | None:
signing_key = None

for key in signing_keys:
Expand Down
4 changes: 2 additions & 2 deletions jwt/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Callable, Dict, TypedDict
from typing import Any, Callable, TypedDict

JWKDict = Dict[str, Any]
JWKDict = dict[str, Any]

HashlibHash = Callable[..., Any]

Expand Down