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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 36 additions & 61 deletions .venv/Lib/site-packages/_plotly_utils/basevalidators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
# back-port of fullmatch from Py3.4+
def fullmatch(regex, string, flags=0):
"""Emulate python-3.4 re.fullmatch()."""
if "pattern" in dir(regex):
regex_string = regex.pattern
else:
regex_string = regex
regex_string = regex.pattern if "pattern" in dir(regex) else regex
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fullmatch refactored with the following changes:

return re.match("(?:" + regex_string + r")\Z", string, flags=flags)


Expand Down Expand Up @@ -181,10 +178,7 @@ def is_homogeneous_array(v):
if np:
v_numpy = np.array(v)
# v is essentially a scalar and so shouldn't count as an array
if v_numpy.shape == ():
return False
else:
return True
return v_numpy.shape != ()
Comment on lines -184 to +181
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function is_homogeneous_array refactored with the following changes:

return False


Expand Down Expand Up @@ -788,9 +782,8 @@ def validate_coerce(self, v):
self.raise_invalid_val(v)

# Check min/max
if self.has_min_max:
if not (self.min_val <= v <= self.max_val):
self.raise_invalid_val(v)
if self.has_min_max and not (self.min_val <= v <= self.max_val):
self.raise_invalid_val(v)
Comment on lines -791 to +786
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.NumberValidator.validate_coerce refactored with the following changes:

return v


Expand Down Expand Up @@ -918,9 +911,8 @@ def validate_coerce(self, v):
self.raise_invalid_val(v)

# Check min/max
if self.has_min_max:
if not (self.min_val <= v <= self.max_val):
self.raise_invalid_val(v)
if self.has_min_max and not (self.min_val <= v <= self.max_val):
self.raise_invalid_val(v)
Comment on lines -921 to +915
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.IntegerValidator.validate_coerce refactored with the following changes:


return v

Expand Down Expand Up @@ -1073,18 +1065,18 @@ def validate_coerce(self, v):
v = to_scalar_or_list(v)

else:
if self.strict:
if not isinstance(v, string_types):
self.raise_invalid_val(v)
else:
if isinstance(v, string_types):
pass
elif isinstance(v, (int, float)):
# Convert value to a string
v = str(v)
else:
self.raise_invalid_val(v)

if (
self.strict
and not isinstance(v, string_types)
or not isinstance(v, string_types)
and not isinstance(v, (int, float))
):
self.raise_invalid_val(v)
elif self.strict:
pass
elif not isinstance(v, string_types):
# Convert value to a string
v = str(v)
Comment on lines -1076 to +1079
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.StringValidator.validate_coerce refactored with the following changes:

if self.no_blank and len(v) == 0:
self.raise_invalid_val(v)

Expand Down Expand Up @@ -1555,7 +1547,7 @@ def description(self):
)
)

desc = """\
return """\
Comment on lines -1558 to +1550
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.ColorscaleValidator.description refactored with the following changes:

The '{plotly_name}' property is a colorscale and may be
specified as:
- A list of colors that will be spaced evenly to create the colorscale.
Expand All @@ -1572,8 +1564,6 @@ def description(self):
plotly_name=self.plotly_name, colorscales_str=colorscales_str
)

return desc

def validate_coerce(self, v):
v_valid = False

Expand Down Expand Up @@ -1601,7 +1591,7 @@ def validate_coerce(self, v):
e for e in v if ColorValidator.perform_validate_coerce(e) is None
]

if len(invalid_els) == 0:
if not invalid_els:
Comment on lines -1604 to +1594
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.ColorscaleValidator.validate_coerce refactored with the following changes:

v_valid = True

# Convert to list of lists colorscale
Expand All @@ -1621,7 +1611,7 @@ def validate_coerce(self, v):
)
]

if len(invalid_els) == 0:
if not invalid_els:
v_valid = True

# Convert to list of lists
Expand All @@ -1641,7 +1631,7 @@ def present(self, v):
elif isinstance(v, string_types):
return v
else:
return tuple([tuple(e) for e in v])
return tuple(tuple(e) for e in v)
Comment on lines -1644 to +1634
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.ColorscaleValidator.present refactored with the following changes:



class AngleValidator(BaseValidator):
Expand All @@ -1661,7 +1651,7 @@ def __init__(self, plotly_name, parent_name, **kwargs):
)

def description(self):
desc = """\
return """\
Comment on lines -1664 to +1654
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.AngleValidator.description refactored with the following changes:

The '{plotly_name}' property is a angle (in degrees) that may be
specified as a number between -180 and 180. Numeric values outside this
range are converted to the equivalent value
Expand All @@ -1670,8 +1660,6 @@ def description(self):
plotly_name=self.plotly_name
)

return desc

def validate_coerce(self, v):
if v is None:
# Pass None through
Expand Down Expand Up @@ -1720,15 +1708,14 @@ def __init__(self, plotly_name, parent_name, dflt=None, regex=None, **kwargs):

def description(self):

desc = """\
return """\
Comment on lines -1723 to +1711
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.SubplotidValidator.description refactored with the following changes:

