8000 Validate string rcParams with string_types, not text_types. · matplotlib/matplotlib@1692377 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 1692377

Browse files
committed
Validate string rcParams with string_types, not text_types.
Otherwise, on Py2, `rcParams["..."] = "..."` won't work unless unicode_literals is active.
1 parent df6acf9 commit 1692377

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

lib/matplotlib/rcsetup.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def validate_color_for_prop_cycle(s):
353353
if match is not None:
354354
raise ValueError('Can not put cycle reference ({cn!r}) in '
355355
'prop_cycler'.format(cn=s))
356-
elif isinstance(s, six.text_type):
356+
elif isinstance(s, six.string_types):
357357
match = re.match('^C[0-9]$', s)
358358
if match is not None:
359359
raise ValueError('Can not put cycle reference ({cn!r}) in '
@@ -409,7 +409,7 @@ def deprecate_axes_colorcycle(value):
409409
validate_colorlist = _listify_validator(validate_color, allow_stringlist=True)
410410
validate_colorlist.__doc__ = 'return a list of colorspecs'
411411

412-
validate_stringlist = _listify_validator(six.text_type)
412+
validate_stringlist = _listify_validator(six.string_types)
413413
validate_stringlist.__doc__ = 'return a list'
414414

415415
validate_orientation = ValidateInStrings(
@@ -855,7 +855,7 @@ def validate_cycler(s):
855855

856856

857857
def validate_hist_bins(s):
858-
if isinstance(s, six.text_type) and s == 'auto':
858+
if isinstance(s, six.string_types) and s == 'auto':
859859
return s
860860
try:
861861
return int(s)
@@ -874,7 +874,7 @@ def validate_animation_writer_path(p):
874874
# Make sure it's a string and then figure out if the animations
875875
# are already loaded and reset the writers (which will validate
876876
# the path on next call)
877-
if not isinstance(p, six.text_type):
877+
if not isinstance(p, six.string_types):
878878
raise ValueError("path must be a (unicode) string")
879879
from sys import modules
880880
# set dirty, so that the next call to the registry will re-evaluate
@@ -950,17 +950,17 @@ def _validate_linestyle(ls):
950950
'datapath': [None, validate_path_exists], # handled by
951951
# _get_data_path_cached
952952
'interactive': [False, validate_bool],
953-
'timezone': ['UTC', six.text_type],
953+
'timezone': ['UTC', six.string_types],
954954

955955
# the verbosity setting
956956
'verbose.level': ['silent', validate_verbose],
957-
'verbose.fileo': ['sys.stdout', six.text_type],
957+
'verbose.fileo': ['sys.stdout', six.string_types],
958958

959959
# line props
960960
'lines.linewidth': [1.5, validate_float], # line width in points
961961
'lines.linestyle': ['-', _validate_linestyle], # solid line
962962
'lines.color': ['C0', validate_color], # first color in color cycle
963-
'lines.marker': ['None', six.text_type], # marker name
963+
'lines.marker': ['None', six.string_types], # marker name
964964
'lines.markeredgewidth': [1.0, validate_float],
965965
'lines.markersize': [6, validate_float], # markersize, in points
966966
'lines.antialiased': [True, validate_bool], # antialiased (no jaggies)
@@ -1004,7 +1004,7 @@ def _validate_linestyle(ls):
10041004
'boxplot.meanline': [False, validate_bool],
10051005

10061006
'boxplot.flierprops.color': ['k', validate_color],
1007-
'boxplot.flierprops.marker': ['o', six.text_type],
1007+
'boxplot.flierprops.marker': ['o', six.string_types],
10081008
'boxplot.flierprops.markerfacecolor': ['none', validate_color_or_auto],
10091009
'boxplot.flierprops.markeredgecolor': ['k', validate_color],
10101010
'boxplot.flierprops.markersize': [6, validate_float],
@@ -1028,7 +1028,7 @@ def _validate_linestyle(ls):
10281028
'boxplot.medianprops.linestyle': ['-', _validate_linestyle],
10291029

10301030
'boxplot.meanprops.color': ['C2', validate_color],
1031-
'boxplot.meanprops.marker': ['^', six.text_type],
1031+
'boxplot.meanprops.marker': ['^', six.string_types],
10321032
'boxplot.meanprops.markerfacecolor': ['C2', validate_color],
10331033
'boxplot.meanprops.markeredgecolor': ['C2', validate_color],
10341034
'boxplot.meanprops.markersize': [6, validate_float],
@@ -1037,10 +1037,10 @@ def _validate_linestyle(ls):
10371037

10381038
## font props
10391039
'font.family': [['sans-serif'], validate_stringlist], # used by text object
1040-
'font.style': ['normal', six.text_type],
1041-
'font.variant': ['normal', six.text_type],
1042-
'font.stretch': ['normal', six.text_type],
1043-
'font.weight': ['normal', six.text_type],
1040+
'font.style': ['normal', six.string_types],
1041+
'font.variant': ['normal', six.string_types],
1042+
'font.stretch': ['normal', six.string_types],
1043+
'font.weight': ['normal', six.string_types],
10441044
'font.size': [10, validate_float], # Base font size in points
10451045
'font.serif': [['DejaVu Serif', 'Bitstream Vera Serif',
10461046
'Computer Modern Roman',
@@ -1088,10 +1088,10 @@ def _validate_linestyle(ls):
10881088
'mathtext.fallback_to_cm': [True, validate_bool],
10891089

10901090
'image.aspect': ['equal', validate_aspect], # equal, auto, a number
1091-
'image.interpolation': ['nearest', six.text_type],
1092-
'image.cmap': ['viridis', six.text_type], # one of gray, jet, etc
1091+
'image.interpolation': ['nearest', six.string_types],
1092+
'image.cmap': ['viridis', six.string_types], # one of gray, jet, etc
10931093
'image.lut': [256, validate_int], # lookup table
1094-
'image.origin': ['upper', six.text_type], # lookup table
1094+
'image.origin': ['upper', six.string_types], # lookup table
10951095
'image.resample': [True, validate_bool],
10961096
# Specify whether vector graphics backends will combine all images on a
10971097
# set of axes into a single composite image
@@ -1118,7 +1118,7 @@ def _validate_linestyle(ls):
11181118

11191119
'axes.titlesize': ['large', validate_fontsize], # fontsize of the
11201120
# axes title
1121-
'axes.titleweight': ['normal', six.text_type], # font weight of axes title
1121+
'axes.titleweight': ['normal', six.string_types], # font weight of axes title
11221122
'axes.titlepad': [6.0, validate_float], # pad from axes top to title in points
11231123
'axes.grid': [False, validate_bool], # display grid or not
11241124
'axes.grid.which': ['major', validate_axis_locator], # set wether the gid are by
@@ -1130,7 +1130,7 @@ def _validate_linestyle(ls):
11301130
'axes.labelsize': ['medium', validate_fontsize], # fontsize of the
11311131
# x any y labels
11321132
'axes.labelpad': [4.0, validate_float], # space between label and axis
1133-
'axes.labelweight': ['normal', six.text_type], # fontsize of the x any y labels
1133+
'axes.labelweight': ['normal', six.string_types], # fontsize of the x any y labels
11341134
'axes.labelcolor': ['k', validate_color], # color of axis label
11351135
'axes.formatter.limits': [[-7, 7], validate_nseq_int(2)],
11361136
# use scientific notation if log10
@@ -1175,16 +1175,16 @@ def _validate_linestyle(ls):
11751175
'axes3d.grid': [True, validate_bool], # display 3d grid
11761176

11771177
# scatter props
1178-
'scatter.marker': ['o', six.text_type],
1178+
'scatter.marker': ['o', six.string_types],
11791179

11801180
# TODO validate that these are valid datetime format strings
1181-
'date.autoformatter.year': ['%Y', six.text_type],
1182-
'date.autoformatter.month': ['%Y-%m', six.text_type],
1183-
'date.autoformatter.day': ['%Y-%m-%d', six.text_type],
1184-
'date.autoformatter.hour': ['%m-%d %H', six.text_type],
1185-
'date.autoformatter.minute': ['%d %H:%M', six.text_type],
1186-
'date.autoformatter.second': ['%H:%M:%S', six.text_type],
1187-
'date.autoformatter.microsecond': ['%M:%S.%f', six.text_type],
1181+
'date.autoformatter.year': ['%Y', six.string_types],
1182+
'date.autoformatter.month': ['%Y-%m', six.string_types],
1183+
'date.autoformatter.day': ['%Y-%m-%d', six.string_types],
1184+
'date.autoformatter.hour': ['%m-%d %H', six.string_types],
1185+
'date.autoformatter.minute': ['%d %H:%M', six.string_types],
1186+
'date.autoformatter.second': ['%H:%M:%S', six.string_types],
1187+
'date.autoformatter.microsecond': ['%M:%S.%f', six.string_types],
11881188

11891189
#legend properties
11901190
'legend.fancybox': [True, validate_bool],
@@ -1237,7 +1237,7 @@ def _validate_linestyle(ls):
12371237

12381238
# fontsize of the xtick labels
12391239
'xtick.labelsize': ['medium', validate_fontsize],
1240-
'xtick.direction': ['out', six.text_type], # direction of xticks
1240+
'xtick.direction': ['out', six.string_types], # direction of xticks
12411241
'xtick.alignment': ["center", _validate_alignment],
12421242

12431243
'ytick.left': [True, validate_bool], # draw ticks on the left side
@@ -1257,7 +1257,7 @@ def _validate_linestyle(ls):
12571257

12581258
# fontsize of the ytick labels
12591259
'ytick.labelsize': ['medium', validate_fontsize],
1260-
'ytick.direction': ['out', six.text_type], # direction of yticks
1260+
'ytick.direction': ['out', six.string_types], # direction of yticks
12611261
'ytick.alignment': ["center_baseline", _validate_alignment],
12621262

12631263

@@ -1270,7 +1270,7 @@ def _validate_linestyle(ls):
12701270
## figure props
12711271
# figure title
12721272
'figure.titlesize': ['large', validate_fontsize],
1273-
'figure.titleweight': ['normal', six.text_type],
1273+
'figure.titleweight': ['normal', six.string_types],
12741274

12751275
# figure size in inches: width by height
12761276
'figure.figsize': [[6.4, 4.8], validate_nseq_float(2)],
@@ -1308,7 +1308,7 @@ def _validate_linestyle(ls):
13081308
'savefig.bbox': ['standard', validate_bbox],
13091309
'savefig.pad_inches': [0.1, validate_float],
13101310
# default directory in savefig dialog box
1311-
'savefig.directory': ['~', six.text_type],
1311+
'savefig.directory': ['~', six.string_types],
13121312
'savefig.transparent': [False, validate_bool],
13131313

13141314
# Maintain shell focus for TkAgg
@@ -1349,7 +1349,7 @@ def _validate_linestyle(ls):
13491349
# set this when you want to generate hardcopy docstring
13501350
'docstring.hardcopy': [False, validate_bool],
13511351
# where plugin directory is locate
1352-
'plugins.directory': ['.matplotlib_plugins', six.text_type],
1352+
'plugins.directory': ['.matplotlib_plugins', six.string_types],
13531353

13541354
'path.simplify': [True, validate_bool],
13551355
'path.simplify_threshold': [1.0 / 9.0, ValidateInterval(0.0, 1.0)],
@@ -1375,12 +1375,12 @@ def _validate_linestyle(ls):
13751375
'keymap.all_axes': [['a'], validate_stringlist],
13761376

13771377
# sample data
1378-
'examples.directory': ['', six.text_type],
1378+
'examples.directory': ['', six.string_types],
13791379

13801380
# Animation settings
13811381
'animation.html': ['none', validate_movie_html_fmt],
13821382
'animation.writer': ['ffmpeg', validate_movie_writer],
1383-
'animation.codec': ['h264', six.text_type],
1383+
'animation.codec': ['h264', six.string_types],
13841384
'animation.bitrate': [-1, validate_int],
13851385
# Controls image format when frames are written to disk
13861386
'animation.frame_format': ['png', validate_movie_frame_fmt],

0 commit comments

Comments
 (0)
0