
    h}0                    N   d Z ddlmZ ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  ede      Z edd      Z	 d'	 	 	 	 	 	 	 	 	 	 	 d(dZ	 d)	 	 	 	 	 	 	 	 	 d*dZ	 	 d)	 	 	 	 	 	 	 	 	 	 	 d+dZ	 d,	 	 	 	 	 	 	 d-dZ	 	 	 	 d.	 	 	 	 	 	 	 	 	 	 	 d/d Z	 	 	 	 	 	 d0d!Z 	 d'	 	 	 	 	 	 	 d1d"Z!d2d#Z"d3d$Z#	 d'	 	 	 	 	 	 	 	 	 	 	 	 	 d4d%Z$	 	 d5	 	 	 	 	 	 	 	 	 	 	 	 	 d6d&Z%y)7zSHelpers related to deprecation of functions, methods, classes, other
functionality.    )annotationsN)Any)Callable)Dict)Match)Optional)Sequence)Set)Tuple)Type)TypeVar)Union   )compat)_hash_limit_string)_warnings_warn)	decorator)inject_docstring_text)inject_param_text   )exc_T)bound_FzCallable[..., Any]c                F     || |      }||_         t        ||dz          y )Ncoder   
stacklevel)deprecated_sincer   )msgversiontype_r   r   warns         ED:\EasyAligner\venv\Lib\site-packages\sqlalchemy/util/deprecations.py_warn_with_versionr&   *   s&     4 D#D4JN3    c                @    t        | |t        j                  ||       y )Nr   )r&   r   SADeprecationWarning)r!   r"   r   r   s       r%   warn_deprecatedr*   7   s     Wc..
r'   c                ^    |rt        | d|      } t        | |t        j                  ||       y)zhIssue a deprecation warning with a parameterized string,
    limiting the number of registrations.

    
   r   N)r   r&   r   r)   )r!   argsr"   r   r   s        r%   warn_deprecated_limitedr.   ?   s.      b$/Wc..
r'   c                8     d dxs dd fd}|S )N.. deprecated::   c           	     Z    t        | t        j                  t              z        S )Nfunc)_decorate_cls_with_warningr   r)   dict)clsconstructorheadermessager"   s    r%   decoratez deprecated_cls.<locals>.decorateV   s2    )$$d,,
 	
