Skip to content
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

Standard import "import io" should be placed before "from setuptools… #167

Merged
merged 5 commits into from
Nov 29, 2017
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
10 changes: 5 additions & 5 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ def _generate_config_html(self):

# Serve the JS bundles for each package
def serve_component_suites(self, package_name, path_in_package_dist):
if (package_name not in self.registered_paths):
if package_name not in self.registered_paths:
raise Exception(
'Error loading dependency.\n'
'"{}" is not a registered library.\n'
'Registered libraries are: {}'
.format(package_name, list(self.registered_paths.keys())))

elif (path_in_package_dist not in self.registered_paths[package_name]):
elif path_in_package_dist not in self.registered_paths[package_name]:
raise Exception(
'"{}" is registered but the path requested is not valid.\n'
'The path requested: "{}"\n'
Expand All @@ -284,7 +284,7 @@ def index(self, *args, **kwargs):
css = self._generate_css_dist_html()
config = self._generate_config_html()
title = getattr(self, 'title', 'Dash')
return ('''
return '''
<!DOCTYPE html>
<html>
<head>
Expand All @@ -304,7 +304,7 @@ def index(self, *args, **kwargs):
</footer>
</body>
</html>
'''.format(title, css, config, scripts))
'''.format(title, css, config, scripts)

def dependencies(self):
return flask.jsonify([
Expand Down Expand Up @@ -449,7 +449,7 @@ def _validate_callback(self, output, inputs, state, events):

callback_id = '{}.{}'.format(
output.component_id, output.component_property)
if (callback_id in self.callback_map):
if callback_id in self.callback_map:
raise exceptions.CantHaveMultipleOutputs('''
You have already assigned a callback to the output
with ID "{}" and property "{}". An output can only have
Expand Down
22 changes: 11 additions & 11 deletions dash/development/base_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,26 @@ def _get_set_or_delete(self, id, operation, new_item=None):
# - __len__

def __getitem__(self, id):
'''Recursively find the element with the given ID through the tree
"""Recursively find the element with the given ID through the tree
of children.
'''
"""

# A component's children can be undefined, a string, another component,
# or a list of components.
return self._get_set_or_delete(id, 'get')

def __setitem__(self, id, item):
'''Set an element by its ID
'''
"""Set an element by its ID
"""
return self._get_set_or_delete(id, 'set', item)

def __delitem__(self, id):
'''Delete items by ID in the tree of children
'''
"""Delete items by ID in the tree of children
"""
return self._get_set_or_delete(id, 'delete')

def traverse(self):
'''Yield each item in the tree'''
"""Yield each item in the tree"""
children = getattr(self, 'children', None)

# children is just a component
Expand All @@ -149,17 +149,17 @@ def traverse(self):
yield t

def __iter__(self):
'''Yield IDs in the tree of children
'''
"""Yield IDs in the tree of children
"""
for t in self.traverse():
if (isinstance(t, Component) and
getattr(t, 'id', None) is not None):

yield t.id

def __len__(self):
'''Return the number of items in the tree
'''
"""Return the number of items in the tree
"""
# TODO - Should we return the number of items that have IDs
# or just the number of items?
# The number of items is more intuitive but returning the number
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import io
from setuptools import setup, find_packages

import io

exec(open('dash/version.py').read())

setup(
Expand All @@ -11,7 +12,7 @@
packages=find_packages(exclude=['tests*']),
license='MIT',
description=('A Python framework for building reactive web-apps. '
'Developed by Plotly.'),
'Developed by Plotly.'),
long_description=io.open('README.md', encoding='utf-8').read(),
install_requires=[
'Flask>=0.12',
Expand Down
4 changes: 2 additions & 2 deletions tests/development/test_base_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@


def nested_tree():
'''This tree has a few unique properties:
"""This tree has a few unique properties:
- children is mixed strings and components (as in c2)
- children is just components (as in c)
- children is just strings (as in c1)
- children is just a single component (as in c3, c4)
- children contains numbers (as in c2)
- children contains "None" items (as in c2)
'''
"""
c1 = Component(
id='0.1.x.x.0',
children='string'
Expand Down