From 997ab7c85aabf0c5f9cc70cc103faf168a321cb3 Mon Sep 17 00:00:00 2001 From: Nicholas Esterer Date: Fri, 16 Oct 2020 11:07:32 -0400 Subject: [PATCH 1/3] Added ' domain' to EnumeratedValidator.build_regex_replacement --- .../plotly/_plotly_utils/basevalidators.py | 318 +++++++++--------- 1 file changed, 160 insertions(+), 158 deletions(-) diff --git a/packages/python/plotly/_plotly_utils/basevalidators.py b/packages/python/plotly/_plotly_utils/basevalidators.py index 954ee39e659..190bc8fad61 100644 --- a/packages/python/plotly/_plotly_utils/basevalidators.py +++ b/packages/python/plotly/_plotly_utils/basevalidators.py @@ -354,14 +354,14 @@ def present(self, v): class DataArrayValidator(BaseValidator): """ - "data_array": { - "description": "An {array} of data. The value MUST be an - {array}, or we ignore it.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - }, + "data_array": { + "description": "An {array} of data. The value MUST be an + {array}, or we ignore it.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + }, """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -394,18 +394,18 @@ def validate_coerce(self, v): class EnumeratedValidator(BaseValidator): """ - "enumerated": { - "description": "Enumerated value type. The available values are - listed in `values`.", - "requiredOpts": [ - "values" - ], - "otherOpts": [ - "dflt", - "coerceNumber", - "arrayOk" - ] - }, + "enumerated": { + "description": "Enumerated value type. The available values are + listed in `values`.", + "requiredOpts": [ + "values" + ], + "otherOpts": [ + "dflt", + "coerceNumber", + "arrayOk" + ] + }, """ def __init__( @@ -477,7 +477,9 @@ def build_regex_replacement(regex_str): # # To be cautious, we only perform this conversion for enumerated # values that match the anchor-style regex - match = re.match(r"\^(\w)\(\[2\-9\]\|\[1\-9\]\[0\-9\]\+\)\?\$", regex_str) + match = re.match( + r"\^(\w)\(\[2\-9\]\|\[1\-9\]\[0\-9\]\+\)\?\( domain\)\?\$", regex_str + ) if match: anchor_char = match.group(1) @@ -599,13 +601,13 @@ def validate_coerce(self, v): class BooleanValidator(BaseValidator): """ - "boolean": { - "description": "A boolean (true/false) value.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - }, + "boolean": { + "description": "A boolean (true/false) value.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + }, """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -662,19 +664,19 @@ def validate_coerce(self, v): class NumberValidator(BaseValidator): """ - "number": { - "description": "A number or a numeric value (e.g. a number - inside a string). When applicable, values - greater (less) than `max` (`min`) are coerced to - the `dflt`.", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "min", - "max", - "arrayOk" - ] - }, + "number": { + "description": "A number or a numeric value (e.g. a number + inside a string). When applicable, values + greater (less) than `max` (`min`) are coerced to + the `dflt`.", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "min", + "max", + "arrayOk" + ] + }, """ def __init__( @@ -792,18 +794,18 @@ def validate_coerce(self, v): class IntegerValidator(BaseValidator): """ - "integer": { - "description": "An integer or an integer inside a string. When - applicable, values greater (less) than `max` - (`min`) are coerced to the `dflt`.", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "min", - "max", - "arrayOk" - ] - }, + "integer": { + "description": "An integer or an integer inside a string. When + applicable, values greater (less) than `max` + (`min`) are coerced to the `dflt`.", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "min", + "max", + "arrayOk" + ] + }, """ def __init__( @@ -923,18 +925,18 @@ def validate_coerce(self, v): class StringValidator(BaseValidator): """ - "string": { - "description": "A string value. Numbers are converted to strings - except for attributes with `strict` set to true.", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "noBlank", - "strict", - "arrayOk", - "values" - ] - }, + "string": { + "description": "A string value. Numbers are converted to strings + except for attributes with `strict` set to true.", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "noBlank", + "strict", + "arrayOk", + "values" + ] + }, """ def __init__( @@ -1092,21 +1094,21 @@ def validate_coerce(self, v): class ColorValidator(BaseValidator): """ - "color": { - "description": "A string describing color. Supported formats: - - hex (e.g. '#d3d3d3') - - rgb (e.g. 'rgb(255, 0, 0)') - - rgba (e.g. 'rgb(255, 0, 0, 0.5)') - - hsl (e.g. 'hsl(0, 100%, 50%)') - - hsv (e.g. 'hsv(0, 100%, 100%)') - - named colors(full list: - http://www.w3.org/TR/css3-color/#svg-color)", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "arrayOk" - ] - }, + "color": { + "description": "A string describing color. Supported formats: + - hex (e.g. '#d3d3d3') + - rgb (e.g. 'rgb(255, 0, 0)') + - rgba (e.g. 'rgb(255, 0, 0, 0.5)') + - hsl (e.g. 'hsl(0, 100%, 50%)') + - hsv (e.g. 'hsv(0, 100%, 100%)') + - named colors(full list: + http://www.w3.org/TR/css3-color/#svg-color)", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "arrayOk" + ] + }, """ re_hex = re.compile(r"#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})") @@ -1443,14 +1445,14 @@ def perform_validate_coerce(v, allow_number=None): class ColorlistValidator(BaseValidator): """ - "colorlist": { - "description": "A list of colors. Must be an {array} containing - valid colors.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - } + "colorlist": { + "description": "A list of colors. Must be an {array} containing + valid colors.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + } """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -1490,20 +1492,20 @@ def validate_coerce(self, v): class ColorscaleValidator(BaseValidator): """ - "colorscale": { - "description": "A Plotly colorscale either picked by a name: - (any of Greys, YlGnBu, Greens, YlOrRd, Bluered, - RdBu, Reds, Blues, Picnic, Rainbow, Portland, - Jet, Hot, Blackbody, Earth, Electric, Viridis) - customized as an {array} of 2-element {arrays} - where the first element is the normalized color - level value (starting at *0* and ending at *1*), - and the second item is a valid color string.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - }, + "colorscale": { + "description": "A Plotly colorscale either picked by a name: + (any of Greys, YlGnBu, Greens, YlOrRd, Bluered, + RdBu, Reds, Blues, Picnic, Rainbow, Portland, + Jet, Hot, Blackbody, Earth, Electric, Viridis) + customized as an {array} of 2-element {arrays} + where the first element is the normalized color + level value (starting at *0* and ending at *1*), + and the second item is a valid color string.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + }, """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -1558,7 +1560,7 @@ def description(self): Many predefined colorscale lists are included in the sequential, diverging, and cyclical modules in the plotly.colors package. - A list of 2-element lists where the first element is the - normalized color level value (starting at 0 and ending at 1), + normalized color level value (starting at 0 and ending at 1), and the second item is a valid color string. (e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']]) - One of the following named colorscales: @@ -1642,13 +1644,13 @@ def present(self, v): class AngleValidator(BaseValidator): """ - "angle": { - "description": "A number (in degree) between -180 and 180.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - }, + "angle": { + "description": "A number (in degree) between -180 and 180.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + }, """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -1683,18 +1685,18 @@ def validate_coerce(self, v): class SubplotidValidator(BaseValidator): """ - "subplotid": { - "description": "An id string of a subplot type (given by dflt), - optionally followed by an integer >1. e.g. if - dflt='geo', we can have 'geo', 'geo2', 'geo3', - ...", - "requiredOpts": [ - "dflt" - ], - "otherOpts": [ - "regex" - ] - } + "subplotid": { + "description": "An id string of a subplot type (given by dflt), + optionally followed by an integer >1. e.g. if + dflt='geo', we can have 'geo', 'geo2', 'geo3', + ...", + "requiredOpts": [ + "dflt" + ], + "otherOpts": [ + "regex" + ] + } """ def __init__(self, plotly_name, parent_name, dflt=None, regex=None, **kwargs): @@ -1754,21 +1756,21 @@ def validate_coerce(self, v): class FlaglistValidator(BaseValidator): """ - "flaglist": { - "description": "A string representing a combination of flags - (order does not matter here). Combine any of the - available `flags` with *+*. - (e.g. ('lines+markers')). Values in `extras` - cannot be combined.", - "requiredOpts": [ - "flags" - ], - "otherOpts": [ - "dflt", - "extras", - "arrayOk" - ] - }, + "flaglist": { + "description": "A string representing a combination of flags + (order does not matter here). Combine any of the + available `flags` with *+*. + (e.g. ('lines+markers')). Values in `extras` + cannot be combined.", + "requiredOpts": [ + "flags" + ], + "otherOpts": [ + "dflt", + "extras", + "arrayOk" + ] + }, """ def __init__( @@ -1875,15 +1877,15 @@ def validate_coerce(self, v): class AnyValidator(BaseValidator): """ - "any": { - "description": "Any type.", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "values", - "arrayOk" - ] - }, + "any": { + "description": "Any type.", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "values", + "arrayOk" + ] + }, """ def __init__(self, plotly_name, parent_name, values=None, array_ok=False, **kwargs): @@ -1915,17 +1917,17 @@ def validate_coerce(self, v): class InfoArrayValidator(BaseValidator): """ - "info_array": { - "description": "An {array} of plot information.", - "requiredOpts": [ - "items" - ], - "otherOpts": [ - "dflt", - "freeLength", - "dimensions" - ] - } + "info_array": { + "description": "An {array} of plot information.", + "requiredOpts": [ + "items" + ], + "otherOpts": [ + "dflt", + "freeLength", + "dimensions" + ] + } """ def __init__( @@ -2705,7 +2707,7 @@ def description(self): - A string containing multiple registered template names, joined on '+' characters (e.g. 'template1+template2'). In this case the resulting - template is computed by merging together the collection of registered + template is computed by merging together the collection of registered templates""" return compound_description From 5a7f6106a465b415cd7127a91805c24e7c0018f6 Mon Sep 17 00:00:00 2001 From: Nicholas Esterer Date: Fri, 16 Oct 2020 12:33:26 -0400 Subject: [PATCH 2/3] Pin black version --- packages/python/plotly/optional-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/python/plotly/optional-requirements.txt b/packages/python/plotly/optional-requirements.txt index 450c32d3345..8ac97789fcf 100644 --- a/packages/python/plotly/optional-requirements.txt +++ b/packages/python/plotly/optional-requirements.txt @@ -25,7 +25,7 @@ psutil ## code formatting pre-commit -black +black==19.10b0 ## codegen dependencies ## inflect From 4a849ceb46a20b5d2c3e0a07243ea04771dd5b94 Mon Sep 17 00:00:00 2001 From: Nicholas Esterer Date: Fri, 16 Oct 2020 13:02:05 -0400 Subject: [PATCH 3/3] Removed whitespace changes --- .../plotly/_plotly_utils/basevalidators.py | 314 +++++++++--------- 1 file changed, 157 insertions(+), 157 deletions(-) diff --git a/packages/python/plotly/_plotly_utils/basevalidators.py b/packages/python/plotly/_plotly_utils/basevalidators.py index 190bc8fad61..099c26598c2 100644 --- a/packages/python/plotly/_plotly_utils/basevalidators.py +++ b/packages/python/plotly/_plotly_utils/basevalidators.py @@ -354,14 +354,14 @@ def present(self, v): class DataArrayValidator(BaseValidator): """ - "data_array": { - "description": "An {array} of data. The value MUST be an - {array}, or we ignore it.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - }, + "data_array": { + "description": "An {array} of data. The value MUST be an + {array}, or we ignore it.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + }, """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -394,18 +394,18 @@ def validate_coerce(self, v): class EnumeratedValidator(BaseValidator): """ - "enumerated": { - "description": "Enumerated value type. The available values are - listed in `values`.", - "requiredOpts": [ - "values" - ], - "otherOpts": [ - "dflt", - "coerceNumber", - "arrayOk" - ] - }, + "enumerated": { + "description": "Enumerated value type. The available values are + listed in `values`.", + "requiredOpts": [ + "values" + ], + "otherOpts": [ + "dflt", + "coerceNumber", + "arrayOk" + ] + }, """ def __init__( @@ -601,13 +601,13 @@ def validate_coerce(self, v): class BooleanValidator(BaseValidator): """ - "boolean": { - "description": "A boolean (true/false) value.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - }, + "boolean": { + "description": "A boolean (true/false) value.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + }, """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -664,19 +664,19 @@ def validate_coerce(self, v): class NumberValidator(BaseValidator): """ - "number": { - "description": "A number or a numeric value (e.g. a number - inside a string). When applicable, values - greater (less) than `max` (`min`) are coerced to - the `dflt`.", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "min", - "max", - "arrayOk" - ] - }, + "number": { + "description": "A number or a numeric value (e.g. a number + inside a string). When applicable, values + greater (less) than `max` (`min`) are coerced to + the `dflt`.", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "min", + "max", + "arrayOk" + ] + }, """ def __init__( @@ -794,18 +794,18 @@ def validate_coerce(self, v): class IntegerValidator(BaseValidator): """ - "integer": { - "description": "An integer or an integer inside a string. When - applicable, values greater (less) than `max` - (`min`) are coerced to the `dflt`.", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "min", - "max", - "arrayOk" - ] - }, + "integer": { + "description": "An integer or an integer inside a string. When + applicable, values greater (less) than `max` + (`min`) are coerced to the `dflt`.", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "min", + "max", + "arrayOk" + ] + }, """ def __init__( @@ -925,18 +925,18 @@ def validate_coerce(self, v): class StringValidator(BaseValidator): """ - "string": { - "description": "A string value. Numbers are converted to strings - except for attributes with `strict` set to true.", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "noBlank", - "strict", - "arrayOk", - "values" - ] - }, + "string": { + "description": "A string value. Numbers are converted to strings + except for attributes with `strict` set to true.", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "noBlank", + "strict", + "arrayOk", + "values" + ] + }, """ def __init__( @@ -1094,21 +1094,21 @@ def validate_coerce(self, v): class ColorValidator(BaseValidator): """ - "color": { - "description": "A string describing color. Supported formats: - - hex (e.g. '#d3d3d3') - - rgb (e.g. 'rgb(255, 0, 0)') - - rgba (e.g. 'rgb(255, 0, 0, 0.5)') - - hsl (e.g. 'hsl(0, 100%, 50%)') - - hsv (e.g. 'hsv(0, 100%, 100%)') - - named colors(full list: - http://www.w3.org/TR/css3-color/#svg-color)", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "arrayOk" - ] - }, + "color": { + "description": "A string describing color. Supported formats: + - hex (e.g. '#d3d3d3') + - rgb (e.g. 'rgb(255, 0, 0)') + - rgba (e.g. 'rgb(255, 0, 0, 0.5)') + - hsl (e.g. 'hsl(0, 100%, 50%)') + - hsv (e.g. 'hsv(0, 100%, 100%)') + - named colors(full list: + http://www.w3.org/TR/css3-color/#svg-color)", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "arrayOk" + ] + }, """ re_hex = re.compile(r"#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})") @@ -1445,14 +1445,14 @@ def perform_validate_coerce(v, allow_number=None): class ColorlistValidator(BaseValidator): """ - "colorlist": { - "description": "A list of colors. Must be an {array} containing - valid colors.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - } + "colorlist": { + "description": "A list of colors. Must be an {array} containing + valid colors.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + } """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -1492,20 +1492,20 @@ def validate_coerce(self, v): class ColorscaleValidator(BaseValidator): """ - "colorscale": { - "description": "A Plotly colorscale either picked by a name: - (any of Greys, YlGnBu, Greens, YlOrRd, Bluered, - RdBu, Reds, Blues, Picnic, Rainbow, Portland, - Jet, Hot, Blackbody, Earth, Electric, Viridis) - customized as an {array} of 2-element {arrays} - where the first element is the normalized color - level value (starting at *0* and ending at *1*), - and the second item is a valid color string.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - }, + "colorscale": { + "description": "A Plotly colorscale either picked by a name: + (any of Greys, YlGnBu, Greens, YlOrRd, Bluered, + RdBu, Reds, Blues, Picnic, Rainbow, Portland, + Jet, Hot, Blackbody, Earth, Electric, Viridis) + customized as an {array} of 2-element {arrays} + where the first element is the normalized color + level value (starting at *0* and ending at *1*), + and the second item is a valid color string.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + }, """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -1560,7 +1560,7 @@ def description(self): Many predefined colorscale lists are included in the sequential, diverging, and cyclical modules in the plotly.colors package. - A list of 2-element lists where the first element is the - normalized color level value (starting at 0 and ending at 1), + normalized color level value (starting at 0 and ending at 1), and the second item is a valid color string. (e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']]) - One of the following named colorscales: @@ -1644,13 +1644,13 @@ def present(self, v): class AngleValidator(BaseValidator): """ - "angle": { - "description": "A number (in degree) between -180 and 180.", - "requiredOpts": [], - "otherOpts": [ - "dflt" - ] - }, + "angle": { + "description": "A number (in degree) between -180 and 180.", + "requiredOpts": [], + "otherOpts": [ + "dflt" + ] + }, """ def __init__(self, plotly_name, parent_name, **kwargs): @@ -1685,18 +1685,18 @@ def validate_coerce(self, v): class SubplotidValidator(BaseValidator): """ - "subplotid": { - "description": "An id string of a subplot type (given by dflt), - optionally followed by an integer >1. e.g. if - dflt='geo', we can have 'geo', 'geo2', 'geo3', - ...", - "requiredOpts": [ - "dflt" - ], - "otherOpts": [ - "regex" - ] - } + "subplotid": { + "description": "An id string of a subplot type (given by dflt), + optionally followed by an integer >1. e.g. if + dflt='geo', we can have 'geo', 'geo2', 'geo3', + ...", + "requiredOpts": [ + "dflt" + ], + "otherOpts": [ + "regex" + ] + } """ def __init__(self, plotly_name, parent_name, dflt=None, regex=None, **kwargs): @@ -1756,21 +1756,21 @@ def validate_coerce(self, v): class FlaglistValidator(BaseValidator): """ - "flaglist": { - "description": "A string representing a combination of flags - (order does not matter here). Combine any of the - available `flags` with *+*. - (e.g. ('lines+markers')). Values in `extras` - cannot be combined.", - "requiredOpts": [ - "flags" - ], - "otherOpts": [ - "dflt", - "extras", - "arrayOk" - ] - }, + "flaglist": { + "description": "A string representing a combination of flags + (order does not matter here). Combine any of the + available `flags` with *+*. + (e.g. ('lines+markers')). Values in `extras` + cannot be combined.", + "requiredOpts": [ + "flags" + ], + "otherOpts": [ + "dflt", + "extras", + "arrayOk" + ] + }, """ def __init__( @@ -1877,15 +1877,15 @@ def validate_coerce(self, v): class AnyValidator(BaseValidator): """ - "any": { - "description": "Any type.", - "requiredOpts": [], - "otherOpts": [ - "dflt", - "values", - "arrayOk" - ] - }, + "any": { + "description": "Any type.", + "requiredOpts": [], + "otherOpts": [ + "dflt", + "values", + "arrayOk" + ] + }, """ def __init__(self, plotly_name, parent_name, values=None, array_ok=False, **kwargs): @@ -1917,17 +1917,17 @@ def validate_coerce(self, v): class InfoArrayValidator(BaseValidator): """ - "info_array": { - "description": "An {array} of plot information.", - "requiredOpts": [ - "items" - ], - "otherOpts": [ - "dflt", - "freeLength", - "dimensions" - ] - } + "info_array": { + "description": "An {array} of plot information.", + "requiredOpts": [ + "items" + ], + "otherOpts": [ + "dflt", + "freeLength", + "dimensions" + ] + } """ def __init__( @@ -2707,7 +2707,7 @@ def description(self): - A string containing multiple registered template names, joined on '+' characters (e.g. 'template1+template2'). In this case the resulting - template is computed by merging together the collection of registered + template is computed by merging together the collection of registered templates""" return compound_description