r'   )r8   Type[_T]returnr=    )r"   r;   r9   r<   r:   s   ``` @r%   deprecated_clsr@   Q   s&     )0'-R-AF
 
 Or'   c                     |rd dxs dnddt         j                  d z  z  d fd}|S )	a  Decorates a function and issues a deprecation warning on use.

    :param version:
      Issue version in the warning.

    :param message:
      If provided, issue message in the warning.  A sensible default
      is used if not provided.

    :param add_deprecation_to_docstring:
      Default True.  If False, the wrapped function's __doc__ is left
      as-is.  If True, the 'message' is prepended to the docs if
      provided, or sensible default if message is omitted.

    r0   r1   r2   Nz$Call to deprecated function %(func)sz (deprecated since: %s)c                d    J J t        | t        | j                        z        S )Nr4   )enable_warnings)_decorate_with_warningr7   __name__)fnrC   r:   r;   r"   warnings    r%   r<   zdeprecated.<locals>.decorate   sH    """"""%d,,+
 	
r'   rF   r   r>   r   )r   r)   )r"   r;   add_deprecation_to_docstringrG   rC   r<   r:   s   `` `` @r%   
deprecatedrJ   c   s]    . $]]

 8**(722G

 

 Or'   c                <    t        	 d| t        j                  d|S )Nr;   rG   2.0)rJ   r   MovedIn20Warning)r;   kws     r%   moved_20rQ      s,     (<(<@B r'   c                :   t        j                  d|       }|rdddd|j                  d         }nd}d| d	|d
dd}d| v r1|j                  dd      }|s|j	                  d      du s
J d| z         |r|d	|z   z  }t
        j                  }t        d||d|S )Nz^:(attr|func|meth):	attributefunctionmethod)attrr5   methr   	constructzThe r1   z= is considered legacy as of the 1.x series of SQLAlchemy and zbecomes a legacy constructz in 2.0.z:attr:warn_on_attribute_accessFrC   zattribute %s will emit a warning on read access.  If you *really* want this, add warn_on_attribute_access=True.  Otherwise please add enable_warnings=False.rL   rM   )rematchgrouppopgetr   LegacyAPIWarningrJ   )api_namealternativerP   type_regr#   r;   attribute_okwarning_clss           r%   became_legacy_20re      s     xx-x8H$j(KNN1
 
 (	
  8vv8%@66+,5 ) ,445 3$$&&KHWkHRHHr'   c                      i i i  j                         D ].  \  }\  }}||<   t        |      |<   t        j                  |<   0 d fd}|S )aK  Decorates a function to warn on use of certain parameters.

    e.g. ::

        @deprecated_params(
            weak_identity_map=(
                "0.7",
                "the :paramref:`.Session.weak_identity_map parameter "
                "is deprecated.",
            )
        )
        def some_function(**kwargs): ...

    c                T  	
 t        j                  |       }|j                  t        t	        |j
                  t        |j
                        t        |j                        z
  d  |j                              t              j                        	t              j                        
nZ|j                  A|j                  t              j                        	t              j                        
nd	t              
|j                  t        d	
fd       }| j                  d uxr | j                  xs d}|rDt        |j                         D ci c]  \  }\  }}|d|dk(  rdn|d|xs d c}}}      } ||       }||_        |S c c}}}w )	Nr?   c                F   D ]6  }|   ||   |   ||   |   k7  st        |   
|   	|   d       8 v r6t        |      j                        rJ t           
   	   d       D ]  }||v st        |   
|   	|   d       !  | |i |S N   r   )r&   set
difference)rF   r-   kwargsmcheck_any_kwcheck_defaultscheck_kwdefaultsmessagesversion_warningsversionss       r%   warnedz3deprecated_params.<locals>.decorate.<locals>.warned   s    #QK'F1I,AQK+q	Xa[0H&  (+#$		 $ x'CK,B,B- $///"\*\*$\2 	 ;&  (+#$	  t&v&&r'   r2   r0   rN   z1.4r1   rF   r   r-   r   rm   r   r>   r   )r   inspect_getfullargspecrr   r7   zipr-   lenrk   intersectionrl   kwonlydefaultsvarkwr   __doc__r   items)rF   specrv   docparamr"   r;   	decoratedro   rp   rq   rr   rs   specsrt   ru   s           @@@@r%   r<   z#deprecated_params.<locals>.decorate   s   ,,R0 ==$IIs499~DMM0BBEFMMH !]77AN8}//9H  ,**H ]77AN8}//9HN8}Hzz 
	' 	' 
	'B jj$39r# 6;[[] 6C11  '5 0ug=2P P5BC 2J		s   (!F#rH   )r   _sanitize_restructured_textr   r)   )r   r   r"   r;   r<   rs   rt   ru   s   `    @@@r%   deprecated_paramsr      sk       "H!HBD%*[[]!!!5g>"%":": &3
G GR Or'   c                h    dd}t        j                  dd |       } t        j                  d||       S )Nc                B    | j                  dd      \  }}|dv r|dz  }|S )Nr   r   )r5   rW   z()r\   )rn   r#   names      r%   replz)_sanitize_restructured_text.<locals>.repl-  s,    ggamt$$DLDr'   z:ref:`(.+) <.*>`c                *    d| j                  d      z  S )Nz"%s"r   r   )rn   s    r%   <lambda>z-_sanitize_restructured_text.<locals>.<lambda>3  s    !''!*1Dr'   z\:(\w+)\:`~?(?:_\w+)?\.?(.+?)`)rn   z
Match[str]r>   str)rZ   sub)textr   s     r%   r   r   ,  s1     66%'DdKD663T4@@r'   c                *   | j                   d uxr | j                   xs d}|||t        |      z  }t        |t        j                        r|dz  }t        ||d      }d }t        |       t        u rgt        | j                        }||d<   |j                  dd        |j                  dd        t        | j                  | j                  |      } |||   }n|| _         |t        | |      }|"|J |J t        | |t        ||||d              | S )Nr2   r4   @ (Background on SQLAlchemy 2.0 at: :ref:`migration_20_toplevel`)r   r~   __dict____weakref__)r~   r7   
issubclassr   Base20DeprecationWarningr   typer   r]   rE   	__bases__getattrsetattrrD   )	r8   r9   wtyper;   r"   docstring_headerr   constructor_fnclsdicts	            r%   r6   r6   7  s9    ++T
!
1ckk
7RC#"+ 66eS99:0 $C)91=93<<(G!$GIKK
D)KKt,s||S]]G<C&!(!5 CK&!(k!:"!---$$$&"E7GT Jr'   c                V   t              t        t        j                        rd}nd}t        dfd       }| j
                  duxr | j
                  xs d}|+|t        | j                        z  }||z  }t        ||d      } ||       }	||	_        fd|	_	        |	S )	z=Wrap a function with a warnings.warn and augmented docstring.r   r2   c                d     xs |j                  dd      }|st        d        | |i |S )N_sa_skip_warningFrj   r   )r]   r&   )rF   r-   rm   skip_warningrC   r;   r"   r   s       r%   rv   z&_decorate_with_warning.<locals>.warned{  sC    ** 
fjj/
 w1E4"6""r'   Nr4   r   c                 "    t         d      S ri   )r&   )r;   r"   r   s   r%   r   z(_decorate_with_warning.<locals>.<lambda>  s    !3%A"r'   rw   )
r   r   r   r   r   r~   r7   rE   r   _sa_warn)
r5   r   r;   r"   r   rC   doc_onlyrv   r   r   s
    ``` `    r%   rD   rD   g  s     *'2G%556, 	
 # # ,,d
"
3t||
9rC#Ddmm44H$#C)91=tIII r'   )N)r!   r   r"   r   r#   Type[exc.SADeprecationWarning]r   intr   Optional[str]r>   None)rj   N)
r!   r   r"   r   r   r   r   r   r>   r   )r!   r   r-   zSequence[Any]r"   r   r   r   r   r   r>   r   )__init__)r"   r   r;   r   r9   r   r>   zCallable[[Type[_T]], Type[_T]])NTNT)r"   r   r;   r   rI   boolrG   z(Optional[Type[exc.SADeprecationWarning]]rC   r   r>   Callable[[_F], _F])r;   r   rP   r   r>   z0Callable[[Callable[..., _T]], Callable[..., _T]])r`   r   ra   r   rP   r   r>   r   )r   zTuple[str, str]r>   r   )r   r   r>   r   )r8   r=   r9   r   r   r   r;   r   r"   r   r   r   r>   r=   )NT)r5   r   r   r   r;   r   r"   r   r   r   rC   r   r>   r   )&r~   
__future__r   rZ   typingr   r   r   r   r   r	   r
   r   r   r   r   r2   r   langhelpersr   r   r   r   r   r   r   r   r&   r*   r.   r@   rJ   rQ   re   r   r   r6   rD   r?   r'   r%   <module>r      s   # 	             + ' " . * T T-. 
4	
4
4 *
4 	
4
 
4 

4 HL	(+7D	 	
  	
  
& >H-:#( ")-8< 333 #'3 6	3
 3 3l5 15#I#I -#I<?#I#ILbJA" '+-	-- *- 	-
 - $- -j '+ *
*)* * 	*
 $* * *r'   