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

Skip to content

Commit 473892d

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

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed
Lines changed: 6 additions & 0 deletions
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

Lines changed: 18 additions & 11 deletions
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):
@@ -476,7 +481,8 @@ def _is_iterable_not_string_like(x):
476481
'markers.fillstyle', ['full', 'left', 'right', 'bottom', 'top', 'none'])
477482

478483

479-
validate_fillstylelist = _listify_validator(validate_fillstyle)
484+
validate_fillstylelist = _listify_validator(
485+
validate_fillstyle, _deprecated="3.6")
480486

481487

482488
def validate_markevery(s):
@@ -516,7 +522,8 @@ def validate_markevery(s):
516522
raise TypeError("'markevery' is of an invalid type")
517523

518524

519-
validate_markeverylist = _listify_validator(validate_markevery)
525+
validate_markeverylist = _listify_validator(
526+
validate_markevery, _deprecated="3.6")
520527

521528

522529
def validate_bbox(s):
@@ -581,8 +588,8 @@ def validate_hatch(s):
581588
return s
582589

583590

584-
validate_hatchlist = _listify_validator(validate_hatch)
585-
validate_dashlist = _listify_validator(validate_floatlist)
591+
validate_hatchlist = _listify_validator(validate_hatch, _deprecated="3.6")
592+
validate_dashlist = _listify_validator(validate_floatlist, _deprecated="3.6")
586593

587594

588595
_prop_validators = {
@@ -594,16 +601,16 @@ def validate_hatch(s):
594601
'edgecolor': validate_colorlist,
595602
'joinstyle': _listify_validator(JoinStyle),
596603
'capstyle': _listify_validator(CapStyle),
597-
'fillstyle': validate_fillstylelist,
604+
'fillstyle': _listify_validator(validate_fillstyle),
598605
'markerfacecolor': validate_colorlist,
599606
'markersize': validate_floatlist,
600607
'markeredgewidth': validate_floatlist,
601608
'markeredgecolor': validate_colorlist,
602-
'markevery': validate_markeverylist,
609+
'markevery': _listify_validator(validate_markevery),
603610
'alpha': validate_floatlist,
604611
'marker': validate_stringlist,
605-
'hatch': validate_hatchlist,
606-
'dashes': validate_dashlist,
612+
'hatch': _listify_validator(validate_hatch),
613+
'dashes': _listify_validator(validate_floatlist),
607614
}
608615
_prop_aliases = {
609616
'c': 'color',
@@ -1186,7 +1193,7 @@ def _convert_validator_spec(key, conv):
11861193
"path.simplify_threshold": _range_validators["0 <= x <= 1"],
11871194
"path.snap": validate_bool,
11881195
"path.sketch": validate_sketch,
1189-
"path.effects": validate_anylist,
1196+
"path.effects": _listify_validator(lambda s: s), # any list
11901197
"agg.path.chunksize": validate_int, # 0 to disable chunking
11911198

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

0 commit comments

Comments
 (0)