Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
35 changes: 29 additions & 6 deletions dash/development/base_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions requires-install.txt
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions tests/unit/development/test_base_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import plotly
import pytest

from dash import __version__
from dash import html
from dash.development.base_component import Component

Expand Down Expand Up @@ -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)))
Expand All @@ -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)))
Expand Down