From 1aaf2806fd64df452dff42f1c4f5492062da3636 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 12 Sep 2021 11:47:51 +0200 Subject: [PATCH] Deprecate many single-use rc validators. They can all easily be defined inline at the place of use. --- .../deprecations/21054-AL.rst | 6 ++++ lib/matplotlib/rcsetup.py | 29 ++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/21054-AL.rst diff --git a/doc/api/next_api_changes/deprecations/21054-AL.rst b/doc/api/next_api_changes/deprecations/21054-AL.rst new file mode 100644 index 000000000000..06d491edb752 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/21054-AL.rst @@ -0,0 +1,6 @@ +Deprecation of rcParams validators +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The following rcParams validators defined in :mod:`.rcsetup` are +deprecated with no replacement: ``validate_any``, ``validate_anylist``, +``validate_fillstylelist``, ``validate_markeverylist``, ``validate_hatchlist``, +``validate_dashlist``. diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 663ff4b70536..99902b7435ce 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -84,8 +84,12 @@ def __call__(self, s): @lru_cache def _listify_validator(scalar_validator, allow_stringlist=False, *, - n=None, doc=None): + n=None, doc=None, _deprecated=None): def f(s): + if _deprecated: + name, = (k for k, v in globals().items() if v is f) + cbook.warn_deprecated( + _deprecated, name=name, obj_type="function") if isinstance(s, str): try: val = [scalar_validator(v.strip()) for v in s.split(',') @@ -123,9 +127,10 @@ def f(s): return f +@_api.deprecated("3.8") def validate_any(s): return s -validate_anylist = _listify_validator(validate_any) +validate_anylist = _listify_validator(validate_any, _deprecated="3.8") def _validate_date(s): @@ -487,7 +492,8 @@ def _is_iterable_not_string_like(x): 'markers.fillstyle', ['full', 'left', 'right', 'bottom', 'top', 'none']) -validate_fillstylelist = _listify_validator(validate_fillstyle) +validate_fillstylelist = _listify_validator( + validate_fillstyle, _deprecated="3.8") def validate_markevery(s): @@ -524,7 +530,8 @@ def validate_markevery(s): raise TypeError("'markevery' is of an invalid type") -validate_markeverylist = _listify_validator(validate_markevery) +validate_markeverylist = _listify_validator( + validate_markevery, _deprecated="3.8") def validate_bbox(s): @@ -591,8 +598,8 @@ def validate_hatch(s): return s -validate_hatchlist = _listify_validator(validate_hatch) -validate_dashlist = _listify_validator(validate_floatlist) +validate_hatchlist = _listify_validator(validate_hatch, _deprecated="3.8") +validate_dashlist = _listify_validator(validate_floatlist, _deprecated="3.8") def _validate_minor_tick_ndivs(n): @@ -622,16 +629,16 @@ def _validate_minor_tick_ndivs(n): 'edgecolor': validate_colorlist, 'joinstyle': _listify_validator(JoinStyle), 'capstyle': _listify_validator(CapStyle), - 'fillstyle': validate_fillstylelist, + 'fillstyle': _listify_validator(validate_fillstyle), 'markerfacecolor': validate_colorlist, 'markersize': validate_floatlist, 'markeredgewidth': validate_floatlist, 'markeredgecolor': validate_colorlist, - 'markevery': validate_markeverylist, + 'markevery': _listify_validator(validate_markevery), 'alpha': validate_floatlist, 'marker': validate_stringlist, - 'hatch': validate_hatchlist, - 'dashes': validate_dashlist, + 'hatch': _listify_validator(validate_hatch), + 'dashes': _listify_validator(validate_floatlist), } _prop_aliases = { 'c': 'color', @@ -1234,7 +1241,7 @@ def _convert_validator_spec(key, conv): "path.simplify_threshold": _validate_greaterequal0_lessequal1, "path.snap": validate_bool, "path.sketch": validate_sketch, - "path.effects": validate_anylist, + "path.effects": _listify_validator(lambda s: s), # any list "agg.path.chunksize": validate_int, # 0 to disable chunking # key-mappings (multi-character mappings should be a list/tuple) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy