Skip to content

Commit 8a8eb08

Browse files
committed
Prefer __str__ over old prepare method.
1 parent b6419e8 commit 8a8eb08

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

plotly/exceptions.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def __init__(self, message='', path=(), notes=None, plain_message=''):
9595
else:
9696
self.notes = [notes]
9797
super(PlotlyGraphObjectError, self).__init__(message)
98-
self.prepare()
9998

10099
def add_note(self, note):
101100
if isinstance(note, list):
@@ -109,7 +108,7 @@ def add_to_error_path(self, path):
109108
else:
110109
self.path = [path] + self.path
111110

112-
def prepare(self):
111+
def __str__(self):
113112
message = self.message
114113
message += "\n\nPath To Error:\n["
115114
for iii, key in enumerate(self.path):
@@ -120,10 +119,7 @@ def prepare(self):
120119
if len(self.notes):
121120
message += "\n\nAdditional Notes:\n{0}".format(
122121
"\n".join(self.notes))
123-
if len(self.args) > 1:
124-
self.args = (message, self.args[1:][0])
125-
else:
126-
self.args = message,
122+
return message
127123

128124

129125
class PlotlyDictKeyError(PlotlyGraphObjectError):

plotly/graph_objs/graph_objs.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ def _value_to_graph_object(self, index, value, _raise=True):
213213
if _raise:
214214
e = exceptions.PlotlyListEntryError(self, index, value)
215215
e.path = self._get_path() + (index, )
216-
e.prepare()
217216
raise e
218217
else:
219218
return
@@ -425,7 +424,6 @@ def __setitem__(self, key, value, _raise=True):
425424
if _raise:
426425
e = exceptions.PlotlyDictKeyError(self, key)
427426
e.path = self._get_path() + (key, )
428-
e.prepare()
429427
raise e
430428
return
431429

@@ -537,7 +535,6 @@ def _value_to_graph_object(self, key, value, _raise=True):
537535
e = exceptions.PlotlyDictValueError(self, key, value,
538536
val_types)
539537
e.path = self._get_path() + (key, )
540-
e.prepare()
541538
raise e
542539
else:
543540
return
@@ -940,7 +937,6 @@ def _value_to_graph_object(self, index, value, _raise=True):
940937
if _raise:
941938
err = exceptions.PlotlyDataTypeError(self, index)
942939
err.path = self._get_path() + (0, )
943-
err.prepare()
944940
raise err
945941

946942
return GraphObjectFactory.create(item, _raise=_raise, _parent=self,

plotly/plotly/plotly.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ def iplot_mpl(fig, resize=True, strip_style=False, update=None,
299299
except exceptions.PlotlyGraphObjectError as err:
300300
err.add_note("Your updated figure could not be properly "
301301
"validated.")
302-
err.prepare()
303302
raise
304303
elif update is not None:
305304
raise exceptions.PlotlyGraphObjectError(
@@ -338,7 +337,6 @@ def plot_mpl(fig, resize=True, strip_style=False, update=None, **plot_options):
338337
except exceptions.PlotlyGraphObjectError as err:
339338
err.add_note("Your updated figure could not be properly "
340339
"validated.")
341-
err.prepare()
342340
raise
343341
elif update is not None:
344342
raise exceptions.PlotlyGraphObjectError(

0 commit comments

Comments
 (0)