Skip to content

Commit a14726c

Browse files
committed
fix DeprecationWarning when importing ABCs
1 parent 0812b1a commit a14726c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

dash/development/base_component.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import collections
21
import abc
32
import inspect
43
import sys
4+
try:
5+
from collections.abc import MutableSequence
6+
except ImportError:
7+
from collections import MutableSequence
58

69
import six
710

@@ -53,8 +56,7 @@ def is_number(s):
5356
def _check_if_has_indexable_children(item):
5457
if (not hasattr(item, 'children') or
5558
(not isinstance(item.children, Component) and
56-
not isinstance(item.children, (tuple,
57-
collections.MutableSequence)))):
59+
not isinstance(item.children, (tuple, MutableSequence)))):
5860

5961
raise KeyError
6062

@@ -153,7 +155,7 @@ def _get_set_or_delete(self, id, operation, new_item=None):
153155
pass
154156

155157
# if children is like a list
156-
if isinstance(self.children, (tuple, collections.MutableSequence)):
158+
if isinstance(self.children, (tuple, MutableSequence)):
157159
for i, item in enumerate(self.children):
158160
# If the item itself is the one we're looking for
159161
if getattr(item, 'id', None) == id:
@@ -229,7 +231,7 @@ def traverse_with_paths(self):
229231
yield "\n".join(["[*] " + children_string, p]), t
230232

231233
# children is a list of components
232-
elif isinstance(children, (tuple, collections.MutableSequence)):
234+
elif isinstance(children, (tuple, MutableSequence)):
233235
for idx, i in enumerate(children):
234236
list_path = "[{:d}] {:s} {}".format(
235237
idx,
@@ -262,7 +264,7 @@ def __len__(self):
262264
elif isinstance(self.children, Component):
263265
length = 1
264266
length += len(self.children)
265-
elif isinstance(self.children, (tuple, collections.MutableSequence)):
267+
elif isinstance(self.children, (tuple, MutableSequence)):
266268
for c in self.children:
267269
length += 1
268270
if isinstance(c, Component):

0 commit comments

Comments
 (0)