From 5e5a5fb9fcc8975db2bc988e2ee23513f1ce2030 Mon Sep 17 00:00:00 2001 From: chriddyp Date: Wed, 3 Jan 2018 16:33:49 -0500 Subject: [PATCH] flake8 fixes --- dash/dash.py | 4 ++-- dash/dependencies.py | 3 +++ dash/development/base_component.py | 37 +++++++++++++++++------------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/dash/dash.py b/dash/dash.py index 71f7d5ec54..bb6a13c62a 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -406,7 +406,7 @@ def _validate_callback(self, output, inputs, state, events): arg.component_id, arg.component_property, arg.component_id, - component.available_properties)\ + component.available_properties) .replace(' ', '')) if (hasattr(arg, 'component_event') and @@ -422,7 +422,7 @@ def _validate_callback(self, output, inputs, state, events): arg.component_id, arg.component_event, arg.component_id, - component.available_events)\ + component.available_events) .replace(' ', '')) if state and not events and not inputs: diff --git a/dash/dependencies.py b/dash/dependencies.py index 825dbf964c..0421860c11 100644 --- a/dash/dependencies.py +++ b/dash/dependencies.py @@ -4,18 +4,21 @@ def __init__(self, component_id, component_property): self.component_id = component_id self.component_property = component_property + # pylint: disable=old-style-class, too-few-public-methods class Input: def __init__(self, component_id, component_property): self.component_id = component_id self.component_property = component_property + # pylint: disable=old-style-class, too-few-public-methods class State: def __init__(self, component_id, component_property): self.component_id = component_id self.component_property = component_property + # pylint: disable=old-style-class, too-few-public-methods class Event: def __init__(self, component_id, component_event): diff --git a/dash/development/base_component.py b/dash/development/base_component.py index 5d875bafc1..42fbe901d5 100644 --- a/dash/development/base_component.py +++ b/dash/development/base_component.py @@ -24,10 +24,11 @@ def __init__(self, **kwargs): for k, v in list(kwargs.items()): if k not in self._prop_names: # pylint: disable=no-member # TODO - What's the right exception here? + # pylint: disable=no-member raise Exception( 'Unexpected keyword argument `{}`'.format(k) + '\nAllowed arguments: {}'.format( - ', '.join(sorted(self._prop_names)) # pylint: disable=no-member + ', '.join(sorted(self._prop_names)) ) ) setattr(self, k, v) @@ -43,12 +44,13 @@ def to_plotly_json(self): return as_json - - # pylint: disable=too-many-branches, too-many-return-statements, redefined-builtin, inconsistent-return-statements + # pylint: disable=too-many-branches, too-many-return-statements + # pylint: disable=redefined-builtin, inconsistent-return-statements def _get_set_or_delete(self, id, operation, new_item=None): _check_if_has_indexable_children(self) - # pylint: disable=access-member-before-definition, attribute-defined-outside-init + # pylint: disable=access-member-before-definition, + # pylint: disable=attribute-defined-outside-init if isinstance(self.children, Component): if getattr(self.children, 'id', None) is not None: # Woohoo! It's the item that we're looking for @@ -182,7 +184,8 @@ def __len__(self): return length -def generate_class(typename, props, description, namespace): # pylint: disable=unused-argument +# pylint: disable=unused-argument +def generate_class(typename, props, description, namespace): # Dynamically generate classes to have nicely formatted docstrings, # keyword arguments, and repr # Insired by http://jameso.be/2013/08/06/namedtuple.html @@ -234,28 +237,29 @@ def __repr__(self): repr(getattr(self, self._prop_names[0], None)) + ')') ''' - filtered_props = reorder_props(filter_props(props)) # pylint: disable=unused-variable - list_of_valid_keys = repr(list(filtered_props.keys())) # pylint: disable=unused-variable - docstring = create_docstring( # pylint: disable=unused-variable + # pylint: disable=unused-variable + filtered_props = reorder_props(filter_props(props)) + list_of_valid_keys = repr(list(filtered_props.keys())) + docstring = create_docstring( typename, filtered_props, parse_events(props), description ) - events = '[' + ', '.join(parse_events(props)) + ']' # pylint: disable=unused-variable + events = '[' + ', '.join(parse_events(props)) + ']' if 'children' in props: - default_argtext = 'children=None, **kwargs' # pylint: disable=unused-variable - argtext = 'children=children, **kwargs' # pylint: disable=unused-variable + default_argtext = 'children=None, **kwargs' + argtext = 'children=children, **kwargs' else: - default_argtext = '**kwargs' # pylint: disable=unused-variable - argtext = '**kwargs' # pylint: disable=unused-variable + default_argtext = '**kwargs' + argtext = '**kwargs' - required_args = required_props(props) # pylint: disable=unused-variable + required_args = required_props(props) d = c.format(**locals()) scope = {'Component': Component} - exec(d, scope) # pylint: disable=exec-used + exec(d, scope) result = scope[typename] return result @@ -355,7 +359,8 @@ def js_to_py_type(type_object): ])), # React's PropTypes.arrayOf - 'arrayOf': lambda: 'list'.format( # pylint: disable=too-many-format-args + # pylint: disable=too-many-format-args + 'arrayOf': lambda: 'list'.format( 'of {}s'.format(js_to_py_type(type_object['value'])) if js_to_py_type(type_object['value']) != '' else ''