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 73746d6

Browse filesBrowse files
committed
Propagate signature-modifying decorators to pyplot wrappers.
1 parent 50959b5 commit 73746d6
Copy full SHA for 73746d6

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
@@ -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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.