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

Skip to content

Commit c73e831

Browse files
committed
Improve @deprecated's docstring.
- The example for `name` doesn't work (one would need ``old_function = deprecated("3.x", name="old_function")(new_function) but in practice that'll likely just be written using normal decorator syntax (there are no use cases of explicitly passing `name` in 3.1, AFAICT). - `obj_type` is also automatically set for properties.
1 parent 158a822 commit c73e831

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/matplotlib/cbook/deprecation.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,8 @@ def deprecated(since, *, message='', name='', alternative='', pending=False,
135135
object.
136136
137137
name : str, optional
138-
The name of the deprecated object; if not provided the name
139-
is automatically determined from the passed in object,
140-
though this is useful in the case of renamed functions, where
141-
the new function is just assigned to the name of the
142-
deprecated function. For example::
143-
144-
def new_function():
145-
...
146-
old_function = new_function
138+
The name used in the deprecation message; if not provided, the name
139+
is automatically determined from the deprecated object.
147140
148141
alternative : str, optional
149142
An alternative API that the user may use in place of the deprecated
@@ -155,8 +148,8 @@ def new_function():
155148
DeprecationWarning. Cannot be used together with *removal*.
156149
157150
obj_type : str, optional
158-
The object type being deprecated; by default, 'function' if decorating
159-
a function and 'class' if decorating a class.
151+
The object type being deprecated; by default, 'class' if decorating
152+
a class, 'attribute' if decorating a property, 'function' otherwise.
160153
161154
addendum : str, optional
162155
Additional text appended directly to the final message.

0 commit comments

Comments
 (0)