@@ -177,7 +177,7 @@ def _check_path_in_prop_tree(obj, path, error_cast=None):
177
177
an Exception object or None. The caller can raise this
178
178
exception to see where the lookup error occurred.
179
179
"""
180
- if type (path ) == type ( tuple () ):
180
+ if isinstance (path , tuple ):
181
181
path = _remake_path_from_tuple (path )
182
182
prop , prop_idcs = _str_to_dict_path_full (path )
183
183
prev_objs = []
@@ -242,7 +242,7 @@ def _check_path_in_prop_tree(obj, path, error_cast=None):
242
242
# Make KeyError more pretty by changing it to a PlotlyKeyError,
243
243
# because the Python interpreter has a special way of printing
244
244
# KeyError
245
- if type ( e ) == type ( KeyError () ):
245
+ if isinstance ( e , KeyError ):
246
246
e = PlotlyKeyError ()
247
247
if error_cast is not None :
248
248
e = error_cast ()
@@ -282,7 +282,7 @@ def _indexing_combinations(dims, alls, product=False):
282
282
for d , a in zip (dims , alls ):
283
283
if d == "all" :
284
284
d = a
285
- elif type ( d ) != type ( list () ):
285
+ elif not isinstance ( d , list ):
286
286
d = [d ]
287
287
r .append (d )
288
288
if product :
@@ -293,7 +293,7 @@ def _indexing_combinations(dims, alls, product=False):
293
293
294
294
def _is_select_subplot_coordinates_arg (* args ):
295
295
""" Returns true if any args are lists or the string 'all' """
296
- return any ((a == "all" ) or ( type ( a ) == type ( list ()) ) for a in args )
296
+ return any ((a == "all" ) or isinstance ( a , list ) for a in args )
297
297
298
298
299
299
def _axis_spanning_shapes_docstr (shape_type ):
@@ -1202,10 +1202,10 @@ def _selector_matches(obj, selector):
1202
1202
return True
1203
1203
# If selector is a string then put it at the 'type' key of a dictionary
1204
1204
# to select objects where "type":selector
1205
- if type (selector ) == type ( str () ):
1205
+ if isinstance (selector , six . string_types ):
1206
1206
selector = dict (type = selector )
1207
1207
# If selector is a dict, compare the fields
1208
- if ( type ( selector ) == type ( dict ()) ) or isinstance (selector , BasePlotlyType ):
1208
+ if isinstance ( selector , dict ) or isinstance (selector , BasePlotlyType ):
1209
1209
# This returns True if selector is an empty dict
1210
1210
for k in selector :
1211
1211
if k not in obj :
@@ -1224,7 +1224,7 @@ def _selector_matches(obj, selector):
1224
1224
return False
1225
1225
return True
1226
1226
# If selector is a function, call it with the obj as the argument
1227
- elif type (selector ) == type ( lambda x : True ):
1227
+ elif six . callable (selector ):
1228
1228
return selector (obj )
1229
1229
else :
1230
1230
raise TypeError (
@@ -1247,15 +1247,15 @@ def _filter_by_selector(self, objects, funcs, selector):
1247
1247
"""
1248
1248
1249
1249
# if selector is not an int, we call it on each trace to test it for selection
1250
- if type (selector ) != type ( int () ):
1250
+ if not isinstance (selector , int ):
1251
1251
funcs .append (lambda obj : self ._selector_matches (obj , selector ))
1252
1252
1253
1253
def _filt (last , f ):
1254
1254
return filter (f , last )
1255
1255
1256
1256
filtered_objects = reduce (_filt , funcs , objects )
1257
1257
1258
- if type (selector ) == type ( int () ):
1258
+ if isinstance (selector , int ):
1259
1259
return iter ([list (filtered_objects )[selector ]])
1260
1260
1261
1261
return filtered_objects
@@ -3941,14 +3941,10 @@ def _make_axis_spanning_layout_object(self, direction, shape):
3941
3941
"""
3942
3942
if direction == "vertical" :
3943
3943
# fix y points to top and bottom of subplot
3944
- axis = "y"
3945
3944
ref = "yref"
3946
- axis_layout_key_template = "yaxis%s"
3947
3945
elif direction == "horizontal" :
3948
3946
# fix x points to left and right of subplot
3949
- axis = "x"
3950
3947
ref = "xref"
3951
- axis_layout_key_template = "xaxis%s"
3952
3948
else :
3953
3949
raise ValueError (
3954
3950
"Bad direction: %s. Permissible values are 'vertical' and 'horizontal'."
@@ -4019,7 +4015,7 @@ def _process_multiple_axis_spanning_shapes(
4019
4015
):
4020
4016
n_layout_objs_after = len (self .layout [layout_obj ])
4021
4017
if (n_layout_objs_after > n_layout_objs_before ) and (
4022
- row == None and col == None
4018
+ row is None and col is None
4023
4019
):
4024
4020
# this was called intending to add to a single plot (and
4025
4021
# self.add_{layout_obj} succeeded)
@@ -4132,7 +4128,7 @@ def _subplot_not_empty(self, xref, yref, selector="all"):
4132
4128
if not selector :
4133
4129
# If nothing to select was specified then a subplot is always deemed non-empty
4134
4130
return True
4135
- if selector == True :
4131
+ if selector is True :
4136
4132
selector = "all"
4137
4133
if selector == "all" :
4138
4134
selector = ["traces" , "shapes" , "annotations" , "images" ]
@@ -4302,7 +4298,6 @@ def _process_kwargs(self, **kwargs):
4302
4298
"""
4303
4299
Process any extra kwargs that are not predefined as constructor params
4304
4300
"""
4305
- invalid_kwargs = {}
4306
4301
for k , v in kwargs .items ():
4307
4302
err = _check_path_in_prop_tree (self , k , error_cast = ValueError )
4308
4303
if err is None :
@@ -6277,7 +6272,7 @@ def _get_child_props(self, child):
6277
6272
# -------------------------------------
6278
6273
try :
6279
6274
trace_index = BaseFigure ._index_is (self .data , child )
6280
- except ValueError as _ :
6275
+ except ValueError :
6281
6276
trace_index = None
6282
6277
6283
6278
# Child is a trace
0 commit comments