Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
99 changes: 72 additions & 27 deletions _plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ def __init__(self, plotly_name, parent_name, **kwargs):
def description(self):
return """\
The '{plotly_name}' property is an array that may be specified as a tuple,
list, numpy array, or pandas Series""".format(plotly_name=self.plotly_name)
list, numpy array, or pandas Series""".format(
plotly_name=self.plotly_name
)

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
Expand Down Expand Up @@ -559,7 +561,9 @@ def description(self):
desc
+ """
- One of the following enumeration values:
{enum_vals_str}""".format(enum_vals_str=enum_vals_str)
{enum_vals_str}""".format(
enum_vals_str=enum_vals_str
)
)

if enum_regexs:
Expand All @@ -576,7 +580,9 @@ def description(self):
desc
+ """
- A string that matches one of the following regular expressions:
{enum_regexs_str}""".format(enum_regexs_str=enum_regexs_str)
{enum_regexs_str}""".format(
enum_regexs_str=enum_regexs_str
)
)

if self.array_ok:
Expand Down Expand Up @@ -647,7 +653,9 @@ def __init__(self, plotly_name, parent_name, array_ok=False, **kwargs):
def description(self):
desc = """\
The '{plotly_name}' property is a boolean and must be specified as:
- A boolean value: True or False""".format(plotly_name=self.plotly_name)
- A boolean value: True or False""".format(
plotly_name=self.plotly_name
)
if self.array_ok:
desc += """
- A tuple or list of the above"""
Expand Down Expand Up @@ -678,7 +686,9 @@ def __init__(self, plotly_name, parent_name, **kwargs):
def description(self):
return """\
The '{plotly_name}' property must be specified as a string or
as a plotly.grid_objs.Column object""".format(plotly_name=self.plotly_name)
as a plotly.grid_objs.Column object""".format(
plotly_name=self.plotly_name
)

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
Expand Down Expand Up @@ -899,10 +909,13 @@ def description(self):

# Extras
if self.extras:
desc = desc + (
"""
desc = (
desc
+ (
"""
OR exactly one of {extras} (e.g. '{eg_extra}')"""
).format(extras=self.extras, eg_extra=self.extras[-1])
).format(extras=self.extras, eg_extra=self.extras[-1])
)

if self.array_ok:
desc = (
Expand Down Expand Up @@ -1049,7 +1062,9 @@ def description(self):
desc
+ """
- One of the following strings:
{valid_str}""".format(valid_str=valid_str)
{valid_str}""".format(
valid_str=valid_str
)
)
else:
desc = (
Expand Down Expand Up @@ -1349,7 +1364,9 @@ def description(self):
valid_color_description
+ """
- A number that will be interpreted as a color
according to {colorscale_path}""".format(colorscale_path=self.colorscale_path)
according to {colorscale_path}""".format(
colorscale_path=self.colorscale_path
)
)

if self.array_ok:
Expand Down Expand Up @@ -1500,7 +1517,9 @@ def description(self):
return """\
The '{plotly_name}' property is a colorlist that may be specified
as a tuple, list, one-dimensional numpy array, or pandas Series of valid
color strings""".format(plotly_name=self.plotly_name)
color strings""".format(
plotly_name=self.plotly_name
)

def validate_coerce(self, v):
if is_none_or_typed_array_spec(v):
Expand Down Expand Up @@ -1598,7 +1617,9 @@ def description(self):
- One of the following named colorscales:
{colorscales_str}.
Appending '_r' to a named colorscale reverses it.
""".format(plotly_name=self.plotly_name, colorscales_str=colorscales_str)
""".format(
plotly_name=self.plotly_name, colorscales_str=colorscales_str
)

return desc

Expand Down Expand Up @@ -1857,18 +1878,24 @@ def description(self):
).format(plotly_name=self.plotly_name)

# Flags
desc = desc + (
"""
desc = (
desc
+ (
"""
- Any combination of {flags} joined with '+' characters
(e.g. '{eg_flag}')"""
).format(flags=self.flags, eg_flag="+".join(self.flags[:2]))
).format(flags=self.flags, eg_flag="+".join(self.flags[:2]))
)

