Skip to content

Commit 215c752

Browse files
authored
Merge pull request #669 from plotly/mkcor-deprecation-collections
Fix DeprecationWarning when importing ABCs.
2 parents 0812b1a + ad8793c commit 215c752

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

dash/development/base_component.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import collections
21
import abc
32
import inspect
43
import sys
5-
64
import six
75

86
from .._utils import patch_collections_abc
97

8+
MutableSequence = patch_collections_abc('MutableSequence')
9+
1010

1111
# pylint: disable=no-init,too-few-public-methods
1212
class ComponentRegistry:
@@ -53,8 +53,7 @@ def is_number(s):
5353
def _check_if_has_indexable_children(item):
5454
if (not hasattr(item, 'children') or
5555
(not isinstance(item.children, Component) and
56-
not isinstance(item.children, (tuple,
57-
collections.MutableSequence)))):
56+
not isinstance(item.children, (tuple, MutableSequence)))):
5857

5958
raise KeyError
6059

@@ -153,7 +152,7 @@ def _get_set_or_delete(self, id, operation, new_item=None):
153152
pass
154153

155154
# if children is like a list
156-
if isinstance(self.children, (tuple, collections.MutableSequence)):
155+
if isinstance(self.children, (tuple, MutableSequence)):
157156
for i, item in enumerate(self.children):
158157
# If the item itself is the one we're looking for
159158
if getattr(item, 'id', None) == id:
@@ -229,7 +228,7 @@ def traverse_with_paths(self):
229228
yield "\n".join(["[*] " + children_string, p]), t
230229

231230
# children is a list of components
232-
elif isinstance(children, (tuple, collections.MutableSequence)):
231+
elif isinstance(children, (tuple, MutableSequence)):
233232
for idx, i in enumerate(children):
234233
list_path = "[{:d}] {:s} {}".format(
235234
idx,
@@ -262,7 +261,7 @@ def __len__(self):
262261
elif isinstance(self.children, Component):
263262
length = 1
264263
length += len(self.children)
265-
elif isinstance(self.children, (tuple, collections.MutableSequence)):
264+
elif isinstance(self.children, (tuple, MutableSequence)):
266265
for c in self.children:
267266
length += 1
268267
if isinstance(c, Component):

0 commit comments

Comments
 (0)