MCPcopy Index your code
hub / github.com/RustPython/RustPython / _deprecated

Function _deprecated

Lib/_py_warnings.py:817–833  ·  view source on GitHub ↗

Warn that *name* is deprecated or should be removed. RuntimeError is raised if *remove* specifies a major/minor tuple older than the current Python version or the same version but past the alpha. The *message* argument is formatted with *name* and *remove* as a Python version tuple

(name, message=_DEPRECATED_MSG, *, remove, _version=sys.version_info)

Source from the content-addressed store, hash-verified

815
816
817def _deprecated(name, message=_DEPRECATED_MSG, *, remove, _version=sys.version_info):
818 """Warn that *name* is deprecated or should be removed.
819
820 RuntimeError is raised if *remove* specifies a major/minor tuple older than
821 the current Python version or the same version but past the alpha.
822
823 The *message* argument is formatted with *name* and *remove* as a Python
824 version tuple (e.g. (3, 11)).
825
826 """
827 remove_formatted = f"{remove[0]}.{remove[1]}"
828 if (_version[:2] > remove) or (_version[:2] == remove and _version[3] != "alpha"):
829 msg = f"{name!r} was slated for removal after Python {remove_formatted} alpha"
830 raise RuntimeError(msg)
831 else:
832 msg = message.format(name=name, remove=remove_formatted)
833 _wm.warn(msg, DeprecationWarning, stacklevel=3)
834
835
836# Private utility function called by _PyErr_WarnUnawaitedCoroutine

Callers 1

add_typeMethod · 0.90

Calls 2

formatMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected