FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Propagate signature-modifying decorators to pyplot wrappers. by anntzer · Pull Request #15254 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (4) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 5 additions & 7 deletions lib/matplotlib/cbook/deprecation.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,6 @@ def _make_keyword_only(since, name, func=None):
"""
Decorator indicating that passing parameter *name* (or any of the following
ones) positionally to *func* is being deprecated.

Note that this decorator **cannot** be applied to a function that has a
pyplot-level wrapper, as the wrapper always pass all arguments by keyword.
If it is used, users will see spurious DeprecationWarnings every time they
call the pyplot wrapper.
"""

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

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

Back | FazBrowse Home | New Git URL