Skip to content

Commit 9280b47

Browse files
authored
Merge pull request matplotlib#30783 from timhoffm/doc-make-keyword-only
DOC: Add example usage to make_keyword_only()
1 parent b94feab commit 9280b47

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/matplotlib/_api/deprecation.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,23 @@ def make_keyword_only(since, name, func=None):
419419
When used on a method that has a pyplot wrapper, this should be the
420420
outermost decorator, so that :file:`boilerplate.py` can access the original
421421
signature.
422+
423+
Examples
424+
--------
425+
Assume we want to only allow *dataset* and *positions* as positional
426+
parameters on the method ::
427+
428+
def violinplot(self, dataset, positions=None, vert=None, ...)
429+
430+
Introduce the deprecation by adding the decorator ::
431+
432+
@_api.make_keyword_only("3.10", "vert")
433+
def violinplot(self, dataset, positions=None, vert=None, ...)
434+
435+
When the deprecation expires, switch to ::
436+
437+
def violinplot(self, dataset, positions=None, *, vert=None, ...)
438+
422439
"""
423440

424441
decorator = functools.partial(make_keyword_only, since, name)

0 commit comments

Comments
 (0)