Skip to content

Commit f5846c7

Browse files
committed
check for keys to be added to plotly_obj before calculating error message
1 parent 8a151e1 commit f5846c7

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

packages/python/plotly/plotly/basedatatypes.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,18 +3862,17 @@ def _perform_update(plotly_obj, update_obj, overwrite=False):
38623862
# This should be valid even if xaxis2 hasn't been initialized:
38633863
# >>> layout.update(xaxis2={'title': 'xaxis 2'})
38643864
for key in update_obj:
3865+
# special handling for missing keys that match _subplot_re_match
3866+
if not key in plotly_obj and isinstance(plotly_obj, BaseLayoutType):
3867+
# try _subplot_re_match
3868+
match = plotly_obj._subplot_re_match(key)
3869+
if match:
3870+
# We need to create a subplotid object
3871+
plotly_obj[key] = {}
3872+
continue
3873+
38653874
err = _check_path_in_prop_tree(plotly_obj, key, error_cast=ValueError)
38663875
if err is not None:
3867-
if isinstance(plotly_obj, BaseLayoutType):
3868-
# try _subplot_re_match
3869-
match = plotly_obj._subplot_re_match(key)
3870-
if match:
3871-
# We need to create a subplotid object
3872-
plotly_obj[key] = {}
3873-
continue
3874-
# If no match, raise the error, which should already
3875-
# contain the _raise_on_invalid_property_error
3876-
# generated message
38773876
raise err
38783877

38793878
# Convert update_obj to dict

0 commit comments

Comments
 (0)