8000 Deprecate unused features of normalize_kwargs. · matplotlib/matplotlib@51c8671 · GitHub
[go: up one dir, main page]

Skip to content

Commit 51c8671

Browse files
committed
Deprecate unused features of normalize_kwargs.
The required, forbidden and allowed kwargs of normalize_kwargs have never been used and add a significant amount of complexity to the implementation of normalize kwargs, so get rid of them.
1 parent 160f711 commit 51c8671

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@ Passing both singular and plural *colors*, *linewidths*, *linestyles* to `.Axes.
8282
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8383
Passing e.g. both *linewidth* and *linewidths* will raise a TypeError in the
8484
future.
85+
86+
*required*, *forbidden* and *allowed* parameters of `.cbook.normalize_kwargs`
87+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88+
These parameters are deprecated.

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,8 +3884,7 @@ def line_props_with_rcdefaults(subkey, explicit, zdelta=0,
38843884
if not use_marker:
38853885
d['marker'] = ''
38863886
if explicit is not None:
3887-
d.update(
3888-
cbook.normalize_kwargs(explicit, mlines.Line2D._alias_map))
3887+
d.update(cbook.normalize_kwargs(explicit, mlines.Line2D))
38893888
return d
38903889

38913890
# box properties
@@ -3900,8 +3899,7 @@ def line_props_with_rcdefaults(subkey, explicit, zdelta=0,
39003899
)
39013900
if boxprops is not None:
39023901
final_boxprops.update(
3903-
cbook.normalize_kwargs(
3904-
boxprops, mpatches.PathPatch._alias_map))
3902+
cbook.normalize_kwargs(boxprops, mpatches.PathPatch))
39053903
else:
39063904
final_boxprops = line_props_with_rcdefaults('boxprops', boxprops,
39073905
use_marker=False)

lib/matplotlib/cbook/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,9 @@ def sanitize_sequence(data):
16821682
else data)
16831683

16841684

1685+
@_delete_parameter("3.3", "required")
1686+
@_delete_parameter("3.3", "forbidden")
1687+
@_delete_parameter("3.3", "allowed")
16851688
def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(),
16861689
allowed=None):
16871690
"""
@@ -1713,16 +1716,16 @@ def normalize_kwargs(kw, alias_mapping=None, required=(), forbidden=(),
17131716
mapping.
17141717
17151718
required : list of str, optional
1716-
A list of keys that must be in *kws*.
1719+
A list of keys that must be in *kws*. This parameter is deprecated.
17171720
17181721
forbidden : list of str, optional
1719-
A list of keys which may not be in *kw*.
1722+
A list of keys which may not be in *kw*. This parameter is deprecated.
17201723
17211724
allowed : list of str, optional
17221725
A list of allowed fields. If this not None, then raise if
17231726
*kw* contains any keys not in the union of *required*
17241727
and *allowed*. To allow only the required fields pass in
1725-
an empty tuple ``allowed=()``.
1728+
an empty tuple ``allowed=()``. This parameter is deprecated.
17261729
17271730
Raises
17281731
------

lib/matplotlib/tests/test_cbook.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import itertools
22
import pickle
33
from weakref import ref
4-
import warnings
54
from unittest.mock import patch, Mock
65

76
from datetime import datetime
@@ -329,17 +328,17 @@ def test_sanitize_sequence():
329328

330329
@pytest.mark.parametrize('inp, kwargs_to_norm', fail_mapping)
331330
def test_normalize_kwargs_fail(inp, kwargs_to_norm):
332-
with pytest.raises(TypeError):
331+
with pytest.raises(TypeError), \
332+
cbook._suppress_matplotlib_deprecation_warning():
333333
cbook.normalize_kwargs(inp, **kwargs_to_norm)
334334

335335

336336
@pytest.mark.parametrize('inp, expected, kwargs_to_norm',
337337
pass_mapping)
338-
def test_normalize_kwargs_pass(inp, expected, kwargs_to_norm):
339-
with warnings.catch_warnings(record=True) as w:
340-
warnings.simplefilter("always")
338+
def test_normalize_kwargs_pass(inp, expected, kwargs_to_norm, recwarn):
339+
with cbook._suppress_matplotlib_deprecation_warning():
341340
assert expected == cbook.normalize_kwargs(inp, **kwargs_to_norm)
342-
assert len(w) == 0
341+
assert len(recwarn) == 0
343342

344343

345344
def test_warn_external_frame_embedded_python():

0 commit comments

Comments
 (0)
0