File: //usr/lib/python3/dist-packages/twisted/python/__pycache__/deprecate.cpython-312.pyc
�
�bl � � � d Z g d�ZddlZddlZddlmZ ddlmZ ddlm Z ddl
mZmZm
Z
mZmZmZ ddlmamZ dd lmZmZ d
Zd� Zde_ d
e_ d
e_ d� Zd+d�Zd,d�Zd,d�Zd� Z d+d�Z!d+d�Z"d� Z#d� Z$ G d� d� Z% G d� d� Z& G d� d� Z'd� Z(d� Z)d� Z*d � Z+d!� Z,d"� Z- ed#ed$ef �%� Z. d+d&ed'e/d(ee/ d)ee.ge.f fd*�Z0y)-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 �0 � | j }t j | � st j
| � r| j }|� d|� �S t j | � r| j � d| j � �S |S # t $ r | j }Y ��w xY w)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__�inspect�isclass�
isfunction�
__module__�ismethod)�obj�name�
moduleNames �:/usr/lib/python3/dist-packages/twisted/python/deprecate.py�_fullyQualifiedNamer&