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

use OrderedDict in byteify #561

Merged
merged 3 commits into from
Feb 1, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions dash/development/_r_components_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
)

component$props <- filter_null(component$props)
structure(component, class = c('dash_component', 'list'))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this trailing whitespace wasn't caught by CI earlier... it's going to generate diffs in all the component packages that use it.


structure(component, class = c('dash_component', 'list'))
}}''' # noqa:E501

# the following strings represent all the elements in an object
Expand Down
8 changes: 5 additions & 3 deletions dash/development/component_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,13 @@ def cli():
# pylint: disable=undefined-variable
def byteify(input_object):
if isinstance(input_object, dict):
return {byteify(key): byteify(value)
for key, value in input_object.iteritems()}
return OrderedDict([
(byteify(key), byteify(value))
for key, value in input_object.iteritems()
])
elif isinstance(input_object, list):
return [byteify(element) for element in input_object]
elif isinstance(input_object, unicode): # noqa:F821
elif isinstance(input_object, unicode): # noqa:F821
return input_object.encode('utf-8')
return input_object

Expand Down
2 changes: 1 addition & 1 deletion tests/development/test_base_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def test_set_item_with_nested_children(self):

c3b = Component(id='3')
self.assertEqual(c5['3'], c3)
self.assertTrue(c5['3'] is not '3')
self.assertTrue(c5['3'] != '3')
self.assertTrue(c5['3'] is not c3b)

c5['3'] = c3b
Expand Down