The '{plotly_name}' property is an identifier of a particular
subplot, of type '{base}', that may be specified as the string '{base}'
optionally followed by an integer >= 1
(e.g. '{base}', '{base}1', '{base}2', '{base}3', etc.)
""".format(
plotly_name=self.plotly_name, base=self.base
)
return desc

def validate_coerce(self, v):
if v is None:
Expand Down Expand Up @@ -1833,10 +1820,10 @@ def vc_scalar(self, v):
split_vals = [e.strip() for e in re.split("[,+]", v)]

# Are all flags valid names?
all_flags_valid = all([f in self.all_flags for f in split_vals])
all_flags_valid = all(f in self.all_flags for f in split_vals)

# Are any 'extras' flags present?
has_extras = any([f in self.extras for f in split_vals])
has_extras = any(f in self.extras for f in split_vals)
Comment on lines -1836 to +1826
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.FlaglistValidator.vc_scalar refactored with the following changes:


# For flaglist to be valid all flags must be valid, and if we have
# any extras present, there must be only one flag (the single extras
Expand Down Expand Up @@ -1899,12 +1886,11 @@ def __init__(self, plotly_name, parent_name, values=None, array_ok=False, **kwar

def description(self):

desc = """\
return """\
The '{plotly_name}' property accepts values of any type
""".format(
plotly_name=self.plotly_name
)
return desc
Comment on lines -1902 to -1907
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.AnyValidator.description refactored with the following changes:


def validate_coerce(self, v):
if v is None:
Expand Down Expand Up @@ -1946,7 +1932,7 @@ def __init__(
)

self.items = items
self.dimensions = dimensions if dimensions else 1
self.dimensions = dimensions or 1
Comment on lines -1949 to +1935
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.InfoArrayValidator.__init__ refactored with the following changes:

self.free_length = free_length

# Instantiate validators for each info array element
Expand Down Expand Up @@ -2329,7 +2315,7 @@ def __init__(self, plotly_name, parent_name, **kwargs):

def description(self):

desc = """\
return """\
Comment on lines -2332 to +2318
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.ImageUriValidator.description refactored with the following changes:

The '{plotly_name}' property is an image URI that may be specified as:
- A remote image URI string
(e.g. 'http://www.somewhere.com/image.png')
Expand All @@ -2341,7 +2327,6 @@ def description(self):
""".format(
plotly_name=self.plotly_name
)
return desc

def validate_coerce(self, v):
if v is None:
Expand Down Expand Up @@ -2423,7 +2408,7 @@ def data_class(self):

def description(self):

desc = (
return (
Comment on lines -2426 to +2411
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.CompoundValidator.data_class.description refactored with the following changes:

"""\
The '{plotly_name}' property is an instance of {class_str}
that may be specified as:
Expand All @@ -2440,8 +2425,6 @@ def description(self):
constructor_params_str=self.data_docs,
)

return desc

def validate_coerce(self, v, skip_invalid=False, _validate=True):
if v is None:
v = self.data_class()
Expand Down Expand Up @@ -2500,7 +2483,7 @@ def __init__(self, plotly_name, parent_name, data_class_str, data_docs, **kwargs

def description(self):

desc = (
return (
Comment on lines -2503 to +2486
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.CompoundValidator.data_class.CompoundArrayValidator.description refactored with the following changes:

"""\
The '{plotly_name}' property is a tuple of instances of
{class_str} that may be specified as:
Expand All @@ -2517,8 +2500,6 @@ def description(self):
constructor_params_str=self.data_docs,
)

return desc

@property
def data_class(self):
if self._data_class is None:
Expand All @@ -2529,10 +2510,12 @@ def data_class(self):

def validate_coerce(self, v, skip_invalid=False):

if v is None:
if not isinstance(v, (list, tuple)) and skip_invalid or v is None:
v = []
elif not isinstance(v, (list, tuple)):
self.raise_invalid_val(v)

elif isinstance(v, (list, tuple)):
else:
Comment on lines -2532 to +2518
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.CompoundValidator.data_class.CompoundArrayValidator.data_class.validate_coerce refactored with the following changes:

res = []
invalid_els = []
for v_el in v:
Expand All @@ -2551,12 +2534,6 @@ def validate_coerce(self, v, skip_invalid=False):
self.raise_invalid_elements(invalid_els)

v = to_scalar_or_list(res)
else:
if skip_invalid:
v = []
else:
self.raise_invalid_val(v)

return v

def present(self, v):
Expand Down Expand Up @@ -2589,7 +2566,7 @@ def description(self):
)
)

desc = (
return (
Comment on lines -2592 to +2569
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function type_str.CompoundValidator.data_class.CompoundArrayValidator.data_class.BaseDataValidator.description refactored with the following changes:

"""\
The '{plotly_name}' property is a tuple of trace instances
that may be specified as:
Expand All @@ -2607,8 +2584,6 @@ def description(self):
(e.g. [{{'type': 'scatter', ...}}, {{'type': 'bar, ...}}])"""
).format(plotly_name=self.plotly_name, trace_types=trace_types_wrapped)

return desc

def get_trace_class(self, trace_name):
# Import trace classes
if trace_name not in self._class_map:
Expand Down
Loading