Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8597f7

Browse filesBrowse files
committed
Propagate signature-modifying decorators to pyplot wrappers.
1 parent dc1f0d9 commit e8597f7
Copy full SHA for e8597f7

File tree

Expand file treeCollapse file tree

4 files changed

+154
-104
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+154
-104
lines changed

‎lib/matplotlib/cbook/deprecation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/deprecation.py
+5-7Lines changed: 5 additions & 7 deletions
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 succed).
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.