From d3d63ba3e285e0196ba4006c73176c6ac740b10f Mon Sep 17 00:00:00 2001 From: t4rk1n Date: Thu, 31 Jan 2019 21:07:03 -0500 Subject: [PATCH 1/3] :bug: Fix collections.abc deprecation warning for py 3.8 --- dash/_utils.py | 8 ++++++++ dash/dash.py | 7 ++++--- dash/development/base_component.py | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dash/_utils.py b/dash/_utils.py index 0e909b31ae..0123e3bfce 100644 --- a/dash/_utils.py +++ b/dash/_utils.py @@ -1,4 +1,6 @@ import uuid +import collections +import six def interpolate_str(template, **data): @@ -40,6 +42,12 @@ def get_asset_path( ]) +def patch_collections_abc(member): + if six.PY2: + return getattr(collections, member) + return getattr(collections.abc, member) + + class AttributeDict(dict): """ Dictionary subclass enabling attribute lookup/assignment of keys/values. diff --git a/dash/dash.py b/dash/dash.py index eb30b2a233..20448ce3c8 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -30,8 +30,9 @@ from ._utils import interpolate_str as _interpolate from ._utils import format_tag as _format_tag from ._utils import generate_hash as _generate_hash -from . import _watch from ._utils import get_asset_path as _get_asset_path +from ._utils import patch_collections_abc as _patch_collections_abc +from . import _watch from . import _configs @@ -275,7 +276,7 @@ def layout(self): return self._layout def _layout_value(self): - if isinstance(self._layout, collections.Callable): + if isinstance(self._layout, _patch_collections_abc('Callable')): self._cached_layout = self._layout() else: self._cached_layout = self._layout @@ -284,7 +285,7 @@ def _layout_value(self): @layout.setter def layout(self, value): if (not isinstance(value, Component) and - not isinstance(value, collections.Callable)): + not isinstance(value, _patch_collections_abc('Callable'))): raise exceptions.NoLayoutException( '' 'Layout must be a dash component ' diff --git a/dash/development/base_component.py b/dash/development/base_component.py index 78592383cc..80b9734354 100644 --- a/dash/development/base_component.py +++ b/dash/development/base_component.py @@ -5,6 +5,8 @@ import six +from .._utils import patch_collections_abc + # pylint: disable=no-init,too-few-public-methods class ComponentRegistry: @@ -58,7 +60,7 @@ def _check_if_has_indexable_children(item): @six.add_metaclass(ComponentMeta) -class Component(collections.MutableMapping): +class Component(patch_collections_abc('MutableMapping')): class _UNDEFINED(object): def __repr__(self): return 'undefined' From ddac3c7d6469a78c8ca22cee817fa8141f9dc179 Mon Sep 17 00:00:00 2001 From: t4rk1n Date: Thu, 31 Jan 2019 21:33:13 -0500 Subject: [PATCH 2/3] :shirt: Fix (no-member) --- dash/_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dash/_utils.py b/dash/_utils.py index 0123e3bfce..45787ac940 100644 --- a/dash/_utils.py +++ b/dash/_utils.py @@ -42,6 +42,7 @@ def get_asset_path( ]) +# pylint: disable=no-member def patch_collections_abc(member): if six.PY2: return getattr(collections, member) From cd8fc620bf87b2d75240014908cf01160c070042 Mon Sep 17 00:00:00 2001 From: t4rk1n Date: Thu, 31 Jan 2019 21:37:07 -0500 Subject: [PATCH 3/3] :pencil: Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1139d839d9..015999416a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## UNRELEASED +## Fixed +- Fixed collections.abc deprecation warning for python 3.8 [#563](https://github.com/plotly/dash/pull/563) + ## [0.36.0] - 2019-01-25 ## Removed - Removed support for `Event` system. Use event properties instead, for example the `n_clicks` property instead of the `click` event, see [#531](https://github.com/plotly/dash/issues/531) for details. `dash_renderer` MUST be upgraded to >=0.17.0 together with this, and it is recommended to update `dash_core_components` to >=0.43.0 and `dash_html_components` to >=0.14.0. [#550](https://github.com/plotly/dash/pull/550)