# Extras
if self.extras:
desc = desc + (
"""
desc = (
desc
+ (
"""
OR exactly one of {extras} (e.g. '{eg_extra}')"""
).format(extras=self.extras, eg_extra=self.extras[-1])
).format(extras=self.extras, eg_extra=self.extras[-1])
)

if self.array_ok:
desc = (
Expand Down Expand Up @@ -1949,7 +1976,9 @@ def __init__(self, plotly_name, parent_name, values=None, array_ok=False, **kwar
def description(self):
desc = """\
The '{plotly_name}' property accepts values of any type
""".format(plotly_name=self.plotly_name)
""".format(
plotly_name=self.plotly_name
)
return desc

def validate_coerce(self, v):
Expand Down Expand Up @@ -2020,7 +2049,9 @@ def description(self):
#
desc = """\
The '{plotly_name}' property is an info array that may be specified as:\
""".format(plotly_name=self.plotly_name)
""".format(
plotly_name=self.plotly_name
)

if isinstance(self.items, list):
# ### Case 1 ###
Expand All @@ -2029,14 +2060,18 @@ def description(self):
desc += """

* a list or tuple of{upto} {N} elements where:\
""".format(upto=upto, N=len(self.item_validators))
""".format(
upto=upto, N=len(self.item_validators)
)

for i, item_validator in enumerate(self.item_validators):
el_desc = item_validator.description().strip()
desc = (
desc
+ """
({i}) {el_desc}""".format(i=i, el_desc=el_desc)
({i}) {el_desc}""".format(
i=i, el_desc=el_desc
)
)

# ### Case 2 ###
Expand All @@ -2057,7 +2092,9 @@ def description(self):
desc = (
desc
+ """
({i}) {el_desc}""".format(i=i, el_desc=el_desc)
({i}) {el_desc}""".format(
i=i, el_desc=el_desc
)
)
item_validator.plotly_name = orig_name
else:
Expand All @@ -2074,7 +2111,9 @@ def description(self):
desc += """
* a list of elements where:
{el_desc}
""".format(el_desc=el_desc)
""".format(
el_desc=el_desc
)

if self.dimensions in ("1-2", 2):
item_validator.plotly_name = "{name}[i][j]".format(
Expand All @@ -2085,7 +2124,9 @@ def description(self):
desc += """
* a 2D list where:
{el_desc}
""".format(el_desc=el_desc)
""".format(
el_desc=el_desc
)

item_validator.plotly_name = orig_name

Expand Down Expand Up @@ -2327,7 +2368,9 @@ def description(self):
desc
+ """
- One of the following dash styles:
{enum_vals_str}""".format(enum_vals_str=enum_vals_str)
{enum_vals_str}""".format(
enum_vals_str=enum_vals_str
)
)

desc = (
Expand Down Expand Up @@ -2363,7 +2406,9 @@ def description(self):
- A PIL.Image.Image object which will be immediately converted
to a data URI image string
See http://pillow.readthedocs.io/en/latest/reference/Image.html
""".format(plotly_name=self.plotly_name)
""".format(
plotly_name=self.plotly_name
)
return desc

def validate_coerce(self, v):
Expand Down
3 changes: 1 addition & 2 deletions codegen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ def name_property(self):

return self.plotly_name + (
"s"
if self.is_array_element
and
if self.is_array_element and
# Don't add 's' to layout.template.data.scatter etc.
not (
self.parent
Expand Down
4 changes: 3 additions & 1 deletion commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ def overwrite_plotlyjs_version_file(plotlyjs_version):
# DO NOT EDIT
# This file is generated by the updatebundle commands.py command
__plotlyjs_version__ = "{plotlyjs_version}"
""".format(plotlyjs_version=plotlyjs_version)
""".format(
plotlyjs_version=plotlyjs_version
)
)


Expand Down
24 changes: 18 additions & 6 deletions plotly/_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,19 @@ def make_subplots(
raise ValueError(
"""
The 'rows' argument to make_subplots must be an int greater than 0.
Received value of type {typ}: {val}""".format(typ=type(rows), val=repr(rows))
Received value of type {typ}: {val}""".format(
typ=type(rows), val=repr(rows)
)
)

