diff --git a/.circleci/config.yml b/.circleci/config.yml index aa29eeabdf..3d93deb313 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -494,7 +494,6 @@ jobs: pip install -r dev-requirements.txt --quiet pip install -r python-requirements.txt --quiet pip install dash-package/dash-package.tar.gz[dev,testing] - pip uninstall -y dash-html-components dash-core-components - run: name: Build command: | diff --git a/dash/development/base_component.py b/dash/development/base_component.py index af7158bf38..7b63dccc5f 100644 --- a/dash/development/base_component.py +++ b/dash/development/base_component.py @@ -78,6 +78,8 @@ def __str__(self): REQUIRED = _REQUIRED() def __init__(self, **kwargs): + import dash # pylint: disable=import-outside-toplevel, cyclic-import + # pylint: disable=super-init-not-called for k, v in list(kwargs.items()): # pylint: disable=no-member @@ -88,12 +90,33 @@ def __init__(self, **kwargs): # e.g. "The dash_core_components.Dropdown component (version 1.6.0) # with the ID "my-dropdown" try: - error_string_prefix = "The `{}.{}` component (version {}){}".format( - self._namespace, - self._type, - getattr(__import__(self._namespace), "__version__", "unknown"), - ' with the ID "{}"'.format(kwargs["id"]) if "id" in kwargs else "", - ) + # Get fancy error strings that have the version numbers + error_string_prefix = "The `{}.{}` component (version {}){}" + # These components are part of dash now, so extract the dash version: + dash_packages = { + "dash_html_components": "html", + "dash_core_components": "dcc", + "dash_table": "dash_table", + } + if self._namespace in dash_packages: + error_string_prefix = error_string_prefix.format( + dash_packages[self._namespace], + self._type, + dash.__version__, + ' with the ID "{}"'.format(kwargs["id"]) + if "id" in kwargs + else "", + ) + else: + # Otherwise import the package and extract the version number + error_string_prefix = error_string_prefix.format( + self._namespace, + self._type, + getattr(__import__(self._namespace), "__version__", "unknown"), + ' with the ID "{}"'.format(kwargs["id"]) + if "id" in kwargs + else "", + ) except ImportError: # Our tests create mock components with libraries that # aren't importable diff --git a/requires-install.txt b/requires-install.txt index 3b9cb2ade8..476666fbf9 100644 --- a/requires-install.txt +++ b/requires-install.txt @@ -1,3 +1,6 @@ Flask>=1.0.4 flask-compress plotly>=5.0.0 +dash_html_components==2.0.0 +dash_core_components==2.0.0 +dash_table==5.0.0 diff --git a/tests/unit/development/test_base_component.py b/tests/unit/development/test_base_component.py index 76595c6464..7b1ed62f9a 100644 --- a/tests/unit/development/test_base_component.py +++ b/tests/unit/development/test_base_component.py @@ -3,6 +3,7 @@ import plotly import pytest +from dash import __version__ from dash import html from dash.development.base_component import Component @@ -458,7 +459,7 @@ def test_debc027_component_error_message(): with pytest.raises(TypeError) as e: html.Div(asdf=True) assert str(e.value) == ( - "The `Div` component " + "The `html.Div` component (version {}) ".format(__version__) + "received an unexpected " + "keyword argument: `asdf`\n" + "Allowed arguments: {}".format(", ".join(sorted(html.Div()._prop_names))) @@ -467,7 +468,7 @@ def test_debc027_component_error_message(): with pytest.raises(TypeError) as e: html.Div(asdf=True, id="my-component") assert str(e.value) == ( - "The `Div` component " + "The `html.Div` component (version {}) ".format(__version__) + 'with the ID "my-component" received an unexpected ' + "keyword argument: `asdf`\n" + "Allowed arguments: {}".format(", ".join(sorted(html.Div()._prop_names)))