
    siD                    N   S r SSKJr  SSKrSSKrSSKJrJr  SSKJ	r	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  SSKJrJrJrJr  SSKJr  \" S5      r\" S5      r\" S\\   S9rSSKJ r    " S S\!5      r" " S S5      r#\	 " S S5      5       r$\#" \ 5      r%g)z!Tools to aid in deprecating code.    )annotationsN)SUPPRESSAction)	dataclassfield)wraps)
ModuleType)TYPE_CHECKING)ArgumentParser	Namespace)Callable)Any	ParamSpecSelfTypeVar)VersionTP
ActionType)bound   )__version__c                      \ rS rSrSrg)DeprecatedError    N)__name__
__module____qualname____firstlineno____static_attributes__r       2lib/python3.13/site-packages/conda/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 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.

:param 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)zlReturn version as non-empty tuple of ints if possible, else None.

:param 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>;   s     J/ItT/Is   .N)tuplestripsplitAttributeError
ValueError)r/   s    r#   r-   %DeprecationHandler._get_version_tuple4   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)zmTest whether own version is less than the given version.

:param version: Version string to compare against.
r   )parsez0.0.0.dev0+placeholder)r*   r-   packaging.versionrB   r+   r(   	TypeError)r.   r/   version_tuplerB   s       r#   _version_less_than%DeprecationHandler._version_less_than?   s    
 T5L5LW5U$UM$U&&66
 	,'G',T]]';$ ##eGn44  G',-E'F$Gs   A9 9BBNr   )addendumstackdeprecation_typec               ,   ^ ^^^^^ SUUUUU U4S jjnU$ )aJ  Deprecation decorator for functions, methods, & classes.

:param deprecate_in: Version in which code will be marked as deprecated.
:param remove_in: Version in which code is expected to be removed.
:param addendum: Optional additional messaging. Useful to indicate what to do instead.
:param stack: Optional stacklevel increment.
c                V  >^^^ T
R                  TT	U R                   SU R                   3TTS9u  mmT(       d  [        T5      eSn[	        U [
        5      (       a   U R                  mSnOU m[        T5      SUUUU4S jj5       nU(       a  X l        U $ U$ ! [         a    U m N8f = f)Nr:   deprecate_in	remove_inprefixrH   rJ   FTc                 F   > [         R                  " TTST-   S9  T" U 0 UD6$ N   
stacklevel)warningswarn)argskwargscategoryfuncmessagerI   s     r#   innerHDeprecationHandler.__call__.<locals>.deprecated_decorator.<locals>.inner   s'    gxAIFT,V,,r"   rX   zP.argsrY   zP.kwargsreturnr   )	_generate_messager   r   r   
isinstancetyper0   r>   r   )objisclassr]   rZ   r[   r\   rH   rN   rJ   rO   r.   rI   s      @@@r#   deprecated_decorator9DeprecationHandler.__call__.<locals>.deprecated_decoratore   s     $ 6 6)#..)3+;+;*<=!!1 !7 !Hg %g.. G#t$$#<<D
 #G 4[- - -
 $
' & Ds   B B('B()rd   Callable[P, T]r`   rh   r   )r.   rN   rO   rH   rI   rJ   rf   s   `````` r#   __call__DeprecationHandler.__call__T   s    "'	 '	R $#r"   )renamerH   rI   rJ   c          	     4   ^ ^^^^^^^ SUUUUUUU U4S jjnU$ )a  Deprecation decorator for keyword arguments.

:param deprecate_in: Version in which code will be marked as deprecated.
:param remove_in: Version in which code is expected to be removed.
:param argument: The argument to deprecate.
:param rename: Optional new argument name.
:param addendum: Optional additional messaging. Useful to indicate what to do instead.
:param 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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$ )	Nr:   ()zUse 'z
' instead.rM   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$ rR   )rV   rW   pop
setdefault)	rX   rY   valueargumentrZ   r[   r\   rk   rI   s	      r#   r]   HDeprecationHandler.argument.<locals>.deprecated_decorator.<locals>.inner   sV     v%MM'8E	J #JJx6E))&%8T,V,,r"   r_   )ra   r   r   r   r   )r[   r]   rZ   r\   rH   rt   rN   rJ   rO   rk   r.   rI   s   ` @@r#   rf   9DeprecationHandler.argument.<locals>.deprecated_decorator   s     $ 6 6)#//*!D,=,=+>azK 39eF8:.x!1 !7 	!Hg %g.. 4[
- 
- 
- Lr"   )r[   rh   r`   rh   r   )	r.   rN   rO   rt   rk   rH   rI   rJ   rf   s	   ```````` r#   rt   DeprecationHandler.argument   s    *	 	B $#r"   c               l   ^ ^^^^^  " UUUUU U4S jS[         5      n[        UR                  Xs40 5      $ )z9Wraps any argparse.Action to issue a deprecation warning.c                  |   >^  \ rS rSr% S\S'   S\S'   S	U 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]rZ   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TS9u  p4U(       d  [        U5      eX0l        X@l        U R                  [        La  X@l        g g )N`rM   )
superr0   ra   option_stringsdestr   rZ   deprecationr~   r   )
inner_selfrX   rY   rZ   r\   	__class__rH   rN   rJ   rO   r.   s        r#   r0   <DeprecationHandler.action.<locals>.DeprecationMixin.__init__   s     $1&1$($:$:!-'
 &44 J55b9:!<  ! 13%%5 %; %!   )'22&.#)0&??(2&-O 3r"   c                   > SSK Jn  X5La-  [        R                  " U R                  U R
                  ST-   S9  [        TU ]  XX45        g )Nr   )NULL   rT   )conda.common.constantsr   rV   rW   r   rZ   r   ri   )r   parser	namespacevaluesoption_stringr   r   rI   s         r#   ri   <DeprecationHandler.action.<locals>.DeprecationMixin.__call__   sD     8%MM".."++#$u9  FJr"   r   )r   r   rX   r   rY   r   r`   Noner4   )r   r   r   r   r   r   r   r   r   r'   r`   r   )	r   r   r   r    __annotations__r0   ri   r!   __classcell__)r   rH   rN   rJ   rO   r.   rI   s   @r#   DeprecationMixinrz      sh    ##I. .@ -1K K&K %K 	K
  *K K Kr"   r   )r   rc   r   )r.   rN   rO   actionrH   rI   rJ   r   s   ``` ``` r#   r   DeprecationHandler.action   s1    0	K 0	Kv 0	Kd FOO&6%?DDr"   )rH   rI   c               T    U R                  UUU R                  U5      S   USU-   S9  g)a3  Deprecation function for modules.