# ### cols ###
if not isinstance(cols, int) or cols <= 0:
raise ValueError(
"""
The 'cols' argument to make_subplots must be an int greater than 0.
Received value of type {typ}: {val}""".format(typ=type(cols), val=repr(cols))
Received value of type {typ}: {val}""".format(
typ=type(cols), val=repr(cols)
)
)

# ### start_cell ###
Expand Down Expand Up @@ -468,7 +472,9 @@ def _checks(item, defaults):
"""
The 'secondary_y' spec property is not supported for subplot of type '{s_typ}'
'secondary_y' is only supported for subplots of type 'xy'
""".format(s_typ=spec["type"])
""".format(
s_typ=spec["type"]
)
)

# ### insets ###
Expand All @@ -480,7 +486,9 @@ def _checks(item, defaults):
raise ValueError(
"""
The 'insets' argument to make_subplots must be a list of dictionaries.
Received value of type {typ}: {val}""".format(typ=type(insets), val=repr(insets))
Received value of type {typ}: {val}""".format(
typ=type(insets), val=repr(insets)
)
)

if insets:
Expand Down Expand Up @@ -1408,7 +1416,9 @@ def _set_trace_grid_reference(trace, layout, grid_ref, row, col, secondary_y=Fal
if not subplot_refs:
raise ValueError(
"""
No subplot specified at grid position ({row}, {col})""".format(row=row, col=col)
No subplot specified at grid position ({row}, {col})""".format(
row=row, col=col
)
)

if secondary_y:
Expand Down Expand Up @@ -1500,7 +1510,9 @@ def _get_grid_subplot(fig, row, col, secondary_y=False):
else:
raise ValueError(
"""
Unexpected subplot type with layout_keys of {}""".format(layout_keys)
Unexpected subplot type with layout_keys of {}""".format(
layout_keys
)
)


Expand Down
16 changes: 12 additions & 4 deletions plotly/basedatatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,9 @@ def _perform_plotly_restyle(self, restyle_data, trace_indexes):
raise ValueError(
"""
Invalid property path '{key_path_str}' for trace class {trace_class}
""".format(key_path_str=key_path_str, trace_class=trace_class)
""".format(
key_path_str=key_path_str, trace_class=trace_class
)
)

# Apply set operation for this trace and thist value
Expand Down Expand Up @@ -2002,7 +2004,9 @@ def _raise_invalid_rows_cols(name, n, invalid):
of length {n} (The number of traces being added)

Received: {invalid}
""".format(name=name, n=n, invalid=invalid)
""".format(
name=name, n=n, invalid=invalid
)

raise ValueError(rows_err_msg)

Expand Down Expand Up @@ -2658,7 +2662,9 @@ def _perform_plotly_relayout(self, relayout_data):
raise ValueError(
"""
Invalid property path '{key_path_str}' for layout
""".format(key_path_str=key_path_str)
""".format(
key_path_str=key_path_str
)
)

# Apply set operation on the layout dict
Expand Down Expand Up @@ -5616,7 +5622,9 @@ def on_change(self, callback, *args, **kwargs):
msg = """
{class_name} object is not a descendant of a Figure.
on_change callbacks are not supported in this case.
""".format(class_name=class_name)
""".format(
class_name=class_name
)
raise ValueError(msg)

# Validate args not empty
Expand Down
4 changes: 3 additions & 1 deletion plotly/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ def __init__(self, xrange=None, yrange=None, **_):
def __repr__(self):
return """\
BoxSelector(xrange={xrange},
yrange={yrange})""".format(xrange=self.xrange, yrange=self.yrange)
yrange={yrange})""".format(
xrange=self.xrange, yrange=self.yrange
)

@property
def type(self):
Expand Down
Loading