Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30d4c5a

Browse files
thombashijpadilla
authored andcommitted
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
1 parent 2122f94 commit 30d4c5a

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

jwt/api_jws.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import binascii
22
import json
33
import warnings
4-
from collections import Mapping
54
try:
65
# import required by mypy to perform type checking, not used for normal execution
76
from typing import Callable, Dict, List, Optional, Union # NOQA
@@ -11,7 +10,7 @@
1110
from .algorithms import (
1211
Algorithm, get_default_algorithms, has_crypto, requires_cryptography # NOQA
1312
)
14-
from .compat import binary_type, string_types, text_type
13+
from .compat import Mapping, binary_type, string_types, text_type
1514
from .exceptions import (
1615
DecodeError, InvalidAlgorithmError, InvalidSignatureError,
1716
InvalidTokenError

jwt/api_jwt.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
import warnings
33
from calendar import timegm
44
from datetime import datetime, timedelta
5-
try:
6-
# Importing ABCs from collections will be removed in PY3.8
7-
from collections.abc import Iterable, Mapping
8-
except ImportError:
9-
from collections import Iterable, Mapping
105
try:
116
# import required by mypy to perform type checking, not used for normal execution
127
from typing import Callable, Dict, List, Optional, Union # NOQA
@@ -15,7 +10,7 @@
1510

1611
from .api_jws import PyJWS
1712
from .algorithms import Algorithm, get_default_algorithms # NOQA
18-
from .compat import string_types
13+
from .compat import Iterable, Mapping, string_types
1914
from .exceptions import (
2015
DecodeError, ExpiredSignatureError, ImmatureSignatureError,
2116
InvalidAudienceError, InvalidIssuedAtError,

jwt/compat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020

2121
string_types = (text_type, binary_type)
2222

23+
try:
24+
# Importing ABCs from collections will be removed in PY3.8
25+
from collections.abc import Iterable, Mapping
26+
except ImportError:
27+
from collections import Iterable, Mapping
2328

2429
try:
2530
constant_time_compare = hmac.compare_digest

0 commit comments

Comments
 (0)