
    4jN!                         S r SSKJrJrJrJr  SSKJr  SSKJ	r	J
r
JrJr  \" 5       rS rS rS rS	 rS
 r " S S\	5      r " S S5      r " S S\\5      r " S S\
5      r " S S\\5      rSSSSS.S jjrg)a  The `with_signature` decorator: override the signature (and related
introspection attributes) of a wrapped callable without mutating the wrapped
function itself. Accepts a prototype callable, a prebuilt `inspect.Signature`,
or a factory that derives a signature from the wrapped function at decoration
time.

This replaces the need for the `adapter=` argument of `wrapt.decorator`,
which is planned for deprecation.
    )
CO_VARARGSCO_VARKEYWORDS	Parameter	Signature)	signature   )BaseObjectProxyBoundFunctionWrapperCallableObjectProxyFunctionWrapperc                 R   ^ ^ ST R                  S5       3mU U4S jn[        U5      $ )a1  Read-only property that memoizes its derivation in a `_self_*` slot.

`functools.cached_property` is unusable on ObjectProxy subclasses: wrapt
overrides `__dict__` with a property returning the wrapped object's dict,
so cached_property's `instance.__dict__[name] = value` would mutate the
wrapped function. Storing under a `_self_*` name routes through wrapt's
own setattr handling and lands in the proxy's real instance dict. Using
a `@property` (data descriptor) also ensures we win over any value
copied into the instance dict by `FunctionWrapper.__init__`.
_self_cached__c                    > [        U T[        5      nU[        L a#  U R                  T5      nU R                  TU5        U$ N)getattr_MISSING_derive__self_setattr__)selfvalueattrslots     N/root/lseg-credit/backend/venv/lib/python3.13/site-packages/wrapt/signature.pygetter_cached.<locals>.getter%   s<    dH-HLL&E!!$.    )lstripproperty)r   r   r   s   ` @r   _cachedr       s-     4;;s+,-D Fr   c                 $   U R                   R                  5        Vs0 s H9  nUR                  [        R                  Ld  M"  UR
                  UR                  _M;     nnU R                  [        R                  La  U R                  US'   U$ s  snf )Nreturn)
parametersvalues
annotationr   emptynamereturn_annotationr   )sigpanns      r   _derive_annotationsr,   /   s}     &&((A<<y. 	(  
 IOO3--HJs   !BBc                 l    [        S U R                  R                  5        5       5      nU=(       d    S $ )Nc              3      #    U  H`  nUR                   [        R                  [        R                  4;   d  M3  UR                  [        R
                  Ld  MR  UR                  v   Mb     g 7fr   )kindr   POSITIONAL_ONLYPOSITIONAL_OR_KEYWORDdefaultr&   .0r*   s     r   	<genexpr>#_derive_defaults.<locals>.<genexpr>;   sQ      (A66i//1P1PQQ 	 IIY__, 			(s   2A*A*A*)tupler#   r$   )r)   defaultss     r   _derive_defaultsr9   :   s3     &&( H tr   c                    U R                   R                  5        Vs0 s HX  nUR                  [        R                  L d  M"  UR
                  [        R                  Ld  MA  UR                  UR
                  _MZ     nnU=(       d    S $ s  snf r   )r#   r$   r/   r   KEYWORD_ONLYr2   r&   r'   )r)   r*   
kwdefaultss      r   _derive_kwdefaultsr=   D   sy     &&((A66Y+++ 	01		0P 			(  
 s   !B	B	!B	c                    / / / p2nS =pEU R                   R                  5        GH  nUR                  [        R                  L a  UR                  UR                  5        M>  UR                  [        R                  L a  UR                  UR                  5        Mx  UR                  [        R                  L a  UR                  nM  UR                  [        R                  L a  UR                  UR                  5        M  UR                  [        R                  L d  M  UR                  nGM     X-   U-   nU(       a  UR                  U5        U(       a  UR                  U5        [        U5      $ r   )r#   r$   r/   r   r0   appendr'   r1   VAR_POSITIONALr;   VAR_KEYWORDr7   )r)   pos_only	pos_or_kwkw_onlyvar_posvar_kwr*   namess           r   _derive_varnamesrH   M   s   #%r2HG^^""$66Y...OOAFF#VVy666QVV$VVy///ffGVVy---NN166"VVy,,,VVF %  7*EWV<r   c                      ^  \ rS rSrSrU 4S jrS r\" S5      r\" S5      r	\" S5      r
\" S5      r\" S	5      rS
rU =r$ )_SignatureCodec   zCode-object proxy deriving argument-related co_* attrs from a Signature.

Non-argument bits (co_flags for coroutine/generator, co_filename, etc.)
fall through to the wrapped function's real __code__.
c                 0   > [         TU ]  U5        X l        g r   super__init___self_signaturer   wrappedr   	__class__s      r   rO   _SignatureCode.__init__j       !(r   c                   ^ U R                   nUS:X  aM  [        R                  [        R                  4m[	        U4S jUR
                  R                  5        5       5      $ US:X  a*  [	        S UR
                  R                  5        5       5      $ US:X  a*  [	        S UR
                  R                  5        5       5      $ US:X  a  [        U5      $ US:X  a  UR
                  R                  5        Vs1 s H  o3R                  iM     snmU R                  R                  [        [        -  ) -  n[        R                  T;   a	  U[        -  n[        R                  T;   a	  U[        -  nU$ [        U5      es  snf )	Nco_argcountc              3   @   >#    U  H  oR                   T;   v   M     g 7fr   )r/   )r4   r*   kindss     r   r5   )_SignatureCode._derive.<locals>.<genexpr>r   s     H0G1vv0Gs   co_posonlyargcountc              3   X   #    U  H   oR                   [        R                  L v   M"     g 7fr   )r/   r   r0   r3   s     r   r5   rZ   t   s!      =T)333=T   (*co_kwonlyargcountc              3   X   #    U  H   oR                   [        R                  L v   M"     g 7fr   )r/   r   r;   r3   s     r   r5   rZ   x   s!      :QQ)000:Qr]   co_varnamesco_flags)rP   r   r0   r1   sumr#   r$   rH   r/   __wrapped__ra   r   r   r@   rA   AttributeError)r   r   r)   r*   flagsrY   s        @r   r   _SignatureCode._deriven   sQ   ""= ..	0O0OPEH0E0E0GHHH'' =@^^=R=R=T   && :=..:O:O:Q   = #C((:%(^^%:%:%<=%<VV%<=E$$--*~2M0NNE''50#$$-'LT"" >s   4E8rW   r[   r^   r`   ra   rP   )__name__
__module____qualname____firstlineno____doc__rO   r   r    rW   r[   r^   r`   ra   __static_attributes____classcell__rS   s   @r   rJ   rJ   c   sJ    )#2 -(K !56 34-(Kz"Hr   rJ   c                   n    \ rS rSrSrS r\S 5       r\" S5      r	\" S5      r
\" S5      r\" S5      rS	rg
)_SignatureMixin   zEShared Signature-derived introspection attrs for wrapper + surrogate.c                     U R                   nUS:X  a  [        U5      $ US:X  a  [        U5      $ US:X  a  [        U5      $ US:X  a   [	        U R
                  R                  U5      $ [        U5      e)N__annotations____defaults____kwdefaults____code__)rP   r,   r9   r=   rJ   rc   rw   rd   )r   r   r)   s      r   r   _SignatureMixin._derive   st    ""$$&s++>!#C((##%c**:!$"2"2";";SAAT""r   c                     U R                   $ r   rg   r   s    r   __signature___SignatureMixin.__signature__   s    ###r   rt   ru   rv   rw    N)rh   ri   rj   rk   rl   r   r   r{   r    rt   ru   rv   rw   rm   r}   r   r   rq   rq      sJ    O
# $ $ /0O>*L-.Nz"Hr   rq   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_SignatureFunctionSurrogate   zFunction surrogate exposing Signature-derived introspection attrs.

Used as __func__ of a bound wrapper so that inspect.signature -- which
treats the bound wrapper as a MethodType and consults __func__ -- sees
our override and strips self/cls correctly.
c                 0   > [         TU ]  U5        X l        g r   rM   rQ   s      r   rO   $_SignatureFunctionSurrogate.__init__   rU   r   rg   )rh   ri   rj   rk   rl   rO   rm   rn   ro   s   @r   r   r      s    ) )r   r   c                   4    \ rS rSr\S 5       r\S 5       rSrg)_BoundSignatureFunctionWrapper   c                 j    [        U R                  R                  U R                  R                  5      $ r   )r   rc   __func___self_parentrP   rz   s    r   r   '_BoundSignatureFunctionWrapper.__func__   s,    *%%t'8'8'H'H
 	
r   c                 .    U R                   R                  $ r   )r   rP   rz   s    r   r{   ,_BoundSignatureFunctionWrapper.__signature__   s      000r   r}   N)rh   ri   rj   rk   r   r   r{   rm   r}   r   r   r   r      s(    
 

 1 1r   r   c                   <   ^  \ rS rSr\rU 4S jr\S 5       rSr	U =r
$ )_SignatureFunctionWrapper   c                 0   > [         TU ]  X5        X0l        g r   rM   )r   rR   wrapperr   rS   s       r   rO   "_SignatureFunctionWrapper.__init__   s    *(r   c                 B    [        U R                  U R                  5      $ r   )r   rc   rP   rz   s    r   r   "_SignatureFunctionWrapper.__func__   s    *4+;+;T=Q=QRRr   rg   )rh   ri   rj   rk   r   __bound_function_wrapper__rO   r   r   rm   rn   ro   s   @r   r   r      s$    !?) S Sr   r   N)	prototyper   factoryc                  ^^^ [        S TTT4 5       5      nUS:X  a  [        S5      eUS:  a  [        S5      eUUU4S jnU c  U$ U" U 5      $ )ax  Override the signature of a wrapped callable.

Exactly one of `prototype`, `signature`, or `factory` must be supplied:

- `prototype`: a callable whose signature will be used.
- `signature`: a prebuilt `inspect.Signature` object.
- `factory`: a callable `factory(wrapped)` invoked at decoration time
  that returns either a `Signature` or a prototype callable.

The resulting wrapper exposes the override via `__signature__`, and
derives `__annotations__`, `__defaults__`, `__kwdefaults__`, and the
argument-related attributes of `__code__` from the same source. The
wrapped function is not mutated. Calling behaviour is unchanged.
c              3   (   #    U  H  oS Lv   M
     g 7fr   r}   )r4   xs     r   r5   !with_signature.<locals>.<genexpr>   s     K+JaTM+Js   r   zBwith_signature requires one of prototype=, signature=, or factory=r   zFwith_signature accepts only one of prototype=, signature=, or factory=c                    > S nTb  TnO9Tb  [        T5      nO*T" U 5      n[        U[        5      (       a  UO
[        U5      n[        XU5      $ )Nc                     U " U0 UD6$ r   r}   )rR   instanceargskwargss       r   _wrapper4with_signature.<locals>._decorator.<locals>._wrapper   s    D+F++r   )_inspect_signature
isinstancer   r   )rR   r   resolvedproducedr   r   r   s       r   
_decorator"with_signature.<locals>._decorator   s_    	,   H"))4Hw'H h	22 '1  )HEEr   )rb   	TypeError)rR   r   r   r   	specifiedr   s    ```  r   with_signaturer      sj      KIy'+JKKIA~P
 	
 1}T
 	
F$ gr   r   )rl   inspectr   r   r   r   r   r   	__wrapt__r	   r
   r   r   objectr   r    r,   r9   r=   rH   rJ   rq   r   r   r   r   r}   r   r   <module>r      s    E D 3  8.,(#_ (#V# #2
)/3F 
)	1%9 	1	S 	S.t .r   