Skip to content

Commit

Permalink
Merge pull request #669 from plotly/mkcor-deprecation-collections
Browse files Browse the repository at this point in the history
Fix DeprecationWarning when importing ABCs.
  • Loading branch information
mkcor authored Apr 1, 2019
2 parents 0812b1a + ad8793c commit 215c752
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions dash/development/base_component.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import collections
import abc
import inspect
import sys

import six

from .._utils import patch_collections_abc

MutableSequence = patch_collections_abc('MutableSequence')


# pylint: disable=no-init,too-few-public-methods
class ComponentRegistry:
Expand Down Expand Up @@ -53,8 +53,7 @@ def is_number(s):
def _check_if_has_indexable_children(item):
if (not hasattr(item, 'children') or
(not isinstance(item.children, Component) and
not isinstance(item.children, (tuple,
collections.MutableSequence)))):
not isinstance(item.children, (tuple, MutableSequence)))):

raise KeyError

Expand Down Expand Up @@ -153,7 +152,7 @@ def _get_set_or_delete(self, id, operation, new_item=None):
pass

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

# children is a list of components
elif isinstance(children, (tuple, collections.MutableSequence)):
elif isinstance(children, (tuple, MutableSequence)):
for idx, i in enumerate(children):
list_path = "[{:d}] {:s} {}".format(
idx,
Expand Down Expand Up @@ -262,7 +261,7 @@ def __len__(self):
elif isinstance(self.children, Component):
length = 1
length += len(self.children)
elif isinstance(self.children, (tuple, collections.MutableSequence)):
elif isinstance(self.children, (tuple, MutableSequence)):
for c in self.children:
length += 1
if isinstance(c, Component):
Expand Down

0 comments on commit 215c752

Please sign in to comment.