Skip to content

Commit bac2e22

Browse files
committed
pep8 graph_objs.py, import OBJ_MAP directly
1 parent d45f0fc commit bac2e22

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

Diff for: plotly/graph_objs/graph_objs.py

+33-16
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
import warnings
2828
import six
2929
from plotly.graph_objs import graph_objs_tools
30-
from plotly.graph_objs.graph_objs_tools import INFO, KEY_TO_NAME, NAME_TO_KEY
30+
from plotly.graph_objs.graph_objs_tools import (
31+
INFO, OBJ_MAP, NAME_TO_KEY, KEY_TO_NAME
32+
)
3133
import copy
3234
from plotly import exceptions
3335
import sys
@@ -192,12 +194,17 @@ def validate(self, caller=True):
192194
raise
193195
else:
194196
raise exceptions.PlotlyGraphObjectError( # TODO!!!
195-
message="uh-oh, this error shouldn't have happenend.",
196-
plain_message="uh-oh, this error shouldn't have happenend.",
197+
message=(
198+
"uh-oh, this error shouldn't have happenend."
199+
),
200+
plain_message=(
201+
"uh-oh, this error shouldn't have happenend."
202+
),
197203
path=[index],
198204
)
199205

200-
def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
206+
def to_string(self, level=0, indent=4, eol='\n',
207+
pretty=True, max_chars=80):
201208
"""Returns a formatted string showing graph_obj constructors.
202209
203210
Example:
@@ -229,7 +236,8 @@ def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
229236
string += ",{eol}{indent}".format(
230237
eol=eol,
231238
indent=' ' * indent * (level + 1))
232-
string += "{eol}{indent}])".format(eol=eol, indent=' ' * indent * level)
239+
string += (
240+
"{eol}{indent}])").format(eol=eol, indent=' ' * indent * level)
233241
return string
234242

235243
def get_ordered(self, caller=True):
@@ -394,7 +402,8 @@ def get_data(self):
394402
d[key] = val.get_data()
395403
else:
396404
try:
397-
if INFO[obj_key][key]['type'] == 'data': # TODO: Update the JSON
405+
# TODO: Update the JSON
406+
if INFO[obj_key][key]['type'] == 'data':
398407
d[key] = val
399408
except KeyError:
400409
pass
@@ -521,7 +530,8 @@ def validate(self, caller=True): # TODO: validate values too?
521530
val_types=val_types
522531
)
523532
else:
524-
matching_objects = [obj for obj in INFO if key in INFO[obj]]
533+
matching_objects = [obj for obj in
534+
INFO if key in INFO[obj]]
525535
notes = ''
526536
if len(matching_objects):
527537
notes += "That key is valid only in these objects:\n\n"
@@ -540,7 +550,8 @@ def validate(self, caller=True): # TODO: validate values too?
540550
key=key,
541551
notes=notes)
542552

543-
def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
553+
def to_string(self, level=0, indent=4, eol='\n',
554+
pretty=True, max_chars=80):
544555
"""Returns a formatted string showing graph_obj constructors.
545556
546557
Example:
@@ -677,7 +688,7 @@ class Data(PlotlyList):
677688
678689
Data([Scatter(), Heatmap(), Box()])
679690
680-
Valid entry types: (dict or any subclass of Trace, i.e., Scatter, Box, etc.)
691+
Valid entry types: (dict or any Trace subclass, e.g. Scatter, Box, etc.)
681692
682693
"""
683694
def to_graph_objs(self, caller=True): # TODO TODO TODO! check logic!
@@ -709,8 +720,10 @@ def to_graph_objs(self, caller=True): # TODO TODO TODO! check logic!
709720
raise exceptions.PlotlyListEntryError(
710721
obj=self,
711722
index=index,
712-
notes="The entry could not be converted into a PlotlyTrace "
713-
"object (e.g., Scatter, Heatmap, Bar, etc).",
723+
notes=(
724+
"The entry could not be converted into a PlotlyTrace "
725+
"object (e.g., Scatter, Heatmap, Bar, etc)."
726+
),
714727
)
715728
super(Data, self).to_graph_objs(caller=caller)
716729

@@ -759,8 +772,10 @@ def to_graph_objs(self, caller=True):
759772
raise exceptions.PlotlyListEntryError(
760773
obj=self,
761774
index=index,
762-
notes="The entry could not be converted into an Annotation "
763-
"object because it was not a dictionary.",
775+
notes=(
776+
"The entry could not be converted into an Annotation "
777+
"object because it was not a dictionary."
778+
),
764779
)
765780
super(Annotations, self).to_graph_objs(caller=caller)
766781

@@ -786,7 +801,8 @@ def __init__(self, *args, **kwargs):
786801
"dictionary-like plot types.\nIt is not meant to be "
787802
"a user interface.")
788803

789-
def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
804+
def to_string(self, level=0, indent=4, eol='\n',
805+
pretty=True, max_chars=80):
790806
"""Returns a formatted string showing graph_obj constructors.
791807
792808
Example:
@@ -896,7 +912,8 @@ def to_graph_objs(self, caller=True):
896912
self[key] = obj # call to super will call 'to_graph_objs'
897913
super(Layout, self).to_graph_objs(caller=caller)
898914

899-
def to_string(self, level=0, indent=4, eol='\n', pretty=True, max_chars=80):
915+
def to_string(self, level=0, indent=4, eol='\n',
916+
pretty=True, max_chars=80):
900917
"""Returns a formatted string showing graph_obj constructors.
901918
902919
Example:
@@ -1052,7 +1069,7 @@ def _factory(name, *args, **kwargs):
10521069
# bases are the base classes that the new class inherits from
10531070
# dict holds attributes for the new class, e.g., __doc__
10541071
# why? because __doc__ isn't writeable after-the-fact!
1055-
for obj in graph_objs_tools.OBJ_MAP:
1072+
for obj in OBJ_MAP:
10561073
if obj not in globals():
10571074
base_name = graph_objs_tools.OBJ_MAP[obj]['base_name']
10581075
if base_name == 'PlotlyList':

0 commit comments

Comments
 (0)