Repository URL to install this package:
Version:
0.1.3 ▾
|
odigos
/
etc
/
odigos-vmagent
/
instrumentations
/
python
/
deprecated
/
__pycache__
/
classic.cpython-311.pyc
|
---|
§ O>gq) ã óè d Z ddlZddlZddlZddlZddlZ ddlZdZdZn%# e $ r dZ ej ¦ « dk rdZndZY nw xY w ed¦ « ed¦ « fZ G d d ej ¦ « Zd ZdS )zñ Classic deprecation warning =========================== Classic ``@deprecated`` decorator to deprecate old python classes, functions or methods. .. _The Warnings Filter: https://docs.python.org/3/library/warnings.html#the-warnings-filter é Né é ÚPyPyó Ú c ó: e Zd ZdZdddedf fd Zd Zd Z xZS )ÚClassicAdaptera8 Classic adapter -- *for advanced usage only* This adapter is used to get the deprecation message according to the wrapped object type: class, function, standard method, static method, or class method. This is the base class of the :class:`~deprecated.sphinx.SphinxAdapter` class which is used to update the wrapped object docstring. You can also inherit this class to change the deprecation message. In the following example, we change the message into "The ... is deprecated.": .. code-block:: python import inspect from deprecated.classic import ClassicAdapter from deprecated.classic import deprecated class MyClassicAdapter(ClassicAdapter): def get_deprecated_msg(self, wrapped, instance): if instance is None: if inspect.isclass(wrapped): fmt = "The class {name} is deprecated." else: fmt = "The function {name} is deprecated." else: if inspect.isclass(instance): fmt = "The class method {name} is deprecated." else: fmt = "The method {name} is deprecated." if self.reason: fmt += " ({reason})" if self.version: fmt += " -- Deprecated since version {version}." return fmt.format(name=wrapped.__name__, reason=self.reason or "", version=self.version or "") Then, you can use your ``MyClassicAdapter`` class like this in your source code: .. code-block:: python @deprecated(reason="use another function", adapter_cls=MyClassicAdapter) def some_old_function(x, y): return x + y r Nr c ó¤ |pd| _ |pd| _ || _ || _ || _ t t | ¦ « ¦ « dS )a Construct a wrapper adapter. :type reason: str :param reason: Reason message which documents the deprecation in your library (can be omitted). :type version: str :param version: Version of your project which deprecates this feature. If you follow the `Semantic Versioning <https://semver.org/>`_, the version number has the format "MAJOR.MINOR.PATCH". :type action: Literal["default", "error", "ignore", "always", "module", "once"] :param action: A warning filter used to activate or not the deprecation warning. Can be one of "error", "ignore", "always", "default", "module", or "once". If ``None`` or empty, the global filtering mechanism is used. See: `The Warnings Filter`_ in the Python documentation. :type category: Type[Warning] :param category: The warning category to use for the deprecation warning. By default, the category class is :class:`~DeprecationWarning`, you can inherit this class to define your own deprecation warning category. :type extra_stacklevel: int :param extra_stacklevel: Number of additional stack levels to consider instrumentation rather than user code. With the default value of 0, the warning refers to where the class was instantiated or the function was called. .. versionchanged:: 1.2.15 Add the *extra_stacklevel* parameter. r N)ÚreasonÚversionÚactionÚcategoryÚextra_stacklevelÚsuperr Ú__init__)Úselfr r r r r Ú __class__s ú9/tmp/pip-target-qlpkiub5/lib/python/deprecated/classic.pyr zClassicAdapter.__init__V sT ø ðH l Ø} "ØØ Ø 0ÔÝ ndÑ#Ô#×,Ò,Ñ.Ô.Ð.Ð.Ð.r c óò |t j |¦ « rd}nd}nt j |¦ « rd}nd}| j r|dz }| j r|dz }| |j | j pd| j pd¬ ¦ « S ) zÿ Get the deprecation warning message for the user. :param wrapped: Wrapped class or function. :param instance: The object to which the wrapped function was bound when it was called. :return: The warning message. Nz Call to deprecated class {name}.z5Call to deprecated function (or staticmethod) {name}.z'Call to deprecated class method {name}.z!Call to deprecated method {name}.z ({reason})z' -- Deprecated since version {version}.r )Únamer r )ÚinspectÚisclassr r ÚformatÚ__name__)r ÚwrappedÚinstanceÚfmts r Úget_deprecated_msgz!ClassicAdapter.get_deprecated_msg s ð ÐÝwÑ'Ô'ð NØ8àMåxÑ(Ô(ð :Ø?à9Ø;ð !Ø=Ñ CØ<ð =ØÐ<Ñ<CØzzwÔ/¸¼Ð8IÀrÐSWÔS_ÐSeÐcezÑfÔfÐfr c ó8 t j ¦ « r#j fd}t |¦ « _ n_t j ¦ « r"t j fd¦ « } |¦ « S t t t ¦ « ¦ « ¦ « S )a Decorate your class or function. :param wrapped: Wrapped class or function. :return: the decorated class or function. .. versionchanged:: 1.2.4 Don't pass arguments to :meth:`object.__new__` (other than *cls*). .. versionchanged:: 1.2.8 The warning filter is not set if the *action* parameter is ``None`` or empty. c ó¬ d ¦ « }t j z }j rgt j ¦ « 5 t j j j ¦ « t j |j |¬¦ « d d d ¦ « n# 1 swxY w Y nt j |j |¬¦ « t j u r | ¦ « S | g|¢R i |¤S ©N)r Ú stacklevel)r Ú_class_stacklevelr r ÚwarningsÚcatch_warningsÚsimplefilterr ÚwarnÚobjectÚ__new__)ÚclsÚargsÚkwargsÚmsgr" Úold_new1r r s r Úwrapped_clsz,ClassicAdapter.__call__.<locals>.wrapped_cls¬ s, ø Ø×-Ò-¨g°tÑ<Ô<Ý.°Ô1FÑF Ø;ð VÝ!Ô0Ñ2Ô2ð Zð ZÝ Ô-¨d¬k¸4¼=ÑIÔIÐIÝ c°D´MÈjÐYÑYÔYÐYðZð Zð Zñ Zô Zð Zð Zð Zð Zð Zð Zøøøð Zð Zð Zð Zøõ M #°´ È*ÐUÑUÔUÐUØv~Ð-Ð-Ø#8 C==Ð(àx Ð5 dÐ5Ð5Ð5¨fÐ5Ð5Ð5ó Á<B  B ÂB c ór | |¦ « }t j z }j rgt j ¦ « 5 t j j j ¦ « t j |j |¬¦ « d d d ¦ « n# 1 swxY w Y nt j |j |¬¦ « | |i |¤S r! ) r Ú_routine_stacklevelr r r$ r% r&