Skip to content

Commit

Permalink
Import collection ABC's from correct module (#384)
Browse files Browse the repository at this point in the history
* Move ABCs imports to compat.py to reuse the imports from other modules

* Import collection ABC's from correct module
  • Loading branch information
thombashi authored and jpadilla committed Nov 25, 2018
1 parent 2122f94 commit 30d4c5a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions jwt/api_jws.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +10,7 @@
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
Expand Down
7 changes: 1 addition & 6 deletions jwt/api_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,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
Expand All @@ -15,7 +10,7 @@

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,
Expand Down
5 changes: 5 additions & 0 deletions jwt/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

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
Expand Down

0 comments on commit 30d4c5a

Please sign in to comment.