Skip to content

Commit 86f04cb

Browse files
authored
Merge pull request #28728 from timhoffm/deprecate-reimport
MNT: Deprecate reimported functions in top-level namespace
2 parents 9fd2ef9 + 04fea8c commit 86f04cb

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
matplotlib.validate_backend
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
...is deprecated. Please use `matplotlib.rcsetup.validate_backend` instead.
5+
6+
7+
matplotlib.sanitize_sequence
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
10+
...is deprecated. Please use `matplotlib.cbook.sanitize_sequence` instead.

lib/matplotlib/__init__.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,8 @@
157157
# cbook must import matplotlib only within function
158158
# definitions, so it is safe to import from it here.
159159
from . import _api, _version, cbook, _docstring, rcsetup
160-
from matplotlib.cbook import sanitize_sequence
161160
from matplotlib._api import MatplotlibDeprecationWarning
162161
from matplotlib.rcsetup import cycler # noqa: F401
163-
from matplotlib.rcsetup import validate_backend
164162

165163

166164
_log = logging.getLogger(__name__)
@@ -1258,7 +1256,7 @@ def use(backend, *, force=True):
12581256
matplotlib.pyplot.switch_backend
12591257
12601258
"""
1261-
name = validate_backend(backend)
1259+
name = rcsetup.validate_backend(backend)
12621260
# don't (prematurely) resolve the "auto" backend setting
12631261
if rcParams._get_backend_or_none() == name:
12641262
# Nothing to do if the requested backend is already set
@@ -1362,7 +1360,7 @@ def _replacer(data, value):
13621360
except Exception:
13631361
# key does not exist, silently fall back to key
13641362
pass
1365-
return sanitize_sequence(value)
1363+
return cbook.sanitize_sequence(value)
13661364

13671365

13681366
def _label_from_arg(y, default_name):
@@ -1494,8 +1492,8 @@ def inner(ax, *args, data=None, **kwargs):
14941492
if data is None:
14951493
return func(
14961494
ax,
1497-
*map(sanitize_sequence, args),
1498-
**{k: sanitize_sequence(v) for k, v in kwargs.items()})
1495+
*map(cbook.sanitize_sequence, args),
1496+
**{k: cbook.sanitize_sequence(v) for k, v in kwargs.items()})
14991497

15001498
bound = new_sig.bind(ax, *args, **kwargs)
15011499
auto_label = (bound.arguments.get(label_namer)
@@ -1532,6 +1530,16 @@ def inner(ax, *args, data=None, **kwargs):
15321530
_log.debug('platform is %s', sys.platform)
15331531

15341532

1533+
@_api.deprecated("3.10", alternative="matplotlib.cbook.sanitize_sequence")
1534+
def sanitize_sequence(data):
1535+
return cbook.sanitize_sequence(data)
1536+
1537+
1538+
@_api.deprecated("3.10", alternative="matplotlib.rcsetup.validate_backend")
1539+
def validate_backend(s):
1540+
return rcsetup.validate_backend(s)
1541+
1542+
15351543
# workaround: we must defer colormaps import to after loading rcParams, because
15361544
# colormap creation depends on rcParams
15371545
from matplotlib.cm import _colormaps as colormaps # noqa: E402

0 commit comments

Comments
 (0)