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

Dont precalculate key error #4101

Merged
merged 4 commits into from
Mar 17, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 not key in plotly_obj and isinstance(plotly_obj, BaseLayoutType):
alexcjohnson marked this conversation as resolved.
Show resolved Hide resolved
# 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