MCPcopy
hub / github.com/pandas-dev/pandas / _warn_if_deprecated

Function _warn_if_deprecated

pandas/_config/config.py:715–746  ·  view source on GitHub ↗

Checks if `key` is a deprecated option and if so, prints a warning. Returns ------- bool - True if `key` is deprecated, False otherwise.

(key: str)

Source from the content-addressed store, hash-verified

713
714
715def _warn_if_deprecated(key: str) -> bool:
716 """
717 Checks if `key` is a deprecated option and if so, prints a warning.
718
719 Returns
720 -------
721 bool - True if `key` is deprecated, False otherwise.
722 """
723 d = _get_deprecated_option(key)
724 if d:
725 if d.msg:
726 warnings.warn(
727 d.msg,
728 d.category,
729 stacklevel=find_stack_level(),
730 )
731 else:
732 msg = f"'{key}' is deprecated"
733 if d.removal_ver:
734 msg += f" and will be removed in {d.removal_ver}"
735 if d.rkey:
736 msg += f", please use '{d.rkey}' instead."
737 else:
738 msg += ", please refrain from using it."
739
740 warnings.warn(
741 msg,
742 d.category,
743 stacklevel=find_stack_level(),
744 )
745 return True
746 return False
747
748
749def _build_option_description(k: str) -> str:

Callers 1

_get_single_keyFunction · 0.85

Calls 2

find_stack_levelFunction · 0.90
_get_deprecated_optionFunction · 0.85

Tested by

no test coverage detected