Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 001dd9b

Browse files
authored
Merge pull request #16604 from anntzer/rcv
Deprecate more rc validators.
2 parents 2df1c54 + 37c7620 commit 001dd9b

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,11 @@ The following validators, defined in `.rcsetup`, are deprecated:
225225
``validate_movie_frame_fmt``, ``validate_axis_locator``,
226226
``validate_movie_html_fmt``, ``validate_grid_axis``,
227227
``validate_axes_titlelocation``, ``validate_toolbar``,
228-
``validate_ps_papersize``, ``validate_legend_log``. To test whether an rcParam
229-
value would be acceptable, one can test e.g. ``rc = RcParams(); rc[k] = v``
230-
raises an exception.
228+
``validate_ps_papersize``, ``validate_legend_loc``,
229+
``validate_bool_maybe_none``, ``validate_hinting``,
230+
``validate_movie_writers``.
231+
To test whether an rcParam value would be acceptable, one can test e.g. ``rc =
232+
RcParams(); rc[k] = v`` raises an exception.
231233

232234
Stricter rcParam validation
233235
~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/matplotlib/rcsetup.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def validate_bool(b):
139139
raise ValueError('Could not convert "%s" to bool' % b)
140140

141141

142+
@cbook.deprecated("3.3")
142143
def validate_bool_maybe_none(b):
143144
"""Convert b to ``bool`` or raise, passing through *None*."""
144145
if isinstance(b, str):
@@ -663,7 +664,13 @@ def validate_markevery(s):
663664
'svg.fonttype', ['none', 'path'], _deprecated_since="3.3")
664665

665666

667+
@cbook.deprecated("3.3")
666668
def validate_hinting(s):
669+
return _validate_hinting(s)
670+
671+
672+
# Replace by plain list in _prop_validators after deprecation period.
673+
def _validate_hinting(s):
667674
if s in (True, False):
668675
cbook.warn_deprecated(
669676
"3.2", message="Support for setting the text.hinting rcParam to "
@@ -680,6 +687,7 @@ def validate_hinting(s):
680687
_deprecated_since="3.3")
681688

682689

690+
@cbook.deprecated("3.3")
683691
def validate_movie_writer(s):
684692
# writers.list() would only list actually available writers, but
685693
# FFMpeg.isAvailable is slow and not worth paying for at every import.
@@ -1147,7 +1155,7 @@ def _convert_validator_spec(key, conv):
11471155
'text.usetex': [False, validate_bool],
11481156
'text.latex.preamble': ['', _validate_tex_preamble],
11491157
'text.latex.preview': [False, validate_bool],
1150-
'text.hinting': ['auto', validate_hinting],
1158+
'text.hinting': ['auto', _validate_hinting],
11511159
'text.hinting_factor': [8, validate_int],
11521160
'text.kerning_factor': [0, validate_int],
11531161
'text.antialiased': [True, validate_bool],
@@ -1467,7 +1475,7 @@ def _convert_validator_spec(key, conv):
14671475
# Limit, in MB, of size of base64 encoded animation in HTML
14681476
# (i.e. IPython notebook)
14691477
'animation.embed_limit': [20, validate_float],
1470-
'animation.writer': ['ffmpeg', validate_movie_writer],
1478+
'animation.writer': ['ffmpeg', validate_string],
14711479
'animation.codec': ['h264', validate_string],
14721480
'animation.bitrate': [-1, validate_int],
14731481
# Controls image format when frames are written to disk

lib/matplotlib/tests/test_rcparams.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ def test_Bug_2543():
125125
# real test is that this does not raise
126126
assert validate_bool_maybe_none(None) is None
127127
assert validate_bool_maybe_none("none") is None
128-
129-
with pytest.raises(ValueError):
130-
validate_bool_maybe_none("blah")
128+
with pytest.raises(ValueError):
129+
validate_bool_maybe_none("blah")
131130
with pytest.raises(ValueError):
132131
validate_bool(None)
133132
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)