diff --git a/pandas/core/common.py b/pandas/core/common.py index 6d419098bf279..1679e01ff9fe1 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -531,17 +531,24 @@ def convert_to_list_like( def temp_setattr( obj, attr: str, value, condition: bool = True ) -> Generator[None, None, None]: - """Temporarily set attribute on an object. - - Args: - obj: Object whose attribute will be modified. - attr: Attribute to modify. - value: Value to temporarily set attribute to. - condition: Whether to set the attribute. Provided in order to not have to - conditionally use this context manager. + """ + Temporarily set attribute on an object. - Yields: - obj with modified attribute. + Parameters + ---------- + obj : object + Object whose attribute will be modified. + attr : str + Attribute to modify. + value : Any + Value to temporarily set attribute to. + condition : bool, default True + Whether to set the attribute. Provided in order to not have to + conditionally use this context manager. + + Yields + ------ + object : obj with modified attribute. """ if condition: old_value = getattr(obj, attr)