@@ -72,7 +72,7 @@ def validate_path_exists(s):
7272
7373def validate_bool (b ):
7474 """Convert b to a boolean or raise"""
75- if type ( b ) is str :
75+ if isinstance ( b , basestring ) :
7676 b = b .lower ()
7777 if b in ('t' , 'y' , 'yes' , 'on' , 'true' , '1' , 1 , True ):
7878 return True
@@ -83,8 +83,8 @@ def validate_bool(b):
8383
8484
8585def validate_bool_maybe_none (b ):
86- ' Convert b to a boolean or raise'
87- if type ( b ) is str :
86+ """ Convert b to a boolean, None, or raise"""
87+ if isinstance ( b , basestring ) :
8888 b = b .lower ()
8989 if b == 'none' :
9090 return None
@@ -179,7 +179,7 @@ def __init__(self, n):
179179
180180 def __call__ (self , s ):
181181 """return a seq of n floats or raise"""
182- if type ( s ) is str :
182+ if isinstance ( s , basestring ) :
183183 ss = s .split (',' )
184184 if len (ss ) != self .n :
185185 raise ValueError (
@@ -202,7 +202,7 @@ def __init__(self, n):
202202
203203 def __call__ (self , s ):
204204 """return a seq of n ints or raise"""
205- if type ( s ) is str :
205+ if isinstance ( s , basestring ) :
206206 ss = s .split (',' )
207207 if len (ss ) != self .n :
208208 raise ValueError (
@@ -254,7 +254,7 @@ def validate_color(s):
254254
255255def validate_colorlist (s ):
256256 'return a list of colorspecs'
257- if type ( s ) is str :
257+ if isinstance ( s , basestring ) :
258258 return [validate_color (c .strip ()) for c in s .split (',' )]
259259 else :
260260 assert type (s ) in [list , tuple ]
@@ -263,7 +263,7 @@ def validate_colorlist(s):
263263
264264def validate_stringlist (s ):
265265 'return a list'
266- if type ( s ) in ( str , unicode ):
266+ if isinstance ( s , basestring ):
267267 return [v .strip () for v in s .split (',' )]
268268 else :
269269 assert type (s ) in [list , tuple ]
@@ -284,7 +284,7 @@ def validate_aspect(s):
284284
285285
286286def validate_fontsize (s ):
287- if type ( s ) is str :
287+ if isinstance ( s , basestring ) :
288288 s = s .lower ()
289289 if s in ['xx-small' , 'x-small' , 'small' , 'medium' , 'large' , 'x-large' ,
290290 'xx-large' , 'smaller' , 'larger' ]:
@@ -337,7 +337,7 @@ def update_savefig_format(value):
337337
338338
339339def validate_ps_distiller (s ):
340- if type ( s ) is str :
340+ if isinstance ( s , basestring ) :
341341 s = s .lower ()
342342
343343 if s in ('none' , None ):
@@ -423,7 +423,7 @@ def validate_hinting(s):
423423
424424
425425def validate_bbox (s ):
426- if type ( s ) is str :
426+ if isinstance ( s , basestring ) :
427427 s = s .lower ()
428428 if s == 'tight' :
429429 return s
0 commit comments