diff --git a/pandas/util/_decorators.py b/pandas/util/_decorators.py index 165824bec131f..d70cd058898a0 100644 --- a/pandas/util/_decorators.py +++ b/pandas/util/_decorators.py @@ -83,7 +83,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]: if alternative.__doc__.count("\n") < 3: raise AssertionError(doc_error_msg) empty1, summary, empty2, doc_string = alternative.__doc__.split("\n", 3) - if empty1 or empty2 and not summary: + if empty1 or (empty2 and not summary): raise AssertionError(doc_error_msg) wrapper.__doc__ = dedent( f""" @@ -211,7 +211,7 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]: kwargs[new_arg_name] = new_arg_value return func(*args, **kwargs) - return cast(F, wrapper) + return cast("F", wrapper) return _deprecate_kwarg @@ -491,19 +491,21 @@ def __call__(self, func: T) -> T: def indent(text: str | None, indents: int = 1) -> str: if not text or not isinstance(text, str): return "" - jointext = "".join(["\n"] + [" "] * indents) - return jointext.join(text.split("\n")) + indent_str = "\n" + " " * indents + if "\n" not in text: + return text + return indent_str.join(text.split("\n")) __all__ = [ "Appender", + "Substitution", "cache_readonly", "deprecate", "deprecate_kwarg", "deprecate_nonkeyword_arguments", "doc", "future_version_msg", - "Substitution", ]