:param deprecate_in: Version in which code will be marked as deprecated.
:param remove_in: Version in which code is expected to be removed.
:param addendum: Optional additional messaging. Useful to indicate what to do instead.
:param stack: Optional stacklevel increment.
r   rS   )rN   rO   topicrH   rI   N)r   _get_module)r.   rN   rO   rH   rI   s        r#   moduleDeprecationHandler.module  s8     	

%""5)!,e) 	 	
r"   c                  U R                  U5      u  pU R                  UUU	 SU 3UUS9u  pU
(       d  [        U5      e[        [	        USS5      =n[
        5      (       a  UnO[        X5      nXl        UR                  X;XU5        g)aa  Deprecation function for module constant/global.

:param deprecate_in: Version in which code will be marked as deprecated.
:param remove_in: Version in which code is expected to be removed.
:param constant:
:param value:
:param addendum: Optional additional messaging. Useful to indicate what to do instead.
:param stack: Optional stacklevel increment.
r:   rM   __getattr__N)r   ra   r   rb   getattr_ConstantDeprecationRegistryr   register)r.   rN   rO   constantrs   rH   rI   rJ   r   fullnamerZ   r\   fallbackdeprecationss                 r#   r   DeprecationHandler.constant  s    *  ++E2 22%Zq
+- 3 
 !'** t<<H(
 
 $L7KL!-h%Hr"   c                   U R                  UUUUUS9u  pxU(       d  [        U5      e[        R                  " XSU-   S9  g)a]  Deprecation function for a topic.

:param deprecate_in: Version in which code will be marked as deprecated.
:param remove_in: Version in which code is expected to be removed.
:param topic: The topic being deprecated.
:param addendum: Optional additional messaging. Useful to indicate what to do instead.
:param stack: Optional stacklevel increment.
rM   rS   rT   N)ra   r   rV   rW   )	r.   rN   rO   r   rH   rI   rJ   rZ   r\   s	            r#   r   DeprecationHandler.topicN  sO    & !22%- 3 
 !'** 	gAI>r"   c                    [         R                  " SU-   5      n UR                  R                  n[	        [         R
                  R                  5       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.

:param stack: The stacklevel increment.
:return: The module and module name.
rS   __file__r   Nz&unable to determine the calling module)sys	_getframef_codeco_filenamer;   modulesr   rb   r	   hasattrr   r   r>   inspect	getmodule
IndexErrorr   )r.   rI   framefilenameloadedr   r   s          r#   r   DeprecationHandler._get_modulep  s    	1MM!e),E9 <<33 $CKK$6$6$89F%fj99 "6:66 (2 &88 : &&u-F!00 " FGG+ "   		s"   C* C 
C'&C'*
C76C7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.

:param deprecate_in: Version in which code will be marked as deprecated.
:param remove_in: Version in which code is expected to be removed.
:param prefix: The message prefix, usually the function name.
:param addendum: Additional messaging. Useful to indicate what to do instead.
:param deprecation_type: The warning type to use for active deprecations.
:return: The warning category (if applicable) and the message.
z.is pending deprecation and will be removed in r:   z%is deprecated and will be removed in Nzwas slated for removal in  )rF   PendingDeprecationWarningjoinfilter)r.   rN   rO   rP   rH   rJ   rZ   warnings           r#   ra   $DeprecationHandler._generate_message  s    ( ""<000HFykQRSG$$Y//'H=i[JGH29+Q?G HHVD6H"=>?
 	
r"   )r(   r+   r*   )r.   r   r/   r}   r`   r   )r/   r}   r`   r)   )r.   r   r/   r}   r`   bool)r.   r   rN   r}   rO   r}   rH   r'   rI   r5   rJ   r|   r`   *Callable[[Callable[P, T]], Callable[P, T]])r.   r   rN   r}   rO   r}   rt   r}   rk   r'   rH   r'   rI   r5   rJ   r|   r`   r   )r.   r   rN   r}   rO   r}   r   r   rH   r'   rI   r5   rJ   r|   r`   r   )r.   r   rN   r}   rO   r}   rH   r'   rI   r5   r`   r   )r.   r   rN   r}   rO   r}   r   r}   rs   r   rH   r'   rI   r5   rJ   r|   r`   r   )r.   r   rN   r}   rO   r}   r   r}   rH   r'   rI   r5   rJ   r|   r`   r   )r.   r   rI   r5   r`   ztuple[ModuleType, str])r.   r   rN   r}   rO   r}   rP   r}   rH   r'   rJ   r|   r`   z tuple[type[Warning] | None, str])r   r   r   r    r   r0   staticmethodr-   rF   DeprecationWarningri   rt   FutureWarningr   r   r   r   r   ra   r!   r   r"   r#   r%   r%   $   s   **##	$  54  $*<:$:$:$ :$
 :$ :$ (:$ 
4:$D "#*<6$6$6$ 6$ 	6$ 6$ 6$ 6$ (6$ 
46$|  $*7>E>E>E >E 	>E >E >E (>E 
>EJ  $


 

 
 
 

<  $*<-I-I-I -I 	-I
 -I -I -I (-I 
-Ij  $*< ? ? ?  ?
  ?  ?  ? ( ? 
 ?D$HL!
!
!
 !
 	!

 !
 (!
 
*!
r"   r%   c                  t    \ rS rSr% Sr\" \SSS9rS\S'   S\S'   S	\S
'   SS jr	            SS jr
Srg)r   i  zRegistry of deprecated module constants.

Serves as a module's __getattr__, issuing deprecation warnings
when registered constants are accessed.
F)default_factoryinitreprz.dict[str, tuple[str, type[Warning], int, Any]]r   r}   r   zCallable[[str], Any] | Noner   c                    XR                   ;   a)  U R                   U   u  p#pE[        R                  " X#US9  U$ U R                  (       a  U R                  U5      $ [	        SU R
                   SU S35      e)NrT   zmodule 'z' has no attribute '')r   rV   rW   r   r>   r   )r.   namer\   rZ   rU   rs   s         r#   ri   %_ConstantDeprecationRegistry.__call__  sl    $$$373D3DT3J0GzMM'
CL====&&x6J4&PQRSSr"   c                .    X#SU-   U4U R                   U'   g )NrS   )r   )r.   r   r\   rZ   rI   rs   s         r#   r   %_ConstantDeprecationRegistry.register  s     (/!e)U&K(#r"   r   N)r   r}   r`   r   )r   r}   r\   r}   rZ   r|   rI   r5   rs   r   r`   r   )r   r   r   r    __doc__r   dictr   r   ri   r   r!   r   r"   r#   r   r     s     DIDL@ 
 M))	T	L	L 	L  		L
 	L 	L 
	Lr"   r   )&r   
__future__r   r   rV   argparser   r   dataclassesr   r   	functoolsr   typesr	   typingr
   r   r   collections.abcr   r   r   r   r   rC   r   r   r   rc   r    r   RuntimeErrorr   r%   r   
deprecatedr   r"   r#   <module>r      s    ( " 
  % (    2(44)A#AT&\:J 	l 	S
 S
l #L #L #LL  ,
r"   