
    diX)                     f   S SK r S SKrS SKrS SKJr   S SKJr   S SKJrJ	r	  S r \R                  " SSS9  S	 r\R                  S:  a  S rO \R                  S:  a  S rO\R                  r\R                  S:  a  S SKJr  OS rS rS rS r0 \\_\\_\\_\\_\\_\R4                  \_\R6                  \_\R8                  \_\R:                  \_\R<                  \_\R>                  \_\R@                  \_\RB                  \_\RD                  \_\RF                  \_\RH                  \_\RJ                  \_\ RL                  R>                  \\ RL                  R@                  \\ RL                  RB                  \\ RL                  RH                  \\ RL                  R8                  \\ RL                  RD                  \\ RL                  RF                  \0Er'S r(S r)S r*S r+g! \ a
    S SKJr   GNf = f! \ a     S SKJrJ	r	   GN! \ a	    S=r	r  GNf = ff = f! \ a    S
 r GNf = f)    N)_AnnotatedAlias)get_type_hints)NotRequiredRequiredc                     [        U SS9$ )NT)include_extras)_get_type_hints)objs    X/var/www/fortnox.synktek.com/backend/venv/lib/python3.13/site-packages/msgspec/_utils.pyr   r      s    3t44    FooT)is_classc                 .    [         R                  " U SSS9$ )NFT)is_argumentr   typing
ForwardRefvalues    r   _forward_refr   &   s      EDIIr   c                 ,    [         R                  " U SS9$ )NF)r   r   r   s    r   r   r   !   s      E::r   )      c                 2    [         R                  " XUS5      $ )N )r   
_eval_type)tglobalnslocalnss      r   r   r   -   s      gr::r   )r   
   c                      [         R                  " XU5      $ ! [         aD  n SSKJn  O)! [         a    [        SU R
                  < S35      Uef = fU" U UUSS9s S nA$ S nAff = f)Nr   )eval_type_backportz#Unable to evaluate type annotation a  . If you are making use of the new typing syntax (unions using `|` since Python 3.10 or builtins subscripting since Python 3.9), you should either replace the use of new syntax with the existing `typing` constructs or install the `eval_type_backport` package.F)try_default)r   r   	TypeErrorr"   ImportError__forward_arg__)r   r   r   er"   s        r   r   r   1   s    	$$Q':: 	A 9!:K:K9N OW W
  &!	 	s)    
A'+A"&AA"A'"A')r      )get_annotationsc                 :    U R                   R                  S0 5      $ )N__annotations__)__dict__get)clss    r   _get_class_annotationsr/   M   s    || 1266r   c                    ^ [        U [        R                  5      (       a  TR                  X 5      $  [	        U R
                  5      nU(       d  U $ [	        U4S jU 5       5      nX   $ ! [         a    U s $ f = f)Nc              3   F   >#    U  H  nTR                  X5      v   M     g 7fN)r-   ).0pmappings     r   	<genexpr> _apply_params.<locals>.<genexpr>`   s     7JqQ""Js   !)
isinstancer   TypeVarr-   tuple__parameters__	Exception)r
   r5   
parametersargss    `  r   _apply_paramsr?   Q   sr    #v~~&&{{3$$3--.

 
 7J77D9  
s   A* *A98A9c                    ^^ 0 m[        U [        5      (       a  U nOU R                  nUU4S jmT" U 0 5        UR                  T4$ )Nc                   >^ [        U [        5      (       a  U n0 nO[        U SS 5      nUS [        [        R
                  4;   d  UT	;   a  g UR                  n[        U4S jU R                   5       5      n[        U5      [        U5      :X  d   e[        [        XE5      5      =T	U'   n[        U[        R
                  5      (       a)  [        USUR                  5      nU H  nT" Xs5        M     g g )N
__origin__c              3   <   >#    U  H  n[        UT5      v   M     g 7fr2   )r?   )r3   ascopes     r   r6   E_get_class_mro_and_typevar_mappings.<locals>.inner.<locals>.<genexpr>u   s     E*Qq%00*s   __orig_bases__)r8   typegetattrobjectr   Genericr;   r:   __args__lendictzip
issubclass	__bases__)
crE   r.   	new_scopeparamsr>   basesbinnerr5   s
    `      r   rW   2_get_class_mro_and_typevar_mappings.<locals>.innerl   s    aCI!\40CtVV^^44w''FE!**EEDv;#d)+++'+C,='>>GCL9c6>>**C!13==AEa#  +r   )r8   rH   rB   __mro__)r
   r.   rW   r5   s     @@r   #_get_class_mro_and_typevar_mappingsrZ   d   sB    G#tnn$$ 
#rN;;r   c                    0 n[        U 5      u  p#U H  nU[        R                  [        4;   a  M  UR	                  U5      n[        [        U5      5      n[        [        R                  R	                  UR                  S5      S0 5      n[        U5      nUR                  5        HX  u  pX;   a  M  [        U
[        5      (       a  [        U
5      n
[!        XU5      n
Ub  [#        X5      n
U
c  [%        S5      n
XU	'   MZ     M     U$ )a  Get the annotations for a class.

This is similar to ``typing.get_type_hints``, except:

- We maintain it
- It leaves extras like ``Annotated``/``ClassVar`` alone
- It resolves any parametrized generics in the class mro. The returned
  mapping may still include ``TypeVar`` values, but those should be treated
  as their unparametrized variants (i.e. equal to ``Any`` for the common case).

Note that this function doesn't check that Generic types are being used
properly - invalid uses of `Generic` may slip through without complaint.

The assumption here is that the user is making use of a static analysis
tool like ``mypy``/``pyright`` already, which would catch misuse of these
APIs.
Nr,   )rZ   r   rK   rJ   r-   rN   varsrI   sysmodules
__module__r/   itemsr8   strr   r   r?   rH   )r
   hintsmrotypevar_mappingsr.   r5   
cls_localscls_globalsannnamer   s              r   get_class_annotationsri      s    $ E?DC6>>6**"&&s+$s)_
ckkoocnndCZQST$S)99;KD}%%%$U+u+>E"%e5}T
$K ' ( Lr   c                   ^ [        U [        5      (       a  U nOU R                  n[        U 5      n[	        US5      (       a  [        UR                  5      nO'UR                  (       a  [        U5      nO
[        5       n0 mUR                  5        Hs  u  pE[        USS5      nU[        L a%  UR                  U5        UR                  S   TU'   M@  U[        L a%  UR                  U5        UR                  S   TU'   Mn  UTU'   Mu     [        U4S jU 5       5      (       d  [!        SU STR#                  5        35      eTU4$ )N__required_keys__rB   Fr   c              3   ,   >#    U  H	  oT;   v   M     g 7fr2   r   )r3   krb   s     r   r6   %get_typeddict_info.<locals>.<genexpr>   s     ,8aEz8s   zRequired set z% contains keys that are no in hints: )r8   rH   rB   ri   hasattrsetrk   	__total__r`   rI   r   addrL   r   discardallRuntimeErrorkeys)r
   r.   	raw_hintsrequiredrm   voriginrb   s          @r   get_typeddict_infor{      s   #tnn%c*Is'((s,,-	y>5 E!L%0XLLOzz!}E!H{"Qzz!}E!HE!H " ,8,,,H:%J5::<.Y
 	
 (?r   c                 R   [        U [        5      (       a  U nOU R                  n[        U 5      n/ n/ n/ n[	        US5      (       Ga  SSKJnJnJn  UR                  R                  5        H  n	U	R                  ULa  U	R                  UL a  [        S5      eM.  U	R                  n
X*   nU	R                  ULa0  UR                  U	R                  5        UR                  XS45        M}  U	R                   ULa0  UR                  U	R                   5        UR                  XS45        M  UR                  XS45        M     UR#                  U5        S n[%        USS 5      nGO0SSKJnJn  / nUR,                   H  n	U	R                  n
X*   nU	R                  nUULa  [        UU5      (       aK  UR.                  (       a  [1        S	5      eUR                  UR2                  5        UR                  XS45        O8UR                  U5        UR                  XS45        OUR                  XS45        U	R4                  c  M  UR                  U	5        M     UR#                  U5        [%        US
S 5      n[%        USS 5      nU(       a  [7        UU5      nU[9        U5      [9        U5      X4$ )N__dataclass_fields__r   )_FIELD_FIELD_INITVARMISSINGz3dataclasses with `InitVar` fields are not supportedFT__post_init__)NOTHINGFactoryzvSupport for default factories with `takes_self=True` is not implemented. File a GitHub issue if you need this feature!__attrs_pre_init____attrs_post_init__)r8   rH   rB   ri   ro   dataclassesr~   r   r   r}   values_field_typer$   rh   defaultappenddefault_factoryextendrI   attrsr   r   __attrs_attrs__
takes_selfNotImplementedErrorfactory	validator_wrap_attrs_validatorsr:   )r
   r.   rb   rx   optionaldefaultsr~   r   r   fieldrh   typpre_init	post_initr   r   fields_with_validatorsr   s                     r   get_dataclass_infor      sR   #tnn!#&EHHHs*++??--446E  .$$6#M  ::D+C}}G+.E 23&&g5 5 56D 12E 23! 7$ 	!C$7	*!#((E::D+CmmGg%gw//))1, 
 OOGOO4OOT$56OOG,OOT$67E 23*&--e4+ ). 	!3 4d;C!6=	!./EyQIhx(EEr   c                    ^ ^ U U4S jnU$ )Nc           	      z   > T H(  nUR                  X[        XR                  5      5        M*     Tb	  T" U 5        g g r2   )r   rI   rh   )r
   r   fieldsr   s     r   rW   %_wrap_attrs_validators.<locals>.innerB  s6    EOOCZZ(@A  cN !r   r   )r   r   rW   s   `` r   r   r   A  s     Lr   c                     U " S0 UD6$ )z1Used to unpickle Structs with keyword-only fieldsr   r   )r.   kwargss     r   rebuildr   K  s    ==r   ),collectionsr]   r   r   typing_extensionsr   r	   r<   r   r   r   r   r$   version_infor   annotationlibr)   r/   r?   rZ   ri   listr:   rp   	frozensetrN   ListTupleSet	FrozenSetDict
CollectionMutableSequenceSequenceMutableMappingMapping
MutableSetAbstractSetabc_CONCRETE_TYPESr{   r   r   r   r   r   r   <module>r      s    
  "9C&75
J
ed+J
 w;* ""J wG7& <)^$	5  y	
 	$ KK LL% JJ i KK t D OOT 4 NND  s!" #$ OOOO##TOOdOOOOOO""DOOT18'TGFTE
  9889
  &&00 &!%%;&&"  ;;;sK   G( G; H# (G87G8;H H
HH HH #	H0/H0