Skip to content

Commit 251ea73

Browse files
jay0leeplamut
authored andcommitted
fix: make collections import compatible across Python versions (#419)
* Use collections.abc, fixes #418 * Python 2.7 compat fix * Fix check
1 parent c3b17e3 commit 251ea73

File tree

1 file changed

+5
-2
lines changed
  • packages/google-auth/google/auth

1 file changed

+5
-2
lines changed

packages/google-auth/google/auth/jwt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
4141
"""
4242

43-
import collections
43+
try:
44+
from collections.abc import Mapping
45+
except ImportError: # Python 2.7 compatibility
46+
from collections import Mapping
4447
import copy
4548
import datetime
4649
import json
@@ -215,7 +218,7 @@ def decode(token, certs=None, verify=True, audience=None):
215218

216219
# If certs is specified as a dictionary of key IDs to certificates, then
217220
# use the certificate identified by the key ID in the token header.
218-
if isinstance(certs, collections.Mapping):
221+
if isinstance(certs, Mapping):
219222
key_id = header.get("kid")
220223
if key_id:
221224
if key_id not in certs:

0 commit comments

Comments
 (0)