Skip to content

Commit 960adb9

Browse files
committed
Revert changes to validators
1 parent 9d6b0c7 commit 960adb9

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

packages/python/plotly/_plotly_utils/basevalidators.py

+22-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import base64
22
import numbers
33
import textwrap
4-
import traceback
54
import uuid
65
from importlib import import_module
76
import copy
@@ -208,17 +207,6 @@ def is_homogeneous_array(v):
208207
return False
209208

210209

211-
def is_typed_array_spec(v):
212-
"""
213-
Return whether a value is considered to be a typed array spec for plotly.js
214-
"""
215-
return isinstance(v, dict) and "bdata" in v and "dtype" in v
216-
217-
218-
def is_none_or_typed_array_spec(v):
219-
return v is None or is_typed_array_spec(v)
220-
221-
222210
def is_simple_array(v):
223211
"""
224212
Return whether a value is considered to be an simple array
@@ -412,7 +400,9 @@ def description(self):
412400
)
413401

414402
def validate_coerce(self, v):
415-
if is_none_or_typed_array_spec(v):
403+
404+
if v is None:
405+
# Pass None through
416406
pass
417407
elif is_homogeneous_array(v):
418408
v = copy_to_readonly_numpy_array(v)
@@ -609,7 +599,8 @@ def in_values(self, e):
609599
return False
610600

611601
def validate_coerce(self, v):
612-
if is_none_or_typed_array_spec(v):
602+
if v is None:
603+
# Pass None through
613604
pass
614605
elif self.array_ok and is_array(v):
615606
v_replaced = [self.perform_replacemenet(v_el) for v_el in v]
@@ -769,7 +760,8 @@ def description(self):
769760
return desc
770761

771762
def validate_coerce(self, v):
772-
if is_none_or_typed_array_spec(v):
763+
if v is None:
764+
# Pass None through
773765
pass
774766
elif self.array_ok and is_homogeneous_array(v):
775767
np = get_module("numpy")
@@ -915,7 +907,8 @@ def description(self):
915907
return desc
916908

917909
def validate_coerce(self, v):
918-
if is_none_or_typed_array_spec(v):
910+
if v is None:
911+
# Pass None through
919912
pass
920913
elif v in self.extras:
921914
return v
@@ -1078,7 +1071,8 @@ def description(self):
10781071
return desc
10791072

10801073
def validate_coerce(self, v):
1081-
if is_none_or_typed_array_spec(v):
1074+
if v is None:
1075+
# Pass None through
10821076
pass
10831077
elif self.array_ok and is_array(v):
10841078

@@ -1379,7 +1373,8 @@ def description(self):
13791373
return valid_color_description
13801374

13811375
def validate_coerce(self, v, should_raise=True):
1382-
if is_none_or_typed_array_spec(v):
1376+
if v is None:
1377+
# Pass None through
13831378
pass
13841379
elif self.array_ok and is_homogeneous_array(v):
13851380
v = copy_to_readonly_numpy_array(v)
@@ -1523,7 +1518,8 @@ def description(self):
15231518

15241519
def validate_coerce(self, v):
15251520

1526-
if is_none_or_typed_array_spec(v):
1521+
if v is None:
1522+
# Pass None through
15271523
pass
15281524
elif is_array(v):
15291525
validated_v = [
@@ -1728,7 +1724,8 @@ def description(self):
17281724
return desc
17291725

17301726
def validate_coerce(self, v):
1731-
if is_none_or_typed_array_spec(v):
1727+
if v is None:
1728+
# Pass None through
17321729
pass
17331730
elif self.array_ok and is_homogeneous_array(v):
17341731
try:
@@ -1916,9 +1913,6 @@ def validate_coerce(self, v):
19161913
if v is None:
19171914
# Pass None through
19181915
pass
1919-
if is_typed_array_spec(v):
1920-
# Pass typed array spec through
1921-
pass
19221916
elif self.array_ok and is_array(v):
19231917

19241918
# Coerce individual strings
@@ -1975,7 +1969,8 @@ def description(self):
19751969
return desc
19761970

19771971
def validate_coerce(self, v):
1978-
if is_none_or_typed_array_spec(v):
1972+
if v is None:
1973+
# Pass None through
19791974
pass
19801975
elif self.array_ok and is_homogeneous_array(v):
19811976
v = copy_to_readonly_numpy_array(v, kind="O")
@@ -2183,7 +2178,8 @@ def validate_element_with_indexed_name(self, val, validator, inds):
21832178
return val
21842179

21852180
def validate_coerce(self, v):
2186-
if is_none_or_typed_array_spec(v):
2181+
if v is None:
2182+
# Pass None through
21872183
return None
21882184
elif not is_array(v):
21892185
self.raise_invalid_val(v)
@@ -2246,7 +2242,7 @@ def validate_coerce(self, v):
22462242
return v
22472243

22482244
def present(self, v):
2249-
if is_none_or_typed_array_spec(v):
2245+
if v is None:
22502246
return None
22512247
else:
22522248
if (

0 commit comments

Comments
 (0)