Skip to content

Commit 5b5508d

Browse files
committed
update name and type from function to callable
1 parent 363f1be commit 5b5508d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pandas/util/_decorators.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]:
245245
return decorate
246246

247247

248-
def doc(*args: Union[str, Callable], **kwargs: str) -> Callable[[F], F]:
248+
def doc(*args: Union[str, Callable], **kwargs: str) -> Callable[[Callable], Callable]:
249249
"""
250250
A decorator take docstring templates, concatenate them and perform string
251251
substitution on it.
252252
253253
This decorator will add a variable "_docstring_components" to the wrapped
254-
function to keep track the original docstring template for potential usage.
254+
callable to keep track the original docstring template for potential usage.
255255
If it should be consider as a template, it will be saved as a string.
256256
Otherwise, it will be saved as callable, and later user __doc__ and dedent
257257
to get docstring.
@@ -260,16 +260,16 @@ def doc(*args: Union[str, Callable], **kwargs: str) -> Callable[[F], F]:
260260
----------
261261
*args : str or callable
262262
The string / docstring / docstring template to be appended in order
263-
after default docstring under function.
263+
after default docstring under callable.
264264
**kwags : str
265265
The string which would be used to format docstring template.
266266
"""
267267

268-
def decorator(func: F) -> F:
268+
def decorator(call: Callable) -> Callable:
269269
# collecting docstring and docstring templates
270270
docstring_components: List[Union[str, Callable]] = []
271-
if func.__doc__:
272-
docstring_components.append(dedent(func.__doc__))
271+
if call.__doc__:
272+
docstring_components.append(dedent(call.__doc__))
273273

274274
for appender in args:
275275
if hasattr(appender, "_docstring_components"):
@@ -280,7 +280,7 @@ def decorator(func: F) -> F:
280280
docstring_components.append(appender)
281281

282282
# formatting templates and concatenating docstring
283-
func.__doc__ = "".join(
283+
call.__doc__ = "".join(
284284
[
285285
component.format(**kwargs)
286286
if isinstance(component, str)
@@ -289,8 +289,8 @@ def decorator(func: F) -> F:
289289
]
290290
)
291291

292-
func._docstring_components = docstring_components # type: ignore
293-
return func
292+
call._docstring_components = docstring_components # type: ignore
293+
return call
294294

295295
return decorator
296296

0 commit comments

Comments
 (0)