Skip to content

Commit 41eb03f

Browse files
committed
Update collections.abc imports to avoid Python 3.7 warnings
1 parent 022167c commit 41eb03f

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

sortedcontainers/sorteddict.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,23 @@
1818

1919
import sys
2020
import warnings
21-
from collections import ItemsView, KeysView, ValuesView, Sequence
2221

2322
from .sortedlist import SortedList, recursive_repr
2423
from .sortedset import SortedSet
2524

25+
###############################################################################
26+
# BEGIN Python 2/3 Shims
27+
###############################################################################
28+
29+
try:
30+
from collections.abc import ItemsView, KeysView, ValuesView, Sequence
31+
except ImportError:
32+
from collections import ItemsView, KeysView, ValuesView, Sequence
33+
34+
###############################################################################
35+
# END Python 2/3 Shims
36+
###############################################################################
37+
2638

2739
class SortedDict(dict):
2840
"""Sorted dict is a sorted mutable mapping.

sortedcontainers/sortedlist.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from __future__ import print_function
1818

1919
from bisect import bisect_left, bisect_right, insort
20-
from collections import Sequence, MutableSequence
2120
from itertools import chain, repeat, starmap
2221
from math import log
2322
from operator import add, eq, ne, gt, ge, lt, le, iadd
@@ -27,6 +26,11 @@
2726
# BEGIN Python 2/3 Shims
2827
###############################################################################
2928

29+
try:
30+
from collections.abc import Sequence, MutableSequence
31+
except ImportError:
32+
from collections import Sequence, MutableSequence
33+
3034
from functools import wraps
3135
from sys import hexversion
3236

sortedcontainers/sortedset.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@
1313
1414
"""
1515

16-
from collections import MutableSet, Sequence, Set
1716
from itertools import chain
1817
from operator import eq, ne, gt, ge, lt, le
1918
from textwrap import dedent
2019

2120
from .sortedlist import SortedList, recursive_repr
2221

22+
###############################################################################
23+
# BEGIN Python 2/3 Shims
24+
###############################################################################
25+
26+
try:
27+
from collections.abc import MutableSet, Sequence, Set
28+
except ImportError:
29+
from collections import MutableSet, Sequence, Set
30+
31+
###############################################################################
32+
# END Python 2/3 Shims
33+
###############################################################################
34+
2335

2436
class SortedSet(MutableSet, Sequence):
2537
"""Sorted set is a sorted mutable set.

0 commit comments

Comments
 (0)