summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>2018-11-26 00:28:26 +0900
committerJosé Padilla <jpadilla@webapplicate.com>2018-11-25 10:28:26 -0500
commit30d4c5a7f91e2425211b51c479f2f1e7a37f98b9 (patch)
tree1c3a0bec154d47aaed6f555e484af34ffdcc42c3
parent2122f94432d160a23e79a4771c05d71132dc6db9 (diff)
downloadpyjwt-30d4c5a7f91e2425211b51c479f2f1e7a37f98b9.tar.gz
Import collection ABC's from correct module (#384)
* Move ABCs imports to compat.py to reuse the imports from other modules * Import collection ABC's from correct module
-rw-r--r--jwt/api_jws.py3
-rw-r--r--jwt/api_jwt.py7
-rw-r--r--jwt/compat.py5
3 files changed, 7 insertions, 8 deletions
diff --git a/jwt/api_jws.py b/jwt/api_jws.py
index 8039e9b..a9354ad 100644
--- a/jwt/api_jws.py
+++ b/jwt/api_jws.py
@@ -1,7 +1,6 @@
import binascii
import json
import warnings
-from collections import Mapping
try:
# import required by mypy to perform type checking, not used for normal execution
from typing import Callable, Dict, List, Optional, Union # NOQA
@@ -11,7 +10,7 @@ except ImportError:
from .algorithms import (
Algorithm, get_default_algorithms, has_crypto, requires_cryptography # NOQA
)
-from .compat import binary_type, string_types, text_type
+from .compat import Mapping, binary_type, string_types, text_type
from .exceptions import (
DecodeError, InvalidAlgorithmError, InvalidSignatureError,
InvalidTokenError
diff --git a/jwt/api_jwt.py b/jwt/api_jwt.py
index 0836ec0..85504ac 100644
--- a/jwt/api_jwt.py
+++ b/jwt/api_jwt.py
@@ -3,11 +3,6 @@ import warnings
from calendar import timegm
from datetime import datetime, timedelta
try:
- # Importing ABCs from collections will be removed in PY3.8
- from collections.abc import Iterable, Mapping
-except ImportError:
- from collections import Iterable, Mapping
-try:
# import required by mypy to perform type checking, not used for normal execution
from typing import Callable, Dict, List, Optional, Union # NOQA
except ImportError:
@@ -15,7 +10,7 @@ except ImportError:
from .api_jws import PyJWS
from .algorithms import Algorithm, get_default_algorithms # NOQA
-from .compat import string_types
+from .compat import Iterable, Mapping, string_types
from .exceptions import (
DecodeError, ExpiredSignatureError, ImmatureSignatureError,
InvalidAudienceError, InvalidIssuedAtError,
diff --git a/jwt/compat.py b/jwt/compat.py
index c30f109..e79e258 100644
--- a/jwt/compat.py
+++ b/jwt/compat.py
@@ -20,6 +20,11 @@ else:
string_types = (text_type, binary_type)
+try:
+ # Importing ABCs from collections will be removed in PY3.8
+ from collections.abc import Iterable, Mapping
+except ImportError:
+ from collections import Iterable, Mapping
try:
constant_time_compare = hmac.compare_digest