
    mi'F              
      ,   U d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZmZmZmZmZmZmZmZmZmZmZmZ m!Z"m#Z# ddl$m%Z% dZ&d	e'd
<   e(ee)         e*e*e*e*e)e)ee)         f         Z+de'd<    G d d          Z,e%Z-dZ.de'd<   dZ/de'd<   dZ0de'd<   dZ1de'd<   dZ2de'd<   dZ3de'd<   dZ4de'd<   dZ5de'd<   dZ6de'd<   d Z7de'd!<   d"Z8de'd#<   d$Z9de'd%<   d&Z:de'd'<   d(Z;de'd)<   d*Z<de'd+<   d,Z=de'd-<   d.Z>de'd/<   dfd6Z?dgd;Z@dhd=Zdid>Zdjd@ZdkdAZ!dldCZdmdDZdndFZAdodGZBdpdIZCdqdJZDdrdLZEdsdMZFdtdOZGdudQZHdvdSZIdwdUZJdxdWZKdydXZLe	dYe*e)eMf         ZNde'dZ<   e	eNeOd[         ePe)d[f         e(d\         f         ZQde'd[<   dzd]ZRd{d^ZSd|d`ZTd}daZUd~ddZVddeZWdYS )a3  
This module contains high-level logic for fixed format serialization.

Lower-level parts are implemented in C in mypyc/lib-rt/librt_internal.c
Short summary of low-level functionality:
* integers are automatically serialized as 1, 2, or 4 bytes, or arbitrary length.
* str/bytes are serialized as size (1, 2, or 4 bytes) followed by bytes buffer.
* floats are serialized as C doubles.

At high-level we add type tags as needed so that our format is self-descriptive.
More precisely:
* False, True, and None are stored as just a tag: 0, 1, 2 correspondingly.
* builtin primitives like int/str/bytes/float are stored as their type tag followed
  by bare (low-level) representation of the value. Reserved tag range for primitives is
  3 ... 19.
* generic (heterogeneous) list are stored as tag, followed by bare size, followed by
  sequence of tagged values.
* homogeneous lists of primitives are stored as tag, followed by bare size, followed
  by sequence of bare values.
* reserved tag range for sequence-like builtins is 20 ... 29
* currently we have only one mapping-like format: string-keyed dictionary with heterogeneous
  values. It is stored as tag, followed by bare size, followed by sequence of pairs: bare
  string key followed by tagged value.
* reserved tag range for mapping-like builtins is 30 ... 39
* there is an additional reserved tag range 40 ... 49 for any other builtin collections.
* custom classes (like types, symbols etc.) are stored as tag, followed by a sequence of
  tagged field values, followed by a special end tag 255. Names of class fields are
  *not* stored, the caller should know the field names and order for the given class tag.
* reserved tag range for symbols (TypeInfo, Var, etc) is 50 ... 79.
* class Instance is the only exception from the above format (since it is the most common one).
  It has two extra formats: few most common instances like "builtins.object" are stored as
  instance tag followed by a secondary tag, other plain non-generic instances are stored as
  instance tag followed by secondary tag followed by fullname as bare string. All generic
  readers must handle these.
* reserved tag range for Instance type formats is 80 ... 99, for other types it is 100 ... 149.
* tag 254 is reserved for if we would ever need to extend the tag range to indicated second tag
  page. Tags 150 ... 253 are free for everything else (e.g. AST nodes etc).

General convention is that custom classes implement write() and read() methods for FF
serialization. The write method should write both class tag and end tag. The read method
conventionally *does not* read the start tag (to simplify logic for unions). Known exceptions
are MypyFile.read() and SymbolTableNode.read(), since those two never appear in a union.

If any of these details change, or if the structure of CacheMeta changes please
bump CACHE_VERSION below.
    )annotations)Sequence)AnyFinalOptionalUnion)	TypeAlias)
