Skip to content

Commit e88f019

Browse files
authored
Merge pull request #4101 from bmaranville/dont_precalculate_key_error
Dont precalculate key error
2 parents bb1d232 + c82aad7 commit e88f019

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

Diff for: packages/python/plotly/plotly/basedatatypes.py

+10-11
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 key not 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
@@ -4778,7 +4777,7 @@ def __contains__(self, prop):
47784777
else:
47794778
return False
47804779
else:
4781-
if obj is not None and p in obj._valid_props:
4780+
if hasattr(obj, "_valid_props") and p in obj._valid_props:
47824781
obj = obj[p]
47834782
else:
47844783
return False

0 commit comments

Comments
 (0)