diff options
author | John T. Wodder II <git@varonathe.org> | 2018-10-29 19:50:49 +0000 |
---|---|---|
committer | John T. Wodder II <git@varonathe.org> | 2018-10-31 14:29:51 +0000 |
commit | 255c70115059c0d3347f6fbe3776031d4a52d009 (patch) | |
tree | 49105e52d8931388a3a476cc1e88593cf1375436 | |
parent | e03fe75a0e3bcd55c545e94aa6ced0b4bb689f5a (diff) | |
download | uritemplates-255c70115059c0d3347f6fbe3776031d4a52d009.tar.gz |
Import ABCs from collections.abc if possible
Quoting Python 3.7's DeprecationWarning: "Using or importing the ABCs from
'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it
will stop working"
-rw-r--r-- | uritemplate/orderedset.py | 8 | ||||
-rw-r--r-- | uritemplate/variable.py | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/uritemplate/orderedset.py b/uritemplate/orderedset.py index 7a9d33e..f21c9cb 100644 --- a/uritemplate/orderedset.py +++ b/uritemplate/orderedset.py @@ -1,14 +1,18 @@ # From: https://github.com/ActiveState/code/blob/master/recipes/Python/576696_OrderedSet_with_Weakrefs/ # noqa -import collections from weakref import proxy +try: + import collections.abc as collections_abc +except ImportError: + import collections as collections_abc + class Link(object): __slots__ = 'prev', 'next', 'key', '__weakref__' -class OrderedSet(collections.MutableSet): +class OrderedSet(collections_abc.MutableSet): 'Set the remembers the order elements were added' # Big-O running times for all methods are the same as for regular sets. # The internal self.__map dictionary maps keys to links in a doubly linked diff --git a/uritemplate/variable.py b/uritemplate/variable.py index 0d2e695..a3bd4ce 100644 --- a/uritemplate/variable.py +++ b/uritemplate/variable.py @@ -15,9 +15,13 @@ What do you do? """ -import collections import sys +try: + import collections.abc as collections_abc +except ImportError: + import collections as collections_abc + if sys.version_info.major == 2: import urllib elif sys.version_info.major == 3: @@ -360,7 +364,7 @@ def list_test(value): def dict_test(value): - return isinstance(value, (dict, collections.MutableMapping)) + return isinstance(value, (dict, collections_abc.MutableMapping)) try: |