Skip to content

Commit ce1eed0

Browse files
committed
Propagate signature-modifying decorators to pyplot wrappers.
1 parent dc1f0d9 commit ce1eed0

File tree

4 files changed

+154
-104
lines changed

4 files changed

+154
-104
lines changed

lib/matplotlib/cbook/deprecation.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,6 @@ def _make_keyword_only(since, name, func=None):
360360
"""
361361
Decorator indicating that passing parameter *name* (or any of the following
362362
ones) positionally to *func* is being deprecated.
363-
364-
Note that this decorator **cannot** be applied to a function that has a
365-
pyplot-level wrapper, as the wrapper always pass all arguments by keyword.
366-
If it is used, users will see spurious DeprecationWarnings every time they
367-
call the pyplot wrapper.
368363
"""
369364

370365
if func is None:
@@ -386,8 +381,11 @@ def _make_keyword_only(since, name, func=None):
386381

387382
@functools.wraps(func)
388383
def wrapper(*args, **kwargs):
389-
bound = signature.bind(*args, **kwargs)
390-
if name in bound.arguments and name not in kwargs:
384+
# Don't use signature.bind here, as it would fail when stacked with
385+
# _rename_parameter and an "old" argument name is passed in
386+
# (signature.bind would fail, but the actual call would succeed).
387+
idx = [*func.__signature__.parameters].index(name)
388+
if len(args) > idx:
391389
warn_deprecated(
392390
since, message="Passing the %(name)s %(obj_type)s "
393391
"positionally is deprecated since Matplotlib %(since)s; the "

0 commit comments

Comments
 (0)