Remove redundant usage of collections(.abc).Mapping

The json.loads method returns a normal python dict without any hook
defined, and type check using the Mapping class is redundant.

In Python 3.8
>>> import json
>>> type(json.loads('{"foo": {"var": "baz"}}'))
<class 'dict'>

In Python 2.7
>>> import json
>>> type(json.loads('{"foo": {"var": "baz"}}'))
<class 'dict'>

With this change we don't have to handle difference between Python 2
and Python 3 and later about import path we should use to import that
abstract class

Closes-Bug: #1936667
Change-Id: I9232311784d1feff2d669455dafde17ed9f751ad
This commit is contained in:
Takashi Kajinami
2021-07-17 01:07:54 +09:00
parent 653daf73ed
commit 775ad9a568

View File

@@ -14,7 +14,6 @@
# limitations under the License.
import base64
import binascii
import collections
import json
import os
@@ -260,7 +259,7 @@ def load_crypto_meta(value, b64decode=True):
if not isinstance(value, six.string_types):
raise ValueError('crypto meta not a string')
val = json.loads(urlparse.unquote_plus(value))
if not isinstance(val, collections.Mapping):
if not isinstance(val, dict):
raise ValueError('crypto meta not a Mapping')
return b64_decode_meta(val)
except (KeyError, ValueError, TypeError) as err: