Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.3k
Remove events#550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Remove events #550
Changes from all commits
2ed3989a79f0beeb4f55f9fea7cf981da6f3227715ec9aaeed10a59e2f5e2762c9a3c8a4fa99755b8d13File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,6 +3,7 @@ | ||
| import os | ||
| from dash.development.base_component import _explicitize_args | ||
| from dash.exceptions import NonExistentEventException | ||
| from ._all_keywords import python_keywords | ||
| from .base_component import Component | ||
| @@ -27,8 +28,7 @@ def generate_class_string(typename, props, description, namespace): | ||
| string | ||
| """ | ||
| # TODO _prop_names, _type, _namespace, available_events, | ||
| # and available_properties | ||
| # TODO _prop_names, _type, _namespace, and available_properties | ||
| # can be modified by a Dash JS developer via setattr | ||
| # TODO - Tab out the repr for the repr of these components to make it | ||
| # look more like a hierarchical tree | ||
| @@ -52,7 +52,6 @@ def __init__(self, {default_argtext}): | ||
| self._namespace = '{namespace}' | ||
| self._valid_wildcard_attributes =\ | ||
| {list_of_valid_wildcard_attr_prefixes} | ||
| self.available_events = {events} | ||
| self.available_properties = {list_of_valid_keys} | ||
| self.available_wildcard_properties =\ | ||
| {list_of_valid_wildcard_attr_prefixes} | ||
| @@ -101,11 +100,11 @@ def __repr__(self): | ||
| docstring = create_docstring( | ||
| component_name=typename, | ||
| props=filtered_props, | ||
| events=parse_events(props), | ||
| description=description).replace('\r\n', '\n') | ||
| prohibit_events(props) | ||
| # pylint: disable=unused-variable | ||
| events = '[' + ', '.join(parse_events(props)) + ']' | ||
| prop_keys = list(props.keys()) | ||
| if 'children' in props: | ||
| prop_keys.remove('children') | ||
| @@ -122,7 +121,7 @@ def __repr__(self): | ||
| for p in prop_keys | ||
| if not p.endswith("-*") and | ||
| p not in python_keywords and | ||
| p not in ['dashEvents', 'fireEvent', 'setProps']] + ['**kwargs'] | ||
| p != 'setProps'] + ['**kwargs'] | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if that was intentional but still present for the R generation
| ||
| ) | ||
| required_args = required_props(props) | ||
| @@ -233,7 +232,7 @@ def required_props(props): | ||
| if prop['required']] | ||
| def create_docstring(component_name, props, events, description): | ||
| def create_docstring(component_name, props, description): | ||
| """ | ||
| Create the Dash component docstring | ||
| @@ -243,8 +242,6 @@ def create_docstring(component_name, props, events, description): | ||
| Component name | ||
| props: dict | ||
| Dictionary with {propName: propMetadata} structure | ||
| events: list | ||
| List of Dash events | ||
| description: str | ||
| Component description | ||
| @@ -259,9 +256,7 @@ def create_docstring(component_name, props, events, description): | ||
| return ( | ||
| """A {name} component.\n{description} | ||
| Keyword arguments:\n{args} | ||
| Available events: {events}""" | ||
| Keyword arguments:\n{args}""" | ||
| ).format( | ||
| name=component_name, | ||
| description=description, | ||
| @@ -274,30 +269,26 @@ def create_docstring(component_name, props, events, description): | ||
| description=prop['description'], | ||
| indent_num=0, | ||
| is_flow_type='flowType' in prop and 'type' not in prop) | ||
| for p, prop in list(filter_props(props).items())), | ||
| events=', '.join(events)) | ||
| for p, prop in list(filter_props(props).items()))) | ||
| def parse_events(props): | ||
| def prohibit_events(props): | ||
| """ | ||
| Pull out the dashEvents from the Component props | ||
| Events have been removed. Raise an error if we see dashEvents or fireEvents | ||
| Parameters | ||
| ---------- | ||
| props: dict | ||
| Dictionary with {propName: propMetadata} structure | ||
| Returns | ||
| Raises | ||
| ------- | ||
| list | ||
| List of Dash event strings | ||
| ? | ||
| """ | ||
| if 'dashEvents' in props and props['dashEvents']['type']['name'] == 'enum': | ||
| events = [v['value'] for v in props['dashEvents']['type']['value']] | ||
| else: | ||
| events = [] | ||
| return events | ||
| if 'dashEvents' in props or 'fireEvents' in props: | ||
| raise NonExistentEventException( | ||
| 'Events are no longer supported by dash. Use properties instead, ' | ||
| 'eg `n_clicks` instead of a `click` event.') | ||
| def parse_wildcards(props): | ||
| @@ -349,7 +340,6 @@ def filter_props(props): | ||
| Filter props from the Component arguments to exclude: | ||
| - Those without a "type" or a "flowType" field | ||
| - Those with arg.type.name in {'func', 'symbol', 'instanceOf'} | ||
| - dashEvents as a name | ||
| Parameters | ||
| ---------- | ||
| @@ -415,10 +405,6 @@ def filter_props(props): | ||
| else: | ||
| raise ValueError | ||
| # dashEvents are a special oneOf property that is used for subscribing | ||
| # to events but it's never set as a property | ||
| if arg_name in ['dashEvents']: | ||
| filtered_props.pop(arg_name) | ||
| return filtered_props | ||
| @@ -518,7 +504,7 @@ def map_js_to_py_types_prop_types(type_object): | ||
| ', '.join( | ||
| "'{}'".format(t) | ||
| for t in list(type_object['value'].keys())), | ||
| 'Those keys have the following types:\n{}'.format( | ||
| 'Those keys have the following types:\n{}'.format( | ||
| '\n'.join(create_prop_docstring( | ||
| prop_name=prop_name, | ||
| type_object=prop, | ||
| @@ -561,7 +547,7 @@ def map_js_to_py_types_flow_types(type_object): | ||
| signature=lambda indent_num: 'dict containing keys {}.\n{}'.format( | ||
| ', '.join("'{}'".format(d['key']) | ||
| for d in type_object['signature']['properties']), | ||
| '{}Those keys have the following types:\n{}'.format( | ||
| '{}Those keys have the following types:\n{}'.format( | ||
| ' ' * indent_num, | ||
| '\n'.join( | ||
| create_prop_docstring( | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| EXIT_STATE=0 | ||
| python -m unittest tests.development.test_base_component || EXIT_STATE=$? | ||
| python -m unittest tests.development.test_component_loader || EXIT_STATE=$? | ||
| python -m unittest tests.test_integration || EXIT_STATE=$? | ||
| python -m unittest tests.test_resources || EXIT_STATE=$? | ||
| python -m unittest tests.test_configs || EXIT_STATE=$? | ||
| pylint dash setup.py --rcfile=$PYLINTRC || EXIT_STATE=$? | ||
| pylint tests -d all -e C0410,C0411,C0412,C0413,W0109 || EXIT_STATE=$? | ||
| flake8 dash setup.py || EXIT_STATE=$? | ||
| flake8 --ignore=E123,E126,E501,E722,E731,F401,F841,W503,W504 --exclude=metadata_test.py tests || EXIT_STATE=$? | ||
| if [ $EXIT_STATE -ne 0 ]; then | ||
alexcjohnson marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| echo "One or more tests failed" | ||
| else | ||
| echo "All tests passed!" | ||
| fi | ||
| exit $EXIT_STATE | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we include the linting also ? CollaboratorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! I'll move linting in here too. CollaboratorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. linting into test.sh -> 2c9a3c8 | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