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

Skip to content

Commit e92685a

Browse files
authored
Merge pull request #15254 from anntzer/propagate-decorators
Propagate signature-modifying decorators to pyplot wrappers.
2 parents 4a6c3b0 + 73746d6 commit e92685a

File tree

4 files changed

+154
-104
lines changed

4 files changed

+154
-104
lines changed

lib/matplotlib/cbook/deprecation.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,6 @@ def _make_keyword_only(since, name, func=None):
393393
"""
394394
Decorator indicating that passing parameter *name* (or any of the following
395395
ones) positionally to *func* is being deprecated.
396-
397-
Note that this decorator **cannot** be applied to a function that has a
398-
pyplot-level wrapper, as the wrapper always pass all arguments by keyword.
399-
If it is used, users will see spurious DeprecationWarnings every time they
400-
call the pyplot wrapper.
401396
"""
402397

403398
if func is None:
@@ -419,8 +414,11 @@ def _make_keyword_only(since, name, func=None):
419414

420415
@functools.wraps(func)
421416
def wrapper(*args, **kwargs):
422-
bound = signature.bind(*args, **kwargs)
423-
if name in bound.arguments and name not in kwargs:
417+
# Don't use signature.bind here, as it would fail when stacked with
418+
# _rename_parameter and an "old" argument name is passed in
419+
# (signature.bind would fail, but the actual call would succeed).
420+
idx = [*func.__signature__.parameters].index(name)
421+
if len(args) > idx:
424422
warn_deprecated(
425423
since, message="Passing the %(name)s %(obj_type)s "
426424
"positionally is deprecated since Matplotlib %(since)s; the "

0 commit comments

Comments
 (0)