From 76d6fbbcba5fc55894865e5db7a8ec9335185a6e Mon Sep 17 00:00:00 2001 From: Ryan Marren Date: Tue, 7 Aug 2018 18:28:52 -0400 Subject: [PATCH 1/4] Fix #321, add test case for prop-less components. --- CHANGELOG.md | 4 ++++ dash/development/base_component.py | 4 ++-- dash/version.py | 2 +- dev-requirements.txt | 1 + tests/test_integration.py | 12 ++++++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ed3850535..a3606e8703 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.23.2 - 2018-08-07 +## Fixed +- Fixed error in 0.23.1 where importing Dash components with no props would result in an error. (Fixes [#321](https://github.com/plotly/dash/issues/321)). + ## 0.23.1 - 2018-08-02 ## Added - Add ie-compat meta tag to the index by default. [#316](https://github.com/plotly/dash/pull/316) diff --git a/dash/development/base_component.py b/dash/development/base_component.py index 274d104148..ddf2fd7fda 100644 --- a/dash/development/base_component.py +++ b/dash/development/base_component.py @@ -303,7 +303,7 @@ def generate_class_string(typename, props, description, namespace): c = '''class {typename}(Component): """{docstring}""" @_explicitize_args - def __init__(self, {default_argtext}, **kwargs): + def __init__(self, {default_argtext}): self._prop_names = {list_of_valid_keys} self._type = '{typename}' self._namespace = '{namespace}' @@ -378,7 +378,7 @@ def __repr__(self): '{:s}=Component.UNDEFINED'.format(p)) for p in prop_keys if not p.endswith("-*") and - p not in ['dashEvents', 'fireEvent', 'setProps']] + p not in ['dashEvents', 'fireEvent', 'setProps']] + ['**kwargs'] ) required_args = required_props(props) diff --git a/dash/version.py b/dash/version.py index db714a8550..5a983c9e12 100644 --- a/dash/version.py +++ b/dash/version.py @@ -1 +1 @@ -__version__ = '0.23.1' +__version__ = '0.23.2' diff --git a/dev-requirements.txt b/dev-requirements.txt index f667e354c3..03d5fc2772 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,7 @@ dash_core_components>=0.4.0 dash_html_components>=0.11.0rc1 dash_flow_example==0.0.3 +dash-dangerously-set-inner-html dash_renderer percy selenium diff --git a/tests/test_integration.py b/tests/test_integration.py index 2e8a2c75dc..9b36f45d88 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -6,6 +6,7 @@ import dash_html_components as html import dash_core_components as dcc import dash_flow_example +import dash_dangerously_set_inner_html import dash import time @@ -235,6 +236,17 @@ def test_wildcard_data_attributes(self): assert_clean_console(self) + def test_no_props_component(self): + app = dash.Dash() + app.layout = html.Div([ + dash_dangerously_set_inner_html.DangerouslySetInnerHTML(''' +

No Props Component

+ ''') + ]) + self.startServer(app) + assert_clean_console(self) + self.percy_snapshot(name='no-props-component') + def test_flow_component(self): app = dash.Dash() From 3aea0fbe1af8002b2f3c58621a548459bae909e9 Mon Sep 17 00:00:00 2001 From: Ryan Marren Date: Wed, 8 Aug 2018 10:39:54 -0400 Subject: [PATCH 2/4] Fix dash-html-components/issues/54, add test for python keyword props --- dash/development/base_component.py | 2 ++ tests/development/metadata_test.json | 7 +++++++ tests/development/metadata_test.py | 5 +++-- tests/development/test_base_component.py | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dash/development/base_component.py b/dash/development/base_component.py index ddf2fd7fda..387a198ce0 100644 --- a/dash/development/base_component.py +++ b/dash/development/base_component.py @@ -2,6 +2,7 @@ import copy import os import inspect +import keyword def is_number(s): @@ -378,6 +379,7 @@ def __repr__(self): '{:s}=Component.UNDEFINED'.format(p)) for p in prop_keys if not p.endswith("-*") and + p not in keyword.kwlist and p not in ['dashEvents', 'fireEvent', 'setProps']] + ['**kwargs'] ) diff --git a/tests/development/metadata_test.json b/tests/development/metadata_test.json index a815b053ea..1da85ba814 100644 --- a/tests/development/metadata_test.json +++ b/tests/development/metadata_test.json @@ -221,6 +221,13 @@ "required": false, "description": "" }, + "in": { + "type": { + "name": "string" + }, + "required": false, + "description": "" + }, "id": { "type": { "name": "string" diff --git a/tests/development/metadata_test.py b/tests/development/metadata_test.py index de56679fc9..1074ff0e51 100644 --- a/tests/development/metadata_test.py +++ b/tests/development/metadata_test.py @@ -34,17 +34,18 @@ class Table(Component): - customArrayProp (list; optional) - data-* (string; optional) - aria-* (string; optional) +- in (string; optional) - id (string; optional) Available events: 'restyle', 'relayout', 'click'""" @_explicitize_args def __init__(self, children=None, optionalArray=Component.UNDEFINED, optionalBool=Component.UNDEFINED, optionalFunc=Component.UNDEFINED, optionalNumber=Component.UNDEFINED, optionalObject=Component.UNDEFINED, optionalString=Component.UNDEFINED, optionalSymbol=Component.UNDEFINED, optionalNode=Component.UNDEFINED, optionalElement=Component.UNDEFINED, optionalMessage=Component.UNDEFINED, optionalEnum=Component.UNDEFINED, optionalUnion=Component.UNDEFINED, optionalArrayOf=Component.UNDEFINED, optionalObjectOf=Component.UNDEFINED, optionalObjectWithShapeAndNestedDescription=Component.UNDEFINED, optionalAny=Component.UNDEFINED, customProp=Component.UNDEFINED, customArrayProp=Component.UNDEFINED, id=Component.UNDEFINED, **kwargs): - self._prop_names = ['children', 'optionalArray', 'optionalBool', 'optionalNumber', 'optionalObject', 'optionalString', 'optionalNode', 'optionalElement', 'optionalEnum', 'optionalUnion', 'optionalArrayOf', 'optionalObjectOf', 'optionalObjectWithShapeAndNestedDescription', 'optionalAny', 'customProp', 'customArrayProp', 'data-*', 'aria-*', 'id'] + self._prop_names = ['children', 'optionalArray', 'optionalBool', 'optionalNumber', 'optionalObject', 'optionalString', 'optionalNode', 'optionalElement', 'optionalEnum', 'optionalUnion', 'optionalArrayOf', 'optionalObjectOf', 'optionalObjectWithShapeAndNestedDescription', 'optionalAny', 'customProp', 'customArrayProp', 'data-*', 'aria-*', 'in', 'id'] self._type = 'Table' self._namespace = 'TableComponents' self._valid_wildcard_attributes = ['data-', 'aria-'] self.available_events = ['restyle', 'relayout', 'click'] - self.available_properties = ['children', 'optionalArray', 'optionalBool', 'optionalNumber', 'optionalObject', 'optionalString', 'optionalNode', 'optionalElement', 'optionalEnum', 'optionalUnion', 'optionalArrayOf', 'optionalObjectOf', 'optionalObjectWithShapeAndNestedDescription', 'optionalAny', 'customProp', 'customArrayProp', 'data-*', 'aria-*', 'id'] + self.available_properties = ['children', 'optionalArray', 'optionalBool', 'optionalNumber', 'optionalObject', 'optionalString', 'optionalNode', 'optionalElement', 'optionalEnum', 'optionalUnion', 'optionalArrayOf', 'optionalObjectOf', 'optionalObjectWithShapeAndNestedDescription', 'optionalAny', 'customProp', 'customArrayProp', 'data-*', 'aria-*', 'in', 'id'] self.available_wildcard_properties = ['data-', 'aria-'] _explicit_args = kwargs.pop('_explicit_args') diff --git a/tests/development/test_base_component.py b/tests/development/test_base_component.py index 625e5329cb..133e9c5b5a 100644 --- a/tests/development/test_base_component.py +++ b/tests/development/test_base_component.py @@ -808,6 +808,8 @@ def setUp(self): ['aria-*', 'string'], + ['in', 'string'], + ['id', 'string'], ['dashEvents', "a value equal to: 'restyle', 'relayout', 'click'"] @@ -885,6 +887,7 @@ def assert_docstring(assertEqual, docstring): "- customArrayProp (list; optional)", '- data-* (string; optional)', '- aria-* (string; optional)', + '- in (string; optional)', '- id (string; optional)', '', "Available events: 'restyle', 'relayout', 'click'", From 6f42579d81ce0fae6b6ed3d381d7bc1cabf7924d Mon Sep 17 00:00:00 2001 From: Ryan Marren Date: Wed, 8 Aug 2018 10:44:13 -0400 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3606e8703..ddae4c72bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.23.2 - 2018-08-07 ## Fixed -- Fixed error in 0.23.1 where importing Dash components with no props would result in an error. (Fixes [#321](https://github.com/plotly/dash/issues/321)). +- Fixed bug in 0.23.1 where importing Dash components with no props would result in an error. (Fixes [#321](https://github.com/plotly/dash/issues/321)). +- Fixed bug in 0.23.1 where importing components with arguments that are python keywords could cause an error. ## 0.23.1 - 2018-08-02 ## Added From 1d0f19adbc54540997d99a5f0f4b60558d4bdeec Mon Sep 17 00:00:00 2001 From: Ryan Marren Date: Fri, 10 Aug 2018 19:54:23 -0400 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddae4c72bd..f2f5dcb390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.23.2 - 2018-08-07 ## Fixed - Fixed bug in 0.23.1 where importing Dash components with no props would result in an error. (Fixes [#321](https://github.com/plotly/dash/issues/321)). -- Fixed bug in 0.23.1 where importing components with arguments that are python keywords could cause an error. +- Fixed bug in 0.23.1 where importing components with arguments that are python keywords could cause an error. In particular, this fixes `dash-html-components` while using Python 3.7. ## 0.23.1 - 2018-08-02 ## Added