
    hu'                     2   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S rS rS r0 \\_\\_\\_\\_\\_\R.                  \_\R0                  \_\R2                  \_\R4                  \_\R6                  \_\R8                  \_\R:                  \_\R<                  \_\R>                  \_\R@                  \_\RB                  \_\RD                  \_\ RF                  R8                  \\ RF                  R:                  \\ RF                  R<                  \\ RF                  RB                  \\ RF                  R2                  \\ RF                  R>                  \\ RF                  R@                  \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    H/home/james-whalen/.local/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   2   s    	$$Q':: 	A 9!:K:K9N OW W
  &!	 	s)    
A'+A"&AA"A'"A'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)get).0pmappings     r   	<genexpr> _apply_params.<locals>.<genexpr>Y   s     7JqQ""Js   !)
isinstancer   TypeVarr+   tuple__parameters__	Exception)r
   r.   
parametersargss    `  r   _apply_paramsr8   J   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r*   )r8   )r,   ascopes     r   r/   E_get_class_mro_and_typevar_mappings.<locals>.inner.<locals>.<genexpr>n   s     E*Qq%00*s   __orig_bases__)r1   typegetattrobjectr   Genericr4   r3   __args__lendictzip
issubclass	__bases__)
cr>   cls	new_scopeparamsr7   basesbinnerr.   s
    `      r   rQ   2_get_class_mro_and_typevar_mappings.<locals>.innere   s    aCI!\40CtVV^^44w''FE!**EEDv;#d)+++'+C,='>>GCL9c6>>**C!13==AEa#  +r   )r1   rA   r;   __mro__)r
   rL   rQ   r.   s     @@r   #_get_class_mro_and_typevar_mappingsrT   ]   sB    G#tnn$$ 
#rN;;r   c                 8   0 n[        U 5      u  p#U G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R                  R	                  S0 5      nUR                  5        HY  u  pX;   a  M  U
c  [        S5      n
O [        U
[        5      (       a  [!        U
5      n
[#        XU5      n
Ub  [%        X5      n
XU	'   M[     G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.
N__dict____annotations__)rT   r   rD   rC   r+   rG   varsrB   sysmodules
__module__rV   itemsrA   r1   strr   r   r8   )r
   hintsmrotypevar_mappingsrL   r.   
cls_localscls_globalsannnamer   s              r   get_class_annotationsre   {   s    $ E?DC6>>6**"&&s+$s)_
ckkoocnndCZQSTll0"599;KD}}T
E3''$U+u+>E"%e5$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 nUR                  5        Hp  u  pV[        USS5      nU[        L a$  UR                  U5        UR                  S   XE'   M?  U[        L a$  UR                  U5        UR                  S   XE'   Ml  XdU'   Mr     XC4$ )N__required_keys__r;   Fr   )r1   rA   r;   re   hasattrsetrg   	__total__r\   rB   r   addrE   r   discard)r
   rL   	raw_hintsrequiredr^   kvorigins           r   get_typeddict_inforr      s    #tnn%c*Is'((s,,-	y>5 E!L%0XLLOzz!}EH{"Qzz!}EH!H " ?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__)r1   rA   r;   re   rh   dataclassesru   rv   rw   rt   values_field_typer$   rd   defaultappenddefault_factoryextendrB   attrsry   rz   __attrs_attrs__
takes_selfNotImplementedErrorfactory	validator_wrap_attrs_validatorsr3   )r
   rL   r^   rn   optionaldefaultsru   rv   rw   fieldrd   typpre_init	post_initry   rz   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 r*   )r   rB   rd   )r
   r   fieldsr   s     r   rQ   %_wrap_attrs_validators.<locals>.inner4  s6    EOOCZZ(@A  cN !r   r   )r   r   rQ   s   `` r   r   r   3  s     Lr   c                     U " S0 UD6$ )z1Used to unpickle Structs with keyword-only fieldsr   r   )rL   kwargss     r   rebuildr   =  s    ==r   ))collectionsrY   r   r   typing_extensionsr   r	   r5   r   r   r   r   r$   version_infor   r8   rT   re   listr3   ri   	frozensetrG   ListTupleSet	FrozenSetDict
CollectionMutableSequenceSequenceMutableMappingMapping
MutableSetAbstractSetabc_CONCRETE_TYPESrr   r   r   r   r   r   r   <module>r      s{    
  "9C&75
J
ed+J
 w;* ""J& <)^$	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 FGFTg	  9889
  &&00 &!%%;&&"  ;;;sK   G G! H	 GG!H(G33
H=HHH		HH