summaryrefslogtreecommitdiff
path: root/jwt/api_jws.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2020-06-18 22:53:17 -0700
committerGitHub <noreply@github.com>2020-06-19 11:53:17 +0600
commitdc8dc7d05d54bd5502295601c01b557caab92a76 (patch)
tree72ff8cc4f0a65015dc7a114d321ee0df4a5da637 /jwt/api_jws.py
parent07210eef3741781e0483cec656b99477c9185732 (diff)
downloadpyjwt-dc8dc7d05d54bd5502295601c01b557caab92a76.tar.gz
Remove unnecessary compatibility shims for Python 2 (#498)
As the project is Python 3 only, can remove the compatibility shims in compat.py. Type checking has been simplified where it can: - str is iterable - bytes is iterable - use isinstance instead of issubclass The remaining function bytes_from_int() has been moved to utils.py.
Diffstat (limited to 'jwt/api_jws.py')
-rw-r--r--jwt/api_jws.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/jwt/api_jws.py b/jwt/api_jws.py
index ef5d7ec..287dbf4 100644
--- a/jwt/api_jws.py
+++ b/jwt/api_jws.py
@@ -1,10 +1,10 @@
import binascii
import json
import warnings
+from collections.abc import Mapping
from .algorithms import requires_cryptography # NOQA
from .algorithms import Algorithm, get_default_algorithms, has_crypto
-from .compat import Mapping, binary_type, string_types, text_type
from .exceptions import (
DecodeError,
InvalidAlgorithmError,
@@ -178,12 +178,12 @@ class PyJWS:
return headers
def _load(self, jwt):
- if isinstance(jwt, text_type):
+ if isinstance(jwt, str):
jwt = jwt.encode("utf-8")
- if not issubclass(type(jwt), binary_type):
+ if not isinstance(jwt, bytes):
raise DecodeError(
- "Invalid token type. Token must be a {}".format(binary_type)
+ "Invalid token type. Token must be a {}".format(bytes)
)
try:
@@ -249,7 +249,7 @@ class PyJWS:
self._validate_kid(headers["kid"])
def _validate_kid(self, kid):
- if not isinstance(kid, string_types):
+ if not isinstance(kid, (bytes, str)):
raise InvalidTokenError("Key ID header parameter must be a string")