
    z	i<                    H   S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	J
r
  SSSSSS	S
.             SS jjrSSSSSSSS.                 SS jjr                    SS jr              SS jr\" 1 Sk5      r          SS jrg)zDeprecation utilities    )annotationsN)Callable)AnyTypeFQiskitz/no earlier than 3 months after the release date   )additional_msgpendingpackage_nameremoval_timelineis_property
stacklevelc                ,   ^ ^^^^^^ UUUUUU U4S jnU$ )ag  Decorator to indicate a function has been deprecated.

It should be placed beneath other decorators like `@staticmethod` and property decorators.

When deprecating a class, set this decorator on its `__init__` function.

Args:
    since: The version the deprecation started at. If the deprecation is pending, set
        the version to when that started; but later, when switching from pending to
        deprecated, update ``since`` to the new version.
    additional_msg: Put here any additional information, such as what to use instead.
        For example, "Instead, use the function ``new_func`` from the module
        ``<my_module>.<my_submodule>``, which is similar but uses GPU acceleration."
    pending: Set to ``True`` if the deprecation is still pending.
    package_name: The package name shown in the deprecation message (e.g. the PyPI package name).
    removal_timeline: How soon can this deprecation be removed? Expects a value
        like "no sooner than 6 months after the latest release" or "in release 9.99".
    is_property: If the deprecated function is a `@property`, set this to True so that the
        generated message correctly describes it as such. (This isn't necessary for
        property setters, as their docstring is ignored by Python.)
    stacklevel: Stack level passed to :func:`warnings.warn`.
Returns:
    Callable: The decorated callable.
c           	     b  >^ ^^ T R                   nT R                  nT	(       a
  SU SU S3nOBSU;   a3  T R                  S:X  a  US [        S5      *  nSU SU S3nOSU SU S3nO	S	U SU S3n[	        UT
TTTTS
9u  mm[
        R                  " T 5      UU UU4S j5       n[        UTTTS9  U$ )NzThe property ``.``__init__z	.__init__zThe class ``zThe method ``z()``zThe function ``deprecated_entityr   sincer
   r	   r   c                 @   > [         R                  " TTTS9  T" U 0 UD6$ )Ncategoryr   )warningswarn)argskwargsr   funcmsgr   s     R/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/utils/deprecation.pywrapper2deprecate_func.<locals>.decorator.<locals>.wrapper^   s#    MM#ZH(((    r   r
   )__qualname__
__module____name__len_write_deprecation_msg	functoolswrapsadd_deprecation_to_docstring)r   qualnamemod_namer   cls_namer!   r   r   r	   r   r   r
   r   r   r   s   `     @@r    	decorator!deprecate_func.<locals>.decorator;   s    $$??  #2(1XJb I H_}}
*#$7s;'7&78&28*AhZr$J!&3H:Qxj$M!"1(1XJd K./%)-
X 
		) 
	) 	%WcPr#    )r   r	   r
   r   r   r   r   r0   s   ``````` r    deprecate_funcr3      s    F) )V r#   )r	   deprecation_descriptionr
   r   	new_alias	predicater   c          	     4   ^ ^^^^^^^^ UUU UUUUUU4	S jn	U	$ )a\  Decorator to indicate an argument has been deprecated in some way.

This decorator may be used multiple times on the same function, once per deprecated argument.
It should be placed beneath other decorators like ``@staticmethod`` and property decorators.

Args:
    name: The name of the deprecated argument.
    since: The version the deprecation started at. If the deprecation is pending, set
        the version to when that started; but later, when switching from pending to
        deprecated, update `since` to the new version.
    deprecation_description: What is being deprecated? E.g. "Setting my_func()'s `my_arg`
        argument to `None`." If not set, will default to "{func_name}'s argument `{name}`".
    additional_msg: Put here any additional information, such as what to use instead
        (if new_alias is not set). For example, "Instead, use the argument `new_arg`,
        which is similar but does not impact the circuit's setup."
    pending: Set to `True` if the deprecation is still pending.
    package_name: The package name shown in the deprecation message (e.g. the PyPI package name).
    new_alias: If the arg has simply been renamed, set this to the new name. The decorator will
        dynamically update the `kwargs` so that when the user sets the old arg, it will be
        passed in as the `new_alias` arg.
    predicate: Only log the runtime warning if the predicate returns True. This is useful to
        deprecate certain values or types for an argument, e.g.
        `lambda my_arg: isinstance(my_arg, dict)`. Regardless of if a predicate is set, the
        runtime warning will only log when the user specifies the argument.
    removal_timeline: How soon can this deprecation be removed? Expects a value
        like "no sooner than 6 months after the latest release" or "in release 9.99".

Returns:
    Callable: The decorated callable.
