12
12
# Optional imports
13
13
# ----------------
14
14
import sys
15
-
16
- from _plotly_utils .compat import str_types
15
+ from six import string_types
17
16
18
17
np = None
19
18
pd = None
@@ -350,7 +349,7 @@ def __init__(self,
350
349
# ----------------------------
351
350
# Look for regular expressions
352
351
for v in self .values :
353
- if v and isinstance (v , str_types ) and v [0 ] == '/' and v [- 1 ] == '/' :
352
+ if v and isinstance (v , string_types ) and v [0 ] == '/' and v [- 1 ] == '/' :
354
353
# String is a regex with leading and trailing '/' character
355
354
regex_str = v [1 :- 1 ]
356
355
self .val_regexs .append (re .compile (regex_str ))
@@ -388,7 +387,7 @@ def perform_replacemenet(self, v):
388
387
"""
389
388
Return v with any applicable regex replacements applied
390
389
"""
391
- if isinstance (v , str_types ):
390
+ if isinstance (v , string_types ):
392
391
for repl_args in self .regex_replacements :
393
392
if repl_args :
394
393
v = re .sub (repl_args [0 ], repl_args [1 ], v )
@@ -443,7 +442,7 @@ def in_values(self, e):
443
442
"""
444
443
Return whether a value matches one of the enumeration options
445
444
"""
446
- is_str = isinstance (e , str_types )
445
+ is_str = isinstance (e , string_types )
447
446
for v , regex in zip (self .values , self .val_regexs ):
448
447
if is_str and regex :
449
448
in_values = fullmatch (regex , e ) is not None
@@ -822,7 +821,7 @@ def validate_coerce(self, v):
822
821
823
822
# If strict, make sure all elements are strings.
824
823
if self .strict :
825
- invalid_els = [e for e in v if not isinstance (e , str_types )]
824
+ invalid_els = [e for e in v if not isinstance (e , string_types )]
826
825
if invalid_els :
827
826
self .raise_invalid_elements (invalid_els )
828
827
@@ -863,10 +862,10 @@ def validate_coerce(self, v):
863
862
864
863
else :
865
864
if self .strict :
866
- if not isinstance (v , str_types ):
865
+ if not isinstance (v , string_types ):
867
866
self .raise_invalid_val (v )
868
867
else :
869
- if not isinstance (v , str_types + (int , float )):
868
+ if not isinstance (v , string_types + (int , float )):
870
869
self .raise_invalid_val (v )
871
870
872
871
# Convert value to a string
@@ -1082,7 +1081,7 @@ def perform_validate_coerce(v, allow_number=None):
1082
1081
if isinstance (v , numbers .Number ) and allow_number :
1083
1082
# If allow_numbers then any number is ok
1084
1083
return v
1085
- elif not isinstance (v , str_types ):
1084
+ elif not isinstance (v , string_types ):
1086
1085
# If not allow_numbers then value must be a string
1087
1086
return None
1088
1087
else :
@@ -1204,7 +1203,7 @@ def validate_coerce(self, v):
1204
1203
pass
1205
1204
if v is None :
1206
1205
v_valid = True
1207
- elif isinstance (v , str_types ):
1206
+ elif isinstance (v , string_types ):
1208
1207
v_match = [
1209
1208
el for el in ColorscaleValidator .named_colorscales
1210
1209
if el .lower () == v .lower ()
@@ -1219,7 +1218,7 @@ def validate_coerce(self, v):
1219
1218
len (e ) != 2 or
1220
1219
not isinstance (e [0 ], numbers .Number ) or
1221
1220
not (0 <= e [0 ] <= 1 ) or
1222
- not isinstance (e [1 ], str_types ) or
1221
+ not isinstance (e [1 ], string_types ) or
1223
1222
ColorValidator .perform_validate_coerce (e [1 ]) is None )]
1224
1223
1225
1224
if len (invalid_els ) == 0 :
@@ -1338,7 +1337,7 @@ def description(self):
1338
1337
def validate_coerce (self , v ):
1339
1338
if v is None :
1340
1339
pass
1341
- elif not isinstance (v , str_types ):
1340
+ elif not isinstance (v , string_types ):
1342
1341
self .raise_invalid_val (v )
1343
1342
else :
1344
1343
# match = re.fullmatch(self.regex, v)
@@ -1420,7 +1419,7 @@ def description(self):
1420
1419
return desc
1421
1420
1422
1421
def vc_scalar (self , v ):
1423
- if not isinstance (v , str_types ):
1422
+ if not isinstance (v , string_types ):
1424
1423
return None
1425
1424
1426
1425
# To be generous we accept flags separated on plus ('+'),
@@ -1661,7 +1660,7 @@ def description(self):
1661
1660
def validate_coerce (self , v ):
1662
1661
if v is None :
1663
1662
pass
1664
- elif isinstance (v , str_types ):
1663
+ elif isinstance (v , string_types ):
1665
1664
# Future possibilities:
1666
1665
# - Detect filesystem system paths and convert to URI
1667
1666
# - Validate either url or data uri
0 commit comments