Skip to content

Commit

Permalink
Merge pull request #561 from plotly/ordered-byteify
Browse files Browse the repository at this point in the history
use OrderedDict in byteify
  • Loading branch information
alexcjohnson committed Feb 1, 2019
2 parents c9b392d + 51e23c1 commit 0f27d78
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
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'))
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

0 comments on commit 0f27d78

Please sign in to comment.