c           	       >	^ ^^^^	 T R                    ST R                   S3mT=(       d	    ST ST S3nT(       a  ST S3nT
(       a  U ST
 3nOUnOT
n[        UTTTUTS9u  mm[        R                  " T 5      UU UUUUUU	4S	 j5       m	[        T S
5      (       a  T R                  T	l        OT R                  R                  T	l        [        R                  " T 5      R                  R                  5        Vs1 s H  oDR                  iM     nn[        R                  R                  U;   a  [!        S5      e[#        T	TTTS9  T	$ s  snf )Nr   z()r   z``'s argument ``zInstead, use the argument ``z``, which behaves identically.z. r   c                 J   > [        U UTT	R                  TTTTTS9	  T" U 0 UD6$ )N)	func_nameoriginal_func_co_varnamesold_arg_namer5   warning_msgr   r6   )_maybe_warn_and_rename_kwarg__original_func_co_varnames)
r   r   r   r   r:   r   namer5   r6   r!   s
     r    r!   1deprecate_arg.<locals>.decorator.<locals>.wrapper   s>    (#*1*M*M!#!#
 (((r#   r?   zl@deprecate_arg cannot be used with functions that take variable *args. Use warnings.warn() directly instead.r$   )r&   r%   r)   r*   r+   hasattrr?   __code__co_varnamesinspect	signature
parametersvalueskind	ParameterVAR_POSITIONAL
ValueErrorr,   )r   r   	alias_msgfinal_additional_msgparamparam_kindsr   r:   r   r!   r	   r4   r@   r5   r   r
   r6   r   r   s   `     @@@@r    r0    deprecate_arg.<locals>.decorator   sW   'q):):(;2>	3_I;FVW[V\\^7_6ykA_`I*3B~6F'G$'0$#1 ./%/-
X 
		) 	) 
	)& 4677262R2RG/26--2K2KG/3:3D3DT3J3U3U3\3\3^_3^%::3^K_  //;> 8 
 	%WcP `s   ;E	r2   )
r@   r   r	   r4   r
   r   r5   r6   r   r0   s
   ````````` r    deprecate_argrR   i   s    V7 7r r#   c               (   [        X5       V	V
s0 s H  u  pX_M	     nn	n
UR                  U5        XK;  a  g U(       a  X[;   a  [        U SU SU S35      eX   n	U(       a  U" U	5      (       d  g [        R                  " XgSS9  Ub  XU'   g g s  sn
n	f )Nz received both z and z (deprecated).   r   )zipupdate	TypeErrorr   r   )r   r   r:   r;   r<   r5   r=   r   r6   valr@   arg_names_to_valuess               r    r>   r>      s     7:$6Z[6Z496Z[v&.Y59+_YKu\NR`abb

+C3MM+Q? y  \s   Bc           
         U(       a  [         nSnSU 3nO[        nSnSU 3nU  SU SU SU SU S	3
n	U(       a  U	SU 3-  n	X4$ )
Nzpending deprecationz8marked deprecated in a future release, and then removed 
deprecatedzremoved z is z as of  z. It will be r   )PendingDeprecationWarningDeprecationWarning)
r   r   r   r
   r	   r   r   deprecation_statusremoval_descr   s
             r    r)   r)      s     % 	 3QRbQcd%)!"2!34 
T"4!5W\N!E7 S"^1	&  >"##=r#   >   tip:args:hint:note:todo:warn:error:notes:warns:yield:danger:raises:return:yields:caution:example:returns:warning:	examples:	see also:	warnings:
arguments:
attention:
important:attributes:parameters:references:keyword args:other parameters:keyword arguments:c                  SU;   a  [        SU R                   S35      eUc  SnOU(       a  U S3OUnSnSnU R                  (       a  U R                  R                  5       nSn[	        U5       H  u  pU
R                  5       nU(       d9  U	S	:w  a3  U(       a,  [        U
5      [        U
R                  5       5      -
  nS
U-  nSnUR                  5       [        ;   d  Mo  U	nU(       d  [        SU R                   S35      e  O   O/ nUU SU 3U SU 3U/nU(       a  XUS-
  US-
  & OUR                  U5        SR                  U5      U l        g)zDynamically insert the deprecation message into ``func``'s docstring.

Args:
    func: The function to modify.
    msg: The full deprecation message.
    since: The version the deprecation started at.
    pending: Is the deprecation still pending?

zNDeprecation messages cannot contain new lines (`\n`), but the deprecation for aY   had them. Usually this happens when using `"""` multiline strings; instead, use string concatenation.

This is a simplification to facilitate deprecation messages being added to the documentation. If you have a compelling reason to need new lines, feel free to improve this function or open a request at https://github.com/Qiskit/qiskit/issues.Nunknown_pending Fr   r\   Tzadd_deprecation_to_docstring cannot currently handle when a Napoleon metadata line like 'Args' is the very first line of docstring, e.g. `"""Args:`. So, it cannot process zF. Instead, move the metadata line to the second line, e.g.:

"""
Args:z.. deprecated:: z     )rL   r%   __doc__
splitlines	enumeratestripr(   lstriplower_NAPOLEON_META_LINESextendjoin)r   r   r   r
   version_strindent
meta_indexoriginal_linescontent_encounteredilinestrippednum_leading_spaces	new_liness                 r    r,   r,   6  s{    s{]  ! "77
 	
 },3x(FJ||002# 0GAzz|H
 '16h%(YT[[]1C%C"11&*#~~#77
*$BBFBSBSAT UYZ  - 10  	(";-0("SE	I :CzA~
Q7i(99^,DLr#   )r   strr	   
str | Noner
   boolr   r   r   r   r   r   r   int)r@   r   r   r   r	   r   r4   r   r
   r   r   r   r5   r   r6   Callable[[Any], bool] | Noner   r   )r   ztuple[Any, ...]r   zdict[str, Any]r:   r   r;   ztuple[str, ...]r<   r   r5   r   r=   r   r   zType[Warning]r6   r   returnNone)r   r   r   r   r   r   r
   r   r	   r   r   r   r   zFtuple[str, Type[DeprecationWarning] | Type[PendingDeprecationWarning]])
r   r   r   r   r   r   r
   r   r   r   )r   
__future__r   r*   rE   r   collections.abcr   typingr   r   r3   rR   r>   r)   	frozensetr   r,   r2   r#   r    <module>r      s    "    $  "& MNN N 	N
 N N N Nj "&*.  .2Md
d d 	d
 (d d d d ,d dN 
   	 
  /          ,  
 D  	
    L@ !! HH-
H-H-(2H-=AH-	H-r#   