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 11import uuid
2+ import collections
3+ import six
24
35
46def interpolate_str (template , ** data ):
@@ -40,6 +42,12 @@ def get_asset_path(
4042 ])
4143
4244
45+ def patch_collections_abc (member ):
46+ if six .PY2 :
47+ return getattr (collections , member )
48+ return getattr (collections .abc , member )
49+
50+
4351class AttributeDict (dict ):
4452 """
4553 Dictionary subclass enabling attribute lookup/assignment of keys/values.
Original file line number Diff line number Diff line change 3030from ._utils import interpolate_str as _interpolate
3131from ._utils import format_tag as _format_tag
3232from ._utils import generate_hash as _generate_hash
33- from . import _watch
3433from ._utils import get_asset_path as _get_asset_path
34+ from ._utils import patch_collections_abc as _patch_collections_abc
35+ from . import _watch
3536from . import _configs
3637
3738
@@ -275,7 +276,7 @@ def layout(self):
275276 return self ._layout
276277
277278 def _layout_value (self ):
278- if isinstance (self ._layout , collections . Callable ):
279+ if isinstance (self ._layout , _patch_collections_abc ( ' Callable' ) ):
279280 self ._cached_layout = self ._layout ()
280281 else :
281282 self ._cached_layout = self ._layout
@@ -284,7 +285,7 @@ def _layout_value(self):
284285 @layout .setter
285286 def layout (self , value ):
286287 if (not isinstance (value , Component ) and
287- not isinstance (value , collections . Callable )):
288+ not isinstance (value , _patch_collections_abc ( ' Callable' ) )):
288289 raise exceptions .NoLayoutException (
289290 ''
290291 'Layout must be a dash component '
Original file line number Diff line number Diff line change 55
66import six
77
8+ from .._utils import patch_collections_abc
9+
810
911# pylint: disable=no-init,too-few-public-methods
1012class ComponentRegistry :
@@ -58,7 +60,7 @@ def _check_if_has_indexable_children(item):
5860
5961
6062@six .add_metaclass (ComponentMeta )
61- class Component (collections . MutableMapping ):
63+ class Component (patch_collections_abc ( ' MutableMapping' ) ):
6264 class _UNDEFINED (object ):
6365 def __repr__ (self ):
6466 return 'undefined'
You can’t perform that action at this time.
0 commit comments