|
1 | | -import collections |
2 | 1 | import abc |
3 | 2 | import inspect |
4 | 3 | import sys |
5 | | - |
6 | 4 | import six |
7 | 5 |
|
8 | 6 | from .._utils import patch_collections_abc |
9 | 7 |
|
| 8 | +MutableSequence = patch_collections_abc('MutableSequence') |
| 9 | + |
10 | 10 |
|
11 | 11 | # pylint: disable=no-init,too-few-public-methods |
12 | 12 | class ComponentRegistry: |
@@ -53,8 +53,7 @@ def is_number(s): |
53 | 53 | def _check_if_has_indexable_children(item): |
54 | 54 | if (not hasattr(item, 'children') or |
55 | 55 | (not isinstance(item.children, Component) and |
56 | | - not isinstance(item.children, (tuple, |
57 | | - collections.MutableSequence)))): |
| 56 | + not isinstance(item.children, (tuple, MutableSequence)))): |
58 | 57 |
|
59 | 58 | raise KeyError |
60 | 59 |
|
@@ -153,7 +152,7 @@ def _get_set_or_delete(self, id, operation, new_item=None): |
153 | 152 | pass |
154 | 153 |
|
155 | 154 | # if children is like a list |
156 | | - if isinstance(self.children, (tuple, collections.MutableSequence)): |
| 155 | + if isinstance(self.children, (tuple, MutableSequence)): |
157 | 156 | for i, item in enumerate(self.children): |
158 | 157 | # If the item itself is the one we're looking for |
159 | 158 | if getattr(item, 'id', None) == id: |
@@ -229,7 +228,7 @@ def traverse_with_paths(self): |
229 | 228 | yield "\n".join(["[*] " + children_string, p]), t |
230 | 229 |
|
231 | 230 | # children is a list of components |
232 | | - elif isinstance(children, (tuple, collections.MutableSequence)): |
| 231 | + elif isinstance(children, (tuple, MutableSequence)): |
233 | 232 | for idx, i in enumerate(children): |
234 | 233 | list_path = "[{:d}] {:s} {}".format( |
235 | 234 | idx, |
@@ -262,7 +261,7 @@ def __len__(self): |
262 | 261 | elif isinstance(self.children, Component): |
263 | 262 | length = 1 |
264 | 263 | length += len(self.children) |
265 | | - elif isinstance(self.children, (tuple, collections.MutableSequence)): |
| 264 | + elif isinstance(self.children, (tuple, MutableSequence)): |
266 | 265 | for c in self.children: |
267 | 266 | length += 1 |
268 | 267 | if isinstance(c, Component): |
|
0 commit comments