Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9985b30

Browse filesBrowse files
clean up flake8 errors
1 parent e33e10b commit 9985b30
Copy full SHA for 9985b30

File tree

Expand file treeCollapse file tree

1 file changed

+12
-17
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-17
lines changed

‎packages/python/plotly/plotly/basedatatypes.py

Copy file name to clipboardExpand all lines: packages/python/plotly/plotly/basedatatypes.py
+12-17Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _check_path_in_prop_tree(obj, path, error_cast=None):
177177
an Exception object or None. The caller can raise this
178178
exception to see where the lookup error occurred.
179179
"""
180-
if type(path) == type(tuple()):
180+
if isinstance(path, tuple):
181181
path = _remake_path_from_tuple(path)
182182
prop, prop_idcs = _str_to_dict_path_full(path)
183183
prev_objs = []
@@ -242,7 +242,7 @@ def _check_path_in_prop_tree(obj, path, error_cast=None):
242242
# Make KeyError more pretty by changing it to a PlotlyKeyError,
243243
# because the Python interpreter has a special way of printing
244244
# KeyError
245-
if type(e) == type(KeyError()):
245+
if isinstance(e, KeyError):
246246
e = PlotlyKeyError()
247247
if error_cast is not None:
248248
e = error_cast()
@@ -282,7 +282,7 @@ def _indexing_combinations(dims, alls, product=False):
282282
for d, a in zip(dims, alls):
283283
if d == "all":
284284
d = a
285-
elif type(d) != type(list()):
285+
elif not isinstance(d, list):
286286
d = [d]
287287
r.append(d)
288288
if product:
@@ -293,7 +293,7 @@ def _indexing_combinations(dims, alls, product=False):
293293

294294
def _is_select_subplot_coordinates_arg(*args):
295295
""" 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)
297297

298298

299299
def _axis_spanning_shapes_docstr(shape_type):
@@ -1202,10 +1202,10 @@ def _selector_matches(obj, selector):
12021202
return True
12031203
# If selector is a string then put it at the 'type' key of a dictionary
12041204
# to select objects where "type":selector
1205-
if type(selector) == type(str()):
1205+
if isinstance(selector, six.string_types):
12061206
selector = dict(type=selector)
12071207
# 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):
12091209
# This returns True if selector is an empty dict
12101210
for k in selector:
12111211
if k not in obj:
@@ -1224,7 +1224,7 @@ def _selector_matches(obj, selector):
12241224
return False
12251225
return True
12261226
# 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):
12281228
return selector(obj)
12291229
else:
12301230
raise TypeError(
@@ -1247,15 +1247,15 @@ def _filter_by_selector(self, objects, funcs, selector):
12471247
"""
12481248

12491249
# 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):
12511251
funcs.append(lambda obj: self._selector_matches(obj, selector))
12521252

12531253
def _filt(last, f):
12541254
return filter(f, last)
12551255

12561256
filtered_objects = reduce(_filt, funcs, objects)
12571257

1258-
if type(selector) == type(int()):
1258+
if isinstance(selector, int):
12591259
return iter([list(filtered_objects)[selector]])
12601260

12611261
return filtered_objects
@@ -3941,14 +3941,10 @@ def _make_axis_spanning_layout_object(self, direction, shape):
39413941
"""
39423942
if direction == "vertical":
39433943
# fix y points to top and bottom of subplot
3944-
axis = "y"
39453944
ref = "yref"
3946-
axis_layout_key_template = "yaxis%s"
39473945
elif direction == "horizontal":
39483946
# fix x points to left and right of subplot
3949-
axis = "x"
39503947
ref = "xref"
3951-
axis_layout_key_template = "xaxis%s"
39523948
else:
39533949
raise ValueError(
39543950
"Bad direction: %s. Permissible values are 'vertical' and 'horizontal'."
@@ -4019,7 +4015,7 @@ def _process_multiple_axis_spanning_shapes(
40194015
):
40204016
n_layout_objs_after = len(self.layout[layout_obj])
40214017
if (n_layout_objs_after > n_layout_objs_before) and (
4022-
row == None and col == None
4018+
row is None and col is None
40234019
):
40244020
# this was called intending to add to a single plot (and
40254021
# self.add_{layout_obj} succeeded)
@@ -4132,7 +4128,7 @@ def _subplot_not_empty(self, xref, yref, selector="all"):
41324128
if not selector:
41334129
# If nothing to select was specified then a subplot is always deemed non-empty
41344130
return True
4135-
if selector == True:
4131+
if selector is True:
41364132
selector = "all"
41374133
if selector == "all":
41384134
selector = ["traces", "shapes", "annotations", "images"]
@@ -4302,7 +4298,6 @@ def _process_kwargs(self, **kwargs):
43024298
"""
43034299
Process any extra kwargs that are not predefined as constructor params
43044300
"""
4305-
invalid_kwargs = {}
43064301
for k, v in kwargs.items():
43074302
err = _check_path_in_prop_tree(self, k, error_cast=ValueError)
43084303
if err is None:
@@ -6277,7 +6272,7 @@ def _get_child_props(self, child):
62776272
# -------------------------------------
62786273
try:
62796274
trace_index = BaseFigure._index_is(self.data, child)
6280-
except ValueError as _:
6275+
except ValueError:
62816276
trace_index = None
62826277

62836278
# Child is a trace

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.