Skip to content

Commit

Permalink
Merge pull request #4101 from bmaranville/dont_precalculate_key_error
Browse files Browse the repository at this point in the history
Dont precalculate key error
  • Loading branch information
alexcjohnson committed Mar 17, 2023
2 parents bb1d232 + c82aad7 commit e88f019
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/python/plotly/plotly/basedatatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3862,18 +3862,17 @@ def _perform_update(plotly_obj, update_obj, overwrite=False):
# This should be valid even if xaxis2 hasn't been initialized:
# >>> layout.update(xaxis2={'title': 'xaxis 2'})
for key in update_obj:
# special handling for missing keys that match _subplot_re_match
if key not in plotly_obj and isinstance(plotly_obj, BaseLayoutType):
# try _subplot_re_match
match = plotly_obj._subplot_re_match(key)
if match:
# We need to create a subplotid object
plotly_obj[key] = {}
continue

err = _check_path_in_prop_tree(plotly_obj, key, error_cast=ValueError)
if err is not None:
if isinstance(plotly_obj, BaseLayoutType):
# try _subplot_re_match
match = plotly_obj._subplot_re_match(key)
if match:
# We need to create a subplotid object
plotly_obj[key] = {}
continue
# If no match, raise the error, which should already
# contain the _raise_on_invalid_property_error
# generated message
raise err

# Convert update_obj to dict
Expand Down Expand Up @@ -4778,7 +4777,7 @@ def __contains__(self, prop):
else:
return False
else:
if obj is not None and p in obj._valid_props:
if hasattr(obj, "_valid_props") and p in obj._valid_props:
obj = obj[p]
else:
return False
Expand Down

0 comments on commit e88f019

Please sign in to comment.