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

Skip to content

Commit 144b913

Browse files
committed
Propagate signature-modifying decorators to pyplot wrappers.
1 parent cbd0409 commit 144b913

File tree

4 files changed

+149
-99
lines changed

4 files changed

+149
-99
lines changed

lib/matplotlib/cbook/deprecation.py

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

372367
if func is None:
@@ -388,8 +383,11 @@ def _make_keyword_only(since, name, func=None):
388383

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

0 commit comments

Comments
 (0)