File: //lib/python3/dist-packages/twisted/python/__pycache__/deprecate.cpython-38.pyc
U
�bl � @ s� d Z dddddddgZdd lZdd lZdd
lmZ ddlmZ ddlm Z dd
l
mZmZm
Z
mZmZmZ ddlmamZ ddlmZmZ dZdd� Zde_de_de_dd� Zd8dd�Zd9dd�Zd:dd�Zdd� Z d;dd�Z!d<dd�Z"d d� Z#d!d� Z$G d"d#� d#�Z%G d$d%� d%�Z&G d&d'� d'�Z'd(d)� Z(d*d� Z)d+d,� Z*d-d.� Z+d/d0� Z,d1d2� Z-ed3ed4ef d5�Z.d=ee/ee/ ee.ge.f d6�d7d�Z0d S )>aa
Deprecation framework for Twisted.
To mark a method, function, or class as being deprecated do this::
from incremental import Version
from twisted.python.deprecate import deprecated
@deprecated(Version("Twisted", 8, 0, 0))
def badAPI(self, first, second):
'''
Docstring for badAPI.
'''
...
@deprecated(Version("Twisted", 16, 0, 0))
class BadClass:
'''
Docstring for BadClass.
'''
The newly-decorated badAPI will issue a warning when called, and BadClass will
issue a warning when instantiated. Both will also have a deprecation notice
appended to their docstring.
To deprecate properties you can use::
from incremental import Version
from twisted.python.deprecate import deprecatedProperty
class OtherwiseUndeprecatedClass:
@deprecatedProperty(Version('Twisted', 16, 0, 0))
def badProperty(self):
'''
Docstring for badProperty.
'''
@badProperty.setter
def badProperty(self, value):
'''
Setter sill also raise the deprecation warning.
'''
To mark module-level attributes as being deprecated you can use::
badAttribute = "someValue"
...
deprecatedModuleAttribute(
Version("Twisted", 8, 0, 0),
"Use goodAttribute instead.",
"your.full.module.name",
"badAttribute")
The deprecated attributes will issue a warning whenever they are accessed. If
the attributes being deprecated are in the same module as the
L{deprecatedModuleAttribute} call is being made from, the C{__name__} global
can be used as the C{moduleName} parameter.
To mark an optional, keyword parameter of a function or method as deprecated
without deprecating the function itself, you can use::
@deprecatedKeywordParameter(Version("Twisted", 19, 2, 0), 'baz')
def someFunction(foo, bar=0, baz=None):
...
See also L{incremental.Version}.
@type DEPRECATION_WARNING_FORMAT: C{str}
@var DEPRECATION_WARNING_FORMAT: The default deprecation warning string format
to use when one is not provided by the user.
�
deprecated�deprecatedProperty�getDeprecationWarningString�getWarningMethod�setWarningMethod�deprecatedModuleAttribute�deprecatedKeywordParameter� N)�findlinestarts��wraps)�
ModuleType)�Any�Callable�Dict�Optional�TypeVar�cast)�warn�
warn_explicit)�Version�getVersionStringz&%(fqpn)s was deprecated in %(version)sc C sn z
| j }W n tk
r$ | j}Y nX t�| �s:t�| �rN| j}|� d|� �S t�| �rj| j� d| j � �S |S )z�
Return the fully qualified name of a module, class, method or function.
Classes and functions need to be module level ones to be correctly
qualified.
@rtype: C{str}.
�.)�__qualname__�AttributeError�__name__�inspectZisclassZ
isfunction�
__module__Zismethod)�obj�name�
moduleName� r �:/usr/lib/python3/dist-packages/twisted/python/deprecate.py�_fullyQualifiedNameo s
r"