File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 1
1
import uuid
2
+ import collections
3
+ import six
2
4
3
5
4
6
def interpolate_str (template , ** data ):
@@ -40,6 +42,12 @@ def get_asset_path(
40
42
])
41
43
42
44
45
+ def patch_collections_abc (member ):
46
+ if six .PY2 :
47
+ return getattr (collections , member )
48
+ return getattr (collections .abc , member )
49
+
50
+
43
51
class AttributeDict (dict ):
44
52
"""
45
53
Dictionary subclass enabling attribute lookup/assignment of keys/values.
Original file line number Diff line number Diff line change 30
30
from ._utils import interpolate_str as _interpolate
31
31
from ._utils import format_tag as _format_tag
32
32
from ._utils import generate_hash as _generate_hash
33
- from . import _watch
34
33
from ._utils import get_asset_path as _get_asset_path
34
+ from ._utils import patch_collections_abc as _patch_collections_abc
35
+ from . import _watch
35
36
from . import _configs
36
37
37
38
@@ -275,7 +276,7 @@ def layout(self):
275
276
return self ._layout
276
277
277
278
def _layout_value (self ):
278
- if isinstance (self ._layout , collections . Callable ):
279
+ if isinstance (self ._layout , _patch_collections_abc ( ' Callable' ) ):
279
280
self ._cached_layout = self ._layout ()
280
281
else :
281
282
self ._cached_layout = self ._layout
@@ -284,7 +285,7 @@ def _layout_value(self):
284
285
@layout .setter
285
286
def layout (self , value ):
286
287
if (not isinstance (value , Component ) and
287
- not isinstance (value , collections . Callable )):
288
+ not isinstance (value , _patch_collections_abc ( ' Callable' ) )):
288
289
raise exceptions .NoLayoutException (
289
290
''
290
291
'Layout must be a dash component '
Original file line number Diff line number Diff line change 5
5
6
6
import six
7
7
8
+ from .._utils import patch_collections_abc
9
+
8
10
9
11
# pylint: disable=no-init,too-few-public-methods
10
12
class ComponentRegistry :
@@ -58,7 +60,7 @@ def _check_if_has_indexable_children(item):
58
60
59
61
60
62
@six .add_metaclass (ComponentMeta )
61
- class Component (collections . MutableMapping ):
63
+ class Component (patch_collections_abc ( ' MutableMapping' ) ):
62
64
class _UNDEFINED (object ):
63
65
def __repr__ (self ):
64
66
return 'undefined'
You can’t perform that action at this time.
0 commit comments