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

Function deprecate_option

pandas/_config/config.py:596–643  ·  view source on GitHub ↗

Mark option `key` as deprecated, if code attempts to access this option, a warning will be produced, using `msg` if given, or a default message if not. if `rkey` is given, any access to the key will be re-routed to `rkey`. Neither the existence of `key` nor that if `rkey` is ch

(
    key: str,
    category: type[Warning],
    msg: str | None = None,
    rkey: str | None = None,
    removal_ver: str | None = None,
)

Source from the content-addressed store, hash-verified

594
595
596def deprecate_option(
597 key: str,
598 category: type[Warning],
599 msg: str | None = None,
600 rkey: str | None = None,
601 removal_ver: str | None = None,
602) -> None:
603 """
604 Mark option `key` as deprecated, if code attempts to access this option,
605 a warning will be produced, using `msg` if given, or a default message
606 if not.
607 if `rkey` is given, any access to the key will be re-routed to `rkey`.
608
609 Neither the existence of `key` nor that if `rkey` is checked. If they
610 do not exist, any subsequence access will fail as usual, after the
611 deprecation warning is given.
612
613 Parameters
614 ----------
615 key : str
616 Name of the option to be deprecated.
617 must be a fully-qualified option name (e.g "x.y.z.rkey").
618 category : Warning
619 Warning class for the deprecation.
620 msg : str, optional
621 Warning message to output when the key is referenced.
622 if no message is given a default message will be emitted.
623 rkey : str, optional
624 Name of an option to reroute access to.
625 If specified, any referenced `key` will be
626 re-routed to `rkey` including set/get/reset.
627 rkey must be a fully-qualified option name (e.g "x.y.z.rkey").
628 used by the default message if no `msg` is specified.
629 removal_ver : str, optional
630 Specifies the version in which this option will
631 be removed. used by the default message if no `msg` is specified.
632
633 Raises
634 ------
635 OptionError
636 If the specified key has already been deprecated.
637 """
638 key = key.lower()
639
640 if key in _deprecated_options:
641 raise OptionError(f"Option '{key}' has already been defined as deprecated.")
642
643 _deprecated_options[key] = DeprecatedOption(key, category, msg, rkey, removal_ver)
644
645
646#

Callers

nothing calls this directly

Calls 3

OptionErrorClass · 0.85
DeprecatedOptionClass · 0.85
lowerMethod · 0.80

Tested by

no test coverage detected