From f6ef2a962e3edd3d39903ff8e28223b5967f9a47 Mon Sep 17 00:00:00 2001 From: mkollo Date: Tue, 16 Aug 2022 17:17:56 +0300 Subject: [PATCH] Updated MutableMapping import for Python 3.10 compatibility. --- pelecanus/pelicanjson.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pelecanus/pelicanjson.py b/pelecanus/pelicanjson.py index 7fdad76..e9768bf 100644 --- a/pelecanus/pelicanjson.py +++ b/pelecanus/pelicanjson.py @@ -15,7 +15,13 @@ """ import copy import json -import collections +import sys + +if sys.version_info.major == 3 and sys.version_info.minor >= 10: + from collections.abc import MutableMapping + from collections import deque +else: + from collections import MutableMapping, deque from .toolbox import backfill_append from .toolbox import new_json_from_path @@ -24,7 +30,7 @@ from .exceptions import EmptyPath -class PelicanJson(collections.MutableMapping): +class PelicanJson(MutableMapping): """PelicanJson objects are nested JSON objects that provide a few methods to make it easier to navigate and edit nested JSON objects. @@ -251,7 +257,7 @@ def test_path(path): # Now, let's take this path and figure out how much of it is already # present in the object. keys_present = path[:] - keys_missing = collections.deque() + keys_missing = deque() while keys_present and not test_path(keys_present): keys_missing.appendleft(keys_present.pop())