Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions pandas/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ def __getattr__(key: str):
from pandas.core.util.hashing import hash_pandas_object

return hash_pandas_object
if key == "Appender":
from pandas.util._decorators import Appender

return Appender
if key == "Substitution":
from pandas.util._decorators import Substitution

Expand Down
43 changes: 1 addition & 42 deletions pandas/util/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import warnings

from pandas._libs.properties import cache_readonly
from pandas._typing import (
F,
T,
)
from pandas._typing import F
from pandas.util._exceptions import find_stack_level

if TYPE_CHECKING:
Expand Down Expand Up @@ -455,43 +452,6 @@ def update(self, *args, **kwargs) -> None:
self.params.update(*args, **kwargs)


class Appender:
"""
A function decorator that will append an addendum to the docstring
of the target function.

This decorator should be robust even if func.__doc__ is None
(for example, if -OO was passed to the interpreter).

Usage: construct a docstring.Appender with a string to be joined to
the original docstring. An optional 'join' parameter may be supplied
which will be used to join the docstring and addendum. e.g.

add_copyright = Appender("Copyright (c) 2009", join='\n')

@add_copyright
def my_dog(has='fleas'):
"This docstring will have a copyright below"
pass
"""

addendum: str | None

def __init__(self, addendum: str | None, join: str = "", indents: int = 0) -> None:
if indents > 0:
self.addendum = indent(addendum, indents=indents)
else:
self.addendum = addendum
self.join = join

def __call__(self, func: T) -> T:
func.__doc__ = func.__doc__ if func.__doc__ else ""
self.addendum = self.addendum if self.addendum else ""
docitems = [func.__doc__, self.addendum]
func.__doc__ = dedent(self.join.join(docitems))
return func


def indent(text: str | None, indents: int = 1) -> str:
if not text or not isinstance(text, str):
return ""
Expand All @@ -500,7 +460,6 @@ def indent(text: str | None, indents: int = 1) -> str:


__all__ = [
"Appender",
"Substitution",
"cache_readonly",
"deprecate",
Expand Down
Loading