
    i;                    (   % S r SSKJr  SSKrSSKrSSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  \(       a:  SS	KJrJr  SS
KJrJrJr  SSKJrJr  SSKJr  \" S5      r\" S5      r\" S\\   S9r " S S\5      r " S S5      r\" \5      r S\!S'   g)z
Reusable helpers for deprecating functionality.

Note: most of this file has been copied from conda's implementation. Usage
documentation can be found here: https://docs.conda.io/projects/conda/en/latest/dev-guide/deprecations.html

    )annotationsN)Action)wraps)
ModuleType)TYPE_CHECKING)__version__)ArgumentParser	Namespace)AnyCallableTypeVar)	ParamSpecSelf)VersionTP
ActionType)boundc                      \ rS rSrSrg)DeprecatedError#    N)__name__
__module____qualname____firstlineno____static_attributes__r       >lib/python3.13/site-packages/anaconda_cli_base/deprecations.pyr   r   #   s    r   r   c                     \ rS rSr% S\S'   S\S'   S\S'   SS jr\SS	 j5       rSS
 jrSSS.           SS jjr	SSSS.               SS jjr
SSS.             SS jjrSSS.           SS jjrSSS.               S S jjrSSS.             S!S jjrS"S jr\S.             S#S jjrSrg)$DeprecationHandler)   
str | None_versiontuple[int, ...] | None_version_tuplezVersion | None_version_objectc                J    Xl         U R                  U5      U l        SU l        g)zFactory to create a deprecation handle for the specified version.

Args:
    version: The version to compare against when checking deprecation statuses.

N)r$   _get_version_tupler&   r'   )selfversions     r   __init__DeprecationHandler.__init__.   s&       #55g>#r   c                     [        S U R                  5       R                  S5       5       5      =(       d    S$ ! [        [        4 a     gf = f)zpReturn version as non-empty tuple of ints if possible, else None.

Args:
    version: Version string to parse.

c              3  8   #    U  H  n[        U5      v   M     g 7fN)int).0parts     r   	<genexpr>8DeprecationHandler._get_version_tuple.<locals>.<genexpr>D   s     J/ItT/Is   .N)tuplestripsplitAttributeError
ValueError)r+   s    r   r)   %DeprecationHandler._get_version_tuple;   sE    	Jw}}/D/DS/IJJRdR
+ 		s   7: AAc                ,   U R                   (       a'  U R                  U5      =n(       a  U R                   U:  $ SSKJn  U R                  c   U" U R
                  5      U l        U R                  U" U5      :  $ ! [         a    U" S5      U l         N.f = f)zqTest whether own version is less than the given version.

Args:
    version: Version string to compare against.

r   )parsez0.0.0.dev0+placeholder)r&   r)   packaging.versionr>   r'   r$   	TypeError)r*   r+   version_tupler>   s       r   _version_less_than%DeprecationHandler._version_less_thanH   s     T5L5LW5U$UM$U&&66
 	,'G',T]]';$ ##eGn44  G',-E'F$Gs   A9 9BBNr   )addendumstackc               (   ^ ^^^^ SUUUU U4S jjnU$ )aE  Deprecation decorator for functions, methods, & classes.

Args:
    deprecate_in: Version in which code will be marked as deprecated.
    remove_in: Version in which code is expected to be removed.
    addendum: Optional additional messaging. Useful to indicate what to do instead.
    stack: Optional stacklevel increment.

c                   >^ ^^ TR                  TTT R                   ST R                   3TS9u  mmT(       d  [        T5      e[	        T 5      SUU UU4S jj5       nU$ )Nr6   deprecate_in	remove_inprefixrD   c                 F   > [         R                  " TTST-   S9  T" U 0 UD6$ N   
stacklevel)warningswarn)argskwargscategoryfuncmessagerE   s     r   innerHDeprecationHandler.__call__.<locals>.deprecated_decorator.<locals>.inner   s'    gxAIFT,V,,r   rS   zP.argsrT   zP.kwargsreturnr   _generate_messager   r   r   r   )	rV   rX   rU   rW   rD   rI   rJ   r*   rE   s	   ` @@r   deprecated_decorator9DeprecationHandler.__call__.<locals>.deprecated_decoratorq   st     $ 6 6)#//*!D,=,=+>?!	 !7 !Hg %g.. 4[- - -
 Lr   rV   Callable[P, T]r[   ra   r   )r*   rI   rJ   rD   rE   r^   s   ````` r   __call__DeprecationHandler.__call___   s    $	 	, $#r   )renamerD   rE   c               0   ^ ^^^^^^ SUUUUUU U4S jjnU$ )a  Deprecation decorator for keyword arguments.

Args:
    deprecate_in: Version in which code will be marked as deprecated.
    remove_in: Version in which code is expected to be removed.
    argument: The argument to deprecate.
    rename: Optional new argument name.
    addendum: Optional additional messaging. Useful to indicate what to do instead.
    stack: Optional stacklevel increment.

c           
        >^ ^^ T	R                  TTT R                   ST R                   ST S3T(       a  T(       d  ST S3OTS9u  mmT(       d  [        T5      e[	        T 5      SUUU UUU
4S jj5       nU$ )	Nr6   ()zUse 'z
' instead.rH   c                    > TU;   aD  [         R                  " TTST-   S9  UR                  TS 5      nT(       a  UR                  TU5        T" U 0 UD6$ rM   )rQ   rR   pop
setdefault)	rS   rT   valueargumentrU   rV   rW   rd   rE   s	      r   rX   HDeprecationHandler.argument.<locals>.deprecated_decorator.<locals>.inner   sV     v%MM'8E	J #JJx6E))&%8T,V,,r   rZ   r\   )rV   rX   rU   rW   rD   rm   rI   rJ   rd   r*   rE   s   ` @@r   r^   9DeprecationHandler.argument.<locals>.deprecated_decorator   s     $ 6 6)#//*!D,=,=+>azK 39eF8:.x !7 !Hg %g.. 4[
- 
- 
- Lr   r`   r   )r*   rI   rJ   rm   rd   rD   rE   r^   s   ``````` r   rm   DeprecationHandler.argument   s    ,	 	@ $#r   c               h   ^ ^^^^  " UUUU U4S jS[         5      n[        UR                  Xc40 5      $ )z9Wraps any argparse.Action to issue a deprecation warning.c                  z   >^  \ rS rSr% S\S'   S\S'   S	U UUUU4S jjr S
           SU U4S jjjrSrU =r$ )3DeprecationHandler.action.<locals>.DeprecationMixin   type[Warning]rU   strhelpc                   > [         TU ]  " U0 UD6  T	R                  TTU R                  (       a  SU R                  S    S3OSU R                   S3T[
        S9u  p4U(       d  [        U5      eX0l        X@l        g )N`)rI   rJ   rK   rD   deprecation_type)	superr,   r]   option_stringsdestFutureWarningr   rU   rw   )

inner_selfrS   rT   rU   rW   	__class__rD   rI   rJ   r*   s
        r   r,   <DeprecationHandler.action.<locals>.DeprecationMixin.__init__   s     $1&1$($:$:!-'
 &44 J55b9:!<  ! 13%%2 %; %!   )'22&.#")r   c                   > [         R                  " U R                  U R                  ST-   S9  [        TU ]  XX45        g )N   rO   )rQ   rR   rw   rU   r|   rb   )r   parser	namespacevaluesoption_stringr   rE   s        r   rb   <DeprecationHandler.action.<locals>.DeprecationMixin.__call__   s9     OO'' 5y  FJr   r   )r   r   rS   r   rT   r   r[   Noner0   )r   r   r   r	   r   r
   r   r   r   r#   r[   r   )	r   r   r   r   __annotations__r,   rb   r   __classcell__)r   rD   rI   rJ   r*   rE   s   @r   DeprecationMixinrs      sg    ##I* *< -1K K&K %K 	K
  *K K Kr   r   )r   typer   )r*   rI   rJ   actionrD   rE   r   s   ``` `` r   r   DeprecationHandler.action   s1    +	K +	Kv +	KZ FOO&6%?DDr   c               T    U R                  UUU R                  U5      S   USU-   S9  g)a.  Deprecation function for modules.

Args:
    deprecate_in: Version in which code will be marked as deprecated.
    remove_in: Version in which code is expected to be removed.
    addendum: Optional additional messaging. Useful to indicate what to do instead.
    stack: Optional stacklevel increment.

   rN   )rI   rJ   topicrD   rE   N)r   _get_module)r*   rI   rJ   rD   rE   s        r   moduleDeprecationHandler.module   s8    " 	

%""5)!,e) 	 	
r   c                  ^^^^	^
^^ U R                  T5      u  nm
U R                  UUT
 ST 3US9u  m	mT	(       d  [        T5      e[        USS5      mSU	UU
UUUU4S jjnXl        g)aV  Deprecation function for module constant/global.

Args:
    deprecate_in: Version in which code will be marked as deprecated.
    remove_in: Version in which code is expected to be removed.
    constant:
    value:
    addendum: Optional additional messaging. Useful to indicate what to do instead.
    stack: Optional stacklevel increment.

r6   rH   __getattr__Nc                   > U T:X  a  [         R                  " TTST-   S9  T$ T(       a  T" U 5      $ [        ST SU  S35      e)NrN   rO   zmodule 'z' has no attribute '')rQ   rR   r:   )namerU   constantfullnamerW   rE   super_getattrrl   s    r   r   0DeprecationHandler.constant.<locals>.__getattr__:  sM    xgxAIF$T** 8H:5I$q!QRRr   )r   rv   r[   r   )r   r]   r   getattrr   )r*   rI   rJ   r   rl   rD   rE   r   r   rU   r   rW   r   s      `` `  @@@@r   r   DeprecationHandler.constant  s    ,  ++E2 22%Zq
+	 3 
' !'**  t<	S 	S )r   c                   U R                  UUUUS9u  pgU(       d  [        U5      e[        R                  " XvSU-   S9  g)aU  Deprecation function for a topic.

Args:
    deprecate_in: Version in which code will be marked as deprecated.
    remove_in: Version in which code is expected to be removed.
    topic: The topic being deprecated.
    addendum: Optional additional messaging. Useful to indicate what to do instead.
    stack: Optional stacklevel increment.

rH   rN   rO   N)r]   r   rQ   rR   )r*   rI   rJ   r   rD   rE   rU   rW   s           r   r   DeprecationHandler.topicF  sL    ( !22%	 3 
 !'** 	gAI>r   c                    [         R                  " SU-   5      n UR                  R                  n[         R                  R                  5        HL  n[        U[        5      (       d  M  [        US5      (       d  M-  UR                  U:X  d  M?  XDR                  4s  $    SSKnUR                  U5      nUb  XfR                  4$  [        S5      e! [         a     N=f = f! [         a     N'f = f)zDetect the module from which we are being called.

Args:
    stack: The stacklevel increment.

Returns:
    The module and module name.

rN   __file__r   Nz&unable to determine the calling module)sys	_getframef_codeco_filenamemodulesr   
isinstancer   hasattrr   r   r:   inspect	getmodule
IndexErrorr   )r*   rE   framefilenameloadedr   r   s          r   r   DeprecationHandler._get_moduleh  s    	1MM!e),E9 <<33
 "kk002F%fj99 "6:66 (2 &88 3 &&u-F!00 " FGG) "   		s"   C! C 
CC!
C.-C.)r{   c          	         U R                  U5      (       a  [        nSU S3nO'U R                  U5      (       a	  UnSU S3nOSnSU S3nUSR                  [        SX7U/5      5      4$ )a  Generate the standardized deprecation message and determine whether the
deprecation is pending, active, or past.

Args:
    deprecate_in: Version in which code will be marked as deprecated.
    remove_in: Version in which code is expected to be removed.
    prefix: The message prefix, usually the function name.
    addendum: Additional messaging. Useful to indicate what to do instead.
    deprecation_type: The warning type to use for active deprecations.

Returns:
    The warning category (if applicable) and the message.

z.is pending deprecation and will be removed in r6   z%is deprecated and will be removed in Nzwas slated for removal in  )rB   PendingDeprecationWarningjoinfilter)r*   rI   rJ   rK   rD   r{   rU   warnings           r   r]   $DeprecationHandler._generate_message  s    0 ""<000HFykQRSG$$Y//'H=i[JGH29+Q?G HHVD6H"=>?
 	
r   )r$   r'   r&   )r*   r   r+   rv   r[   r   )r+   rv   r[   r%   )r*   r   r+   rv   r[   bool)r*   r   rI   rv   rJ   rv   rD   r#   rE   r1   r[   *Callable[[Callable[P, T]], Callable[P, T]])r*   r   rI   rv   rJ   rv   rm   rv   rd   r#   rD   r#   rE   r1   r[   r   )r*   r   rI   rv   rJ   rv   r   r   rD   r#   rE   r1   r[   r   )r*   r   rI   rv   rJ   rv   rD   r#   rE   r1   r[   r   )r*   r   rI   rv   rJ   rv   r   rv   rl   r   rD   r#   rE   r1   r[   r   )r*   r   rI   rv   rJ   rv   r   rv   rD   r#   rE   r1   r[   r   )r*   r   rE   r1   r[   ztuple[ModuleType, str])r*   r   rI   rv   rJ   rv   rK   rv   rD   r#   r{   ru   r[   z tuple[type[Warning] | None, str])r   r   r   r   r   r,   staticmethodr)   rB   rb   rm   r   r   r   r   r   DeprecationWarningr]   r   r   r   r   r!   r!   )   su   **##$ 
 
58  $($($($ ($
 ($ ($ 
4($` "#6$6$6$ 6$ 	6$ 6$ 6$ 6$ 
46$|  $8E8E8E 8E 	8E 8E 8E 
8E~  $


 

 
 
 

@  $0)0)0) 0) 	0)
 0) 0) 0) 
0)p  $ ? ? ?  ?
  ?  ?  ? 
 ?D'H` +=%
%
%
 %
 	%

 %
 (%
 
*%
 %
r   r!   
deprecated)"__doc__
__future__r   r   rQ   argparser   	functoolsr   typesr   typingr   anaconda_cli_baser   r	   r
   r   r   r   typing_extensionsr   r   r?   r   r   r   r   r   RuntimeErrorr   r!   r   r   r   r   r   <module>r      s    # 
       )2--1)A#AT&\:J	l 	M
 M
` "4K!@
 @r   