Skip to content

Commit fbda8d5

Browse files
committed
Deprecate many single-use rc validators.
They can all easily be defined inline at the place of use.
1 parent fc350ea commit fbda8d5

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deprecation of rcParams validators
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
The following rcParams validators defined in :mod:`.rcsetup` are
4+
deprecated with no replacement: ``validate_any``, ``validate_anylist``,
5+
``validate_fillstylelist``, ``validate_markeverylist``, ``validate_hatchlist``,
6+
``validate_dashlist``.

lib/matplotlib/rcsetup.py

+18-11
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ def __call__(self, s):
8484

8585
@lru_cache
8686
def _listify_validator(scalar_validator, allow_stringlist=False, *,
87-
n=None, doc=None):
87+
n=None, doc=None, _deprecated=None):
8888
def f(s):
89+
if _deprecated:
90+
name, = (k for k, v in globals().items() if v is f)
91+
cbook.warn_deprecated(
92+
_deprecated, name=name, obj_type="function")
8993
if isinstance(s, str):
9094
try:
9195
val = [scalar_validator(v.strip()) for v in s.split(',')
@@ -123,9 +127,10 @@ def f(s):
123127
return f
124128

125129

130+
@_api.deprecated("3.6")
126131
def validate_any(s):
127132
return s
128-
validate_anylist = _listify_validator(validate_any)
133+
validate_anylist = _listify_validator(validate_any, _deprecated="3.6")
129134

130135

131136
def _validate_date(s):
@@ -487,7 +492,8 @@ def _is_iterable_not_string_like(x):
487492
'markers.fillstyle', ['full', 'left', 'right', 'bottom', 'top', 'none'])
488493

489494

490-
validate_fillstylelist = _listify_validator(validate_fillstyle)
495+
validate_fillstylelist = _listify_validator(
496+
validate_fillstyle, _deprecated="3.6")
491497

492498

493499
def validate_markevery(s):
@@ -524,7 +530,8 @@ def validate_markevery(s):
524530
raise TypeError("'markevery' is of an invalid type")
525531

526532

527-
validate_markeverylist = _listify_validator(validate_markevery)
533+
validate_markeverylist = _listify_validator(
534+
validate_markevery, _deprecated="3.6")
528535

529536

530537
def validate_bbox(s):
@@ -591,8 +598,8 @@ def validate_hatch(s):
591598
return s
592599

593600

594-
validate_hatchlist = _listify_validator(validate_hatch)
595-
validate_dashlist = _listify_validator(validate_floatlist)
601+
validate_hatchlist = _listify_validator(validate_hatch, _deprecated="3.6")
602+
validate_dashlist = _listify_validator(validate_floatlist, _deprecated="3.6")
596603

597604

598605
def _validate_minor_tick_ndivs(n):
@@ -622,16 +629,16 @@ def _validate_minor_tick_ndivs(n):
622629
'edgecolor': validate_colorlist,
623630
'joinstyle': _listify_validator(JoinStyle),
624631
'capstyle': _listify_validator(CapStyle),
625-
'fillstyle': validate_fillstylelist,
632+
'fillstyle': _listify_validator(validate_fillstyle),
626633
'markerfacecolor': validate_colorlist,
627634
'markersize': validate_floatlist,
628635
'markeredgewidth': validate_floatlist,
629636
'markeredgecolor': validate_colorlist,
630-
'markevery': validate_markeverylist,
637+
'markevery': _listify_validator(validate_markevery),
631638
'alpha': validate_floatlist,
632639
'marker': validate_stringlist,
633-
'hatch': validate_hatchlist,
634-
'dashes': validate_dashlist,
640+
'hatch': _listify_validator(validate_hatch),
641+
'dashes': _listify_validator(validate_floatlist),
635642
}
636643
_prop_aliases = {
637644
'c': 'color',
@@ -1234,7 +1241,7 @@ def _convert_validator_spec(key, conv):
12341241
"path.simplify_threshold": _validate_greaterequal0_lessequal1,
12351242
"path.snap": validate_bool,
12361243
"path.sketch": validate_sketch,
1237-
"path.effects": validate_anylist,
1244+
"path.effects": _listify_validator(lambda s: s), # any list
12381245
"agg.path.chunksize": validate_int, # 0 to disable chunking
12391246

12401247
# key-mappings (multi-character mappings should be a list/tuple)

0 commit comments

Comments
 (0)