@@ -101,7 +101,8 @@ def __str__(self):
101
101
102
102
103
103
class PlotlyDictKeyError (PlotlyGraphObjectError ):
104
- def __init__ (self , obj = '' , key = '' , ** kwargs ):
104
+ def __init__ (self , obj , path = (), ** kwargs ):
105
+ key = path [- 1 ]
105
106
message = (
106
107
"Invalid key, '{key}', for class, '{obj_name}'.\n \n Run "
107
108
"'help(plotly.graph_objs.{obj_name})' for more information."
@@ -110,13 +111,14 @@ def __init__(self, obj='', key='', **kwargs):
110
111
plain_message = ("Invalid key, '{key}', found in '{obj}' object"
111
112
"" .format (key = key , obj = obj .__class__ .__name__ ))
112
113
super (PlotlyDictKeyError , self ).__init__ (message = message ,
113
- path = [ key ] ,
114
+ path = path ,
114
115
plain_message = plain_message ,
115
116
** kwargs )
116
117
117
118
118
119
class PlotlyDictValueError (PlotlyGraphObjectError ):
119
- def __init__ (self , obj = '' , key = '' , value = '' , val_types = '' , ** kwargs ):
120
+ def __init__ (self , obj , value , val_types , path = (), ** kwargs ):
121
+ key = path [- 1 ]
120
122
message = (
121
123
"Invalid value type, '{value_name}', associated with key, "
122
124
"'{key}', for class, '{obj_name}'.\n Valid types for this key "
@@ -130,12 +132,13 @@ def __init__(self, obj='', key='', value='', val_types='', **kwargs):
130
132
"'{key}'" .format (key = key , obj = obj .__class__ .__name__ ))
131
133
super (PlotlyDictValueError , self ).__init__ (message = message ,
132
134
plain_message = plain_message ,
133
- path = [ key ] ,
135
+ path = path ,
134
136
** kwargs )
135
137
136
138
137
139
class PlotlyListEntryError (PlotlyGraphObjectError ):
138
- def __init__ (self , obj = '' , index = '' , entry = '' , ** kwargs ):
140
+ def __init__ (self , obj , path = (), ** kwargs ):
141
+ index = path [- 1 ]
139
142
message = (
140
143
"The entry at index, '{0}', is invalid in a '{1}' object"
141
144
"" .format (index , obj .__class__ .__name__ )
@@ -146,12 +149,13 @@ def __init__(self, obj='', index='', entry='', **kwargs):
146
149
)
147
150
super (PlotlyListEntryError , self ).__init__ (message = message ,
148
151
plain_message = plain_message ,
149
- path = [ index ] ,
152
+ path = path ,
150
153
** kwargs )
151
154
152
155
153
156
class PlotlyDataTypeError (PlotlyGraphObjectError ):
154
- def __init__ (self , obj = '' , index = '' , ** kwargs ):
157
+ def __init__ (self , obj , path = (), ** kwargs ):
158
+ index = path [- 1 ]
155
159
message = (
156
160
"The entry at index, '{0}', is invalid because it does not "
157
161
"contain a valid 'type' key-value. This is required for valid "
@@ -163,7 +167,7 @@ def __init__(self, obj='', index='', **kwargs):
163
167
"lists." .format (index ))
164
168
super (PlotlyDataTypeError , self ).__init__ (message = message ,
165
169
plain_message = plain_message ,
166
- path = [ index ] ,
170
+ path = path ,
167
171
** kwargs )
168
172
169
173
0 commit comments