Skip to content

Commit e403e17

Browse files
committed
fix: use correct types for encoder_cls and decoder_cls parameters
1 parent 84d3247 commit e403e17

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/joserfc/jwt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22
import json
33
from json import JSONEncoder, JSONDecoder
4+
from typing import Type
45
from .rfc7519.claims import convert_claims
56
from .rfc7519.claims import Claims as Claims
67
from .rfc7519.claims import check_sensitive_data as check_sensitive_data
@@ -51,7 +52,7 @@ def encode(
5152
key: KeyFlexible,
5253
algorithms: list[str] | None = None,
5354
registry: JWSRegistry | JWERegistry | None = None,
54-
encoder_cls: JSONEncoder | None = None) -> str:
55+
encoder_cls: Type[JSONEncoder] | None = None) -> str:
5556
"""Encode a JSON Web Token with the given header, and claims.
5657
5758
:param header: A dict of the JWT header
@@ -75,7 +76,7 @@ def decode(
7576
key: KeyFlexible,
7677
algorithms: list[str] | None = None,
7778
registry: JWSRegistry | JWERegistry | None = None,
78-
decoder_cls: JSONDecoder | None = None) -> Token:
79+
decoder_cls: Type[JSONDecoder] | None = None) -> Token:
7980
"""Decode the JSON Web Token string with the given key, and validate
8081
it with the claims requests.
8182

src/joserfc/rfc7519/claims.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import datetime
66
import calendar
77
from json import JSONEncoder
8-
from typing import Dict, Any
8+
from typing import Dict, Any, Type
99
from ..util import to_bytes
1010
from ..errors import InsecureClaimError
1111

@@ -26,7 +26,7 @@
2626
Claims = Dict[str, Any]
2727

2828

29-
def convert_claims(claims: Claims, encoder_cls: JSONEncoder | None = None) -> bytes:
29+
def convert_claims(claims: Claims, encoder_cls: Type[JSONEncoder] | None = None) -> bytes:
3030
"""Turn claims into bytes payload."""
3131
for k in ["exp", "iat", "nbf"]:
3232
claim = claims.get(k)

0 commit comments

Comments
 (0)