Skip to content

Commit 1c75712

Browse files
authoredAug 5, 2018
Fix update method on empty and uninitialized array property (#1092)
* Fix for GH1072. Empty array properties are replaced during update * Don't error when a literal property is set to it's correct value. This avoids errors when performing updates like figure.update(data=[go.Scatter(...), ...]) * Fix two failing validator tests
1 parent 7ab0c90 commit 1c75712

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+253
-108
lines changed
 

‎_plotly_utils/basevalidators.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -1658,16 +1658,21 @@ class LiteralValidator(BaseValidator):
16581658
"""
16591659
Validator for readonly literal values
16601660
"""
1661-
def __init__(self, plotly_name, parent_name, **kwargs):
1662-
super(LiteralValidator, self).__init__(plotly_name=plotly_name,
1663-
parent_name=parent_name,
1664-
**kwargs)
1661+
def __init__(self, plotly_name, parent_name, val, **kwargs):
1662+
super(LiteralValidator, self).__init__(
1663+
plotly_name=plotly_name,
1664+
parent_name=parent_name,
1665+
**kwargs)
1666+
self.val = val
16651667

16661668
def validate_coerce(self, v):
1667-
raise ValueError("""\
1668-
The '{plotly_name}' property of {parent_name} is read-only""".format(
1669-
plotly_name=self.plotly_name, parent_name=self.parent_name
1670-
))
1669+
if v != self.val:
1670+
raise ValueError("""\
1671+
The '{plotly_name}' property of {parent_name} is read-only""".format(
1672+
plotly_name=self.plotly_name, parent_name=self.parent_name
1673+
))
1674+
else:
1675+
return v
16711676

16721677

16731678
class ImageUriValidator(BaseValidator):

‎_plotly_utils/tests/validators/test_basetraces_validator.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ def validator():
1010
'bar': 'Bar',
1111
'box': 'Box'},
1212
plotly_name='prop',
13-
parent_name='parent')
13+
parent_name='parent',
14+
set_uid=True)
1415

1516

1617
# Tests

0 commit comments

Comments
 (0)
Please sign in to comment.