Skip to content

Commit f4be2b1

Browse files
Changed PlotlyKeyError's superclass to KeyError
But overrode the __str__ method.
1 parent c09c03e commit f4be2b1

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/python/plotly/_plotly_utils/exceptions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ def __init__(self, obj, path, notes=()):
8585
)
8686

8787

88-
class PlotlyKeyError(LookupError):
88+
class PlotlyKeyError(KeyError):
8989
"""
9090
KeyErrors are not printed as beautifully as other errors (this is so that
91-
{}[''] prints "KeyError: ''" and not "KeyError:"). So here we subclass
92-
LookupError to make a PlotlyKeyError object which will print nicer error
93-
messages for KeyErrors.
91+
{}[''] prints "KeyError: ''" and not "KeyError:"). So here we use
92+
LookupError's __str__ to make a PlotlyKeyError object which will print nicer
93+
error messages for KeyErrors.
9494
"""
9595

96-
pass
96+
def __str__(self):
97+
return LookupError.__str__(self)

packages/python/plotly/plotly/basedatatypes.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,9 +4066,6 @@ def __contains__(self, prop):
40664066
-------
40674067
bool
40684068
"""
4069-
# TODO: We don't want to throw an error in __contains__ because any code that
4070-
# relies on it returning False will have to be changed (it will have to
4071-
# have a try except block...).
40724069
prop = BaseFigure._str_to_dict_path(prop)
40734070

40744071
# Handle remapping

0 commit comments

Comments
 (0)