summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-09-28 13:26:42 -0700
committerJosé Padilla <jpadilla@webapplicate.com>2019-09-28 16:26:41 -0400
commit1b979a42dcd57588fa1d7c169b6627f1f0cd3e1b (patch)
tree497c0ce22606fe63fb9f896f39bdd30a13dd8e97
parent3d47b0ea9e5d489f9c90ee6dde9e3d9d69244e3a (diff)
downloadpyjwt-1b979a42dcd57588fa1d7c169b6627f1f0cd3e1b.tar.gz
Correct type for json_encoder argument (#438)
Per recent upstream fix to typeshed, json.dumps() cls argument should be optional type JSONEncoder. https://github.com/python/typeshed/commit/8e0d288ea49a34f9bd21b1598ec487414a339a1f Fixes mypy error: jwt/api_jws.py:102: error: Argument "cls" to "dumps" has incompatible type "Optional[Callable[..., Any]]"; expected "Optional[Type[JSONEncoder]]" jwt/api_jwt.py:61: error: Argument "cls" to "dumps" has incompatible type "Optional[Callable[..., Any]]"; expected "Optional[Type[JSONEncoder]]"
-rw-r--r--jwt/api_jws.py4
-rw-r--r--jwt/api_jwt.py4
2 files changed, 4 insertions, 4 deletions
diff --git a/jwt/api_jws.py b/jwt/api_jws.py
index a9354ad..19f58d0 100644
--- a/jwt/api_jws.py
+++ b/jwt/api_jws.py
@@ -3,7 +3,7 @@ import json
import warnings
try:
# import required by mypy to perform type checking, not used for normal execution
- from typing import Callable, Dict, List, Optional, Union # NOQA
+ from typing import Callable, Dict, List, Optional, Type, Union # NOQA
except ImportError:
pass
@@ -78,7 +78,7 @@ class PyJWS(object):
key, # type: str
algorithm='HS256', # type: str
headers=None, # type: Optional[Dict]
- json_encoder=None # type: Optional[Callable]
+ json_encoder=None # type: Optional[Type[json.JSONEncoder]]
):
segments = []
diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py
index 971fa20..3e280bc 100644
--- a/jwt/api_jwt.py
+++ b/jwt/api_jwt.py
@@ -4,7 +4,7 @@ from calendar import timegm
from datetime import datetime, timedelta
try:
# import required by mypy to perform type checking, not used for normal execution
- from typing import Any, Callable, Dict, List, Optional, Union # NOQA
+ from typing import Any, Callable, Dict, List, Optional, Type, Union # NOQA
except ImportError:
pass
@@ -42,7 +42,7 @@ class PyJWT(PyJWS):
key, # type: str
algorithm='HS256', # type: str
headers=None, # type: Optional[Dict]
- json_encoder=None # type: Optional[Callable]
+ json_encoder=None # type: Optional[Type[json.JSONEncoder]]
):
# Check that we get a mapping
if not isinstance(payload, Mapping):