ReadBufferWriteBuffer	read_bool
read_bytes
read_floatread_intread_strread_tag
write_boolwrite_byteswrite_float	write_int	write_str	write_tag)u8   r   CACHE_VERSION
_TypeAliasSerializedErrorc                  Z    e Zd ZdZd,d Zd-d"Zed.d%            Zd/d(Zed0d*            Z	d+S )1	CacheMetaz/Class representing cache metadata for a module.idstrpathmtimeintsizehashdependencies	list[str]
data_mtime	data_file
suppressedoptionsdict[str, object]	dep_prios	list[int]	dep_lines
dep_hasheslist[bytes]interface_hashbyteserror_lineslist[SerializedError]
version_id
ignore_allboolplugin_datar   returnNonec                  || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        || _        || _        || _        || _        || _        || _        d S N)r   r!   r"   r$   r%   r&   r(   r)   r*   r+   r-   r/   r0   r2   r4   r6   r7   r9   )selfr   r!   r"   r$   r%   r&   r(   r)   r*   r+   r-   r/   r0   r2   r4   r6   r7   r9   s                      b/var/www/html/bestrading.cuttalo.com/scripts/kaggle-env/lib/python3.11/site-packages/mypy/cache.py__init__zCacheMeta.__init__Q   s    , 	
		($"$""$,&$$&    dict[str, Any]c                N   i d| j         d| j        d| j        d| j        d| j        d| j        d| j        d| j        d	| j        d
| j	        d| j
        dd | j        D             d| j                                        d| j        d| j        d| j        d| j        S )Nr   r!   r"   r$   r%   r(   r&   r*   r+   r-   r/   r0   c                6    g | ]}|                                 S  )hex.0deps     r?   
<listcomp>z'CacheMeta.serialize.<locals>.<listcomp>   s     @@@37799@@@rA   r2   r4   r6   r7   r9   )r   r!   r"   r$   r%   r(   r&   r*   r+   r-   r/   r0   r2   rF   r4   r6   r7   r9   )r>   s    r?   	serializezCacheMeta.serialize|   s   
$'
DI
 TZ
 DI	

 DI
 $/
 D-
 $/
 t|
 
 
 @@@@@
 d15577
 4+
 $/
  $/!
" 4+#
 	
rA   metaCacheMeta | Nonec           	        	 t          di d|d         d|d         d|d         d|d         d|d         d|d         d|d         d|d	|d	         d
|d
         d|d         d|d         dd |d         D             dt                              |d                   dd |d         D             d|d         d|d         d|d         S # t          t          f$ r Y d S w xY w)Nr   r!   r"   r$   r%   r&   r(   r)   r*   r+   r-   r/   r0   c                B    g | ]}t                               |          S rE   )r3   fromhexrG   s     r?   rJ   z)CacheMeta.deserialize.<locals>.<listcomp>   s$    MMM3EMM#..MMMrA   r2   r4   c                ,    g | ]}t          |          S rE   )tuple)rH   errs     r?   rJ   z)CacheMeta.deserialize.<locals>.<listcomp>   s    GGGCU3ZZGGGrA   r6   r7   r9   rE   )r   r3   rP   KeyError
ValueError)clsrL   r)   s      r?   deserializezCacheMeta.deserialize   s   	   ::&\\ 7mm &\\	
 &\\ ".11  -- $)  -- Y {++ {++ NM$|:LMMMM  %}}T2B-CDDD HG43FGGGG   --!"  --#$ !//% ( *% 	 	 	44	s   CC C)(C)datar   c                   t          || j                   t          || j                   t          || j                   t          || j                   t          || j                   t          || j                   t          || j	                   t          || j
                   t          || j                   t          || j                   t          || j                   t!          || j                   t%          || j                   t)          || j                   t          || j                   t/          || j                   t3          || j                   d S r=   )r   r   r!   r   r"   r$   r%   write_str_listr&   r(   r*   
write_jsonr+   write_int_listr-   r/   write_bytes_listr0   r   r2   write_errorsr4   r6   r   r7   write_json_valuer9   )r>   rX   s     r?   writezCacheMeta.write   s@   $   $	"""$
###$	"""$	"""tT.///$(((tT_---4&&&tT^,,,tT^,,,t///D$-...T4+,,,$(((4))) 	t/00000rA   r
   c                `   	 t          di dt          |          dt          |          dt          |          dt          |          dt          |          dt          |          dt          |          d|d	t          |          d
t	          |          dt          |          dt          |          dt          |          dt          |          dt          |          dt          |          dt          |          dt          |          S # t          $ r Y d S w xY w)Nr   r!   r"   r$   r%   r&   r(   r)   r*   r+   r-   r/   r0   r2   r4   r6   r7   r9   rE   )r   r   r   read_str_list	read_jsonread_int_listread_bytes_listr   read_errorsr   read_json_valuerU   )rV   rX   r)   s      r?   readzCacheMeta.read   s   	   D>>>d^^^ tnnn d^^^	
 d^^^ +4000 $D>>> $) )... "$ (--- (--- +4000  *$/// (---  $D>>>!" %T???#$ ,D111% (  	 	 	44	s   DD 
D-,D-N)&r   r    r!   r    r"   r#   r$   r#   r%   r    r&   r'   r(   r#   r)   r    r*   r'   r+   r,   r-   r.   r/   r.   r0   r1   r2   r3   r4   r5   r6   r    r7   r8   r9   r   r:   r;   )r:   rB   )rL   rB   r)   r    r:   rM   )rX   r   r:   r;   )rX   r
   r)   r    r:   rM   )
__name__
__module____qualname____doc__r@   rK   classmethodrW   r`   rh   rE   rA   r?   r   r   N   s        99)' )' )' )'V
 
 
 
*    [21 1 1 1*    [  rA   r   z
Final[Tag]LITERAL_FALSELITERAL_TRUE   LITERAL_NONE   LITERAL_INT   LITERAL_STR   LITERAL_BYTES   LITERAL_FLOAT   LITERAL_COMPLEX   LIST_GEN   LIST_INT   LIST_STR   
LIST_BYTES   	TUPLE_GEN   DICT_STR_GEN   EXTRA_ATTRS   DT_SPEC   END_TAGrX   r
   tagTagr:   int | str | bool | floatc                    |t           k    rt          |           S |t          k    rt          |           S |t          k    rdS |t
          k    rdS |t          k    rt          |           S J d|             )NFTzUnknown literal tag )rs   read_int_bareru   read_str_barern   ro   ry   read_float_barerX   r   s     r?   read_literalr      s    
kT"""			T"""			u			t			t$$$.......rA   r   value)int | str | bool | float | complex | Noner;   c                   t          |t                    rt          | |           d S t          |t                    r't	          | t
                     t          | |           d S t          |t                    r't	          | t                     t          | |           d S t          |t                    r't	          | t                     t          | |           d S t          |t                    rAt	          | t                     t          | |j                   t          | |j                   d S t	          | t"                     d S r=   )
isinstancer8   r   r#   r   rs   write_int_barer    ru   write_str_barefloatry   write_float_barecomplexr{   realimagrq   rX   r   s     r?   write_literalr     s4   % &4	E3		 &$$$$tU#####	E3		 &$$$$tU#####	E5	!	! &$&&&u%%%%%	E7	#	# &$(((uz***uz*****$%%%%%rA   r#   c                T    t          |           t          k    sJ t          |           S r=   )r   rs   r   rX   s    r?   r   r     '    D>>[((((rA   c                P    t          | t                     t          | |           d S r=   )r   rs   r   r   s     r?   r   r      (    dK   4rA   r    c                T    t          |           t          k    sJ t          |           S r=   )r   ru   r   r   s    r?   r   r   %  r   rA   c                P    t          | t                     t          | |           d S r=   )r   ru   r   r   s     r?   r   r   *  r   rA   r3   c                T    t          |           t          k    sJ t          |           S r=   )r   rw   read_bytes_barer   s    r?   r   r   /  s'    D>>]****4   rA   c                P    t          | t                     t          | |           d S r=   )r   rw   write_bytes_barer   s     r?   r   r   4  s(    dM"""T5!!!!!rA   
int | Nonec                r    t          |           }|t          k    rd S |t          k    sJ t          |           S r=   )r   rq   rs   r   r   s     r?   read_int_optr   9  <    
4..C
lt+rA   c                    |'t          | t                     t          | |           d S t          | t                     d S r=   )r   rs   r   rq   r   s     r?   write_int_optr   A  D    $$$$tU#####$%%%%%rA   
str | Nonec                r    t          |           }|t          k    rd S |t          k    sJ t          |           S r=   )r   rq   ru   r   r   s     r?   read_str_optr   I  r   rA   c                    |'t          | t                     t          | |           d S t          | t                     d S r=   )r   ru   r   rq   r   s     r?   write_str_optr   Q  r   rA   r.   c                     t                     t          k    sJ t                     } fdt          |          D             S )Nc                .    g | ]}t                    S rE   )r   rH   _rX   s     r?   rJ   z!read_int_list.<locals>.<listcomp>\  !    555AM$555rA   )r   r   r   rangerX   r$   s   ` r?   rd   rd   Y  G    D>>X%%%%D5555t5555rA   c                    t          | t                     t          | t          |                     |D ]}t          | |           d S r=   )r   r   r   lenrX   r   items      r?   r\   r\   _  T    dH4U$$$ # #tT""""# #rA   r'   c                     t                     t          k    sJ t                     } fdt          |          D             S )Nc                .    g | ]}t                    S rE   )r   r   s     r?   rJ   z!read_str_list.<locals>.<listcomp>i  r   rA   )r   r   r   r   r   s   ` r?   rb   rb   f  r   rA   Sequence[str]c                    t          | t                     t          | t          |                     |D ]}t	          | |           d S r=   )r   r   r   r   r   r   s      r?   rZ   rZ   l  r   rA   r1   c                     t                     t          k    sJ t                     } fdt          |          D             S )Nc                .    g | ]}t                    S rE   )r   r   s     r?   rJ   z#read_bytes_list.<locals>.<listcomp>v  s!    777aOD!!777rA   )r   r   r   r   r   s   ` r?   re   re   s  sG    D>>Z''''D77775;;7777rA   Sequence[bytes]c                    t          | t                     t          | t          |                     |D ]}t	          | |           d S r=   )r   r   r   r   r   r   s      r?   r]   r]   y  sT    dJ4U$$$ % %t$$$$% %rA   list[str | None]c                     t                     t          k    sJ t                     } fdt          |          D             S )Nc                .    g | ]}t                    S rE   )r   r   s     r?   rJ   z%read_str_opt_list.<locals>.<listcomp>  s!    4441L444rA   )r   r}   r   r   r   s   ` r?   read_str_opt_listr     sG    D>>X%%%%D4444d4444rA   c                    t          | t                     t          | t          |                     |D ]}t	          | |           d S r=   )r   r}   r   r   r   r   s      r?   write_str_opt_listr     sT    dH4U$$$ " "dD!!!!" "rA   NValue	JsonValue)r   .c                J    t                     }|t          k    rd S |t          k    rdS |t          k    rdS |t          k    rt                     S |t          k    rt                     S |t          k    r*t                     } fdt          |          D             S |t          k    r7t                     }t           fdt          |          D                       S |t          k    r*t                     } fdt          |          D             S J d|             )NFTc                .    g | ]}t                    S rE   rg   r   s     r?   rJ   z#read_json_value.<locals>.<listcomp>  s!    ;;;!%%;;;rA   c              3  6   K   | ]}t                    V  d S r=   r   r   s     r?   	<genexpr>z"read_json_value.<locals>.<genexpr>  s+      @@q_T**@@@@@@rA   c                J    i | ]}t                    t                     S rE   r   rg   r   s     r?   
<dictcomp>z#read_json_value.<locals>.<dictcomp>  s+    PPPqd##_T%:%:PPPrA   zInvalid JSON tag: )r   rq   rn   ro   rs   r   ru   r   r}   r   r   rR   r   )rX   r   r$   s   `  r?   rg   rg     s6   
4..C
lt
mu
lt
kT"""
kT"""
hT"";;;;uT{{;;;;
iT""@@@@E$KK@@@@@@
lT""PPPPE$KKPPPP,,s,,,,,rA   c                   |t          | t                     d S t          |t                    rt	          | |           d S t          |t
                    r't          | t                     t          | |           d S t          |t                    r't          | t                     t          | |           d S t          |t                    rIt          | t                     t          | t          |                     |D ]}t          | |           d S t          |t                    rIt          | t                      t          | t          |                     |D ]}t          | |           d S t          |t"                    rlt          | t$                     t          | t          |                     t'          |          D ](}t          | |           t          | ||                    )d S J d|             )NFzInvalid JSON value: )r   rq   r   r8   r   r#   rs   r   r    ru   r   listr}   r   r_   rR   r   dictr   sorted)rX   r   valkeys       r?   r_   r_     s   }$%%%%%	E4	 	  54	E3		 5$$$$tU#####	E3		 5$$$$tU#####	E4	 	  5$!!!tSZZ((( 	( 	(CT3''''	( 	(	E5	!	! 5$	"""tSZZ((( 	( 	(CT3''''	( 	(	E4	 	  5$%%%tSZZ(((%== 	/ 	/C4%%%T5:....	/ 	/ 	54U44444rA   rB   c                     t                     t          k    sJ t                     } fdt          |          D             S )Nc                J    i | ]}t                    t                     S rE   r   r   s     r?   r   zread_json.<locals>.<dictcomp>  s+    LLL1M$!6!6LLLrA   )r   r   r   r   r   s   ` r?   rc   rc     sG    D>>\))))DLLLLdLLLLrA   c                    t          | t                     t          | t          |                     t	          |          D ](}t          | |           t          | ||                    )d S r=   )r   r   r   r   r   r   r_   )rX   r   r   s      r?   r[   r[     sn    dL!!!4U$$$e}} + +tS!!!uSz****+ +rA   errsr5   c           	        t          | t                     t          | t          |                     |D ]\  }}}}}}}}	t          | t                     t          | |           t          | |           t          | |           t          | |           t          | |           t          | |           t          | |           t          | |	           d S r=   )r   r}   r   r   r   r   r   r   )
rX   r   r!   linecolumnend_line
end_columnseveritymessagecodes
             r?   r^   r^     s    dH4T###MQ 	" 	"IdFHj(GT$	"""dD!!!$$$!!!$
###$!!!$   dD!!!!	" 	"rA   c                   t          |           t          k    sJ g }t          t          |                     D ]}t          |           t          k    sJ |                    t          |           t          |           t          |           t          |           t          |           t          |           t          |           t          |           f           |S r=   )	r   r}   r   r   r   appendr   r   r   )rX   resultr   s      r?   rf   rf     s    D>>X%%%%F=&&'' 
 
~~****T""T""		
 	
 	
 	
 MrA   )rX   r
   r   r   r:   r   )rX   r   r   r   r:   r;   )rX   r
   r:   r#   )rX   r   r   r#   r:   r;   )rX   r
   r:   r    )rX   r   r   r    r:   r;   )rX   r
   r:   r3   )rX   r   r   r3   r:   r;   )rX   r
   r:   r   )rX   r   r   r   r:   r;   )rX   r
   r:   r   )rX   r   r   r   r:   r;   )rX   r
   r:   r.   )rX   r   r   r.   r:   r;   )rX   r
   r:   r'   )rX   r   r   r   r:   r;   )rX   r
   r:   r1   )rX   r   r   r   r:   r;   )rX   r
   r:   r   )rX   r   r   r   r:   r;   )rX   r
   r:   r   )rX   r   r   r   r:   r;   )rX   r
   r:   rB   )rX   r   r   rB   r:   r;   )rX   r   r   r5   r:   r;   )rX   r
   r:   r5   )Xrl   
__future__r   collections.abcr   typingr   r   r   r   typing_extensionsr	   r   librt.internalr
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   mypy_extensionsr   r   __annotations__rR   r    r#   r   r   r   rn   ro   rq   rs   ru   rw   ry   r{   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rd   r\   rb   rZ   re   r]   r   r   r8   r   r   r   r   rg   r_   rc   r[   r^   rf   rE   rA   r?   <module>r      sB  - - -^ # " " " " " $ $ $ $ $ $ . . . . . . . . . . . . 5 5 5 5 5 5                                           #HSM3S#sCQYZ]Q^$^_ _ _ _ _J J J J J J J J\ 	                                              
    	                     / / / / & & & &(   
       
   
       
! ! ! !
" " " "
   & & & &   & & & &6 6 6 6# # # #6 6 6 6# # # #8 8 8 8% % % %5 5 5 5" " " " $S$./ / / / / 	4d3#34e<L6MM	    
- - - -05 5 5 5BM M M M+ + + +" " " "     rA   