a
    g=ici                     @   sp  U d dl Z d dlZd dlZd dlmZmZmZ d dlmZ d dl	m
Z
mZ d dlmZmZmZmZmZ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!m"Z"m#Z#m$Z$m%Z%m&Z& d dl'm(Z( dd	l)m*Z* dd
lm+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 ddl3m4Z4 erd dl5m6Z6 d dl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z> ddl?m@Z@ ddlmAZAmBZBmCZCmDZDmEZE ee&ee#e e#eFef e#eFeef f  ZGdZHdZIeJeKeLeFeMeNeOe+eeeejPeeeQjReSjRhZTe"e$e  eUd< eVeWeXeYeZeeehZ[e"e$e  eUd< eFedddZ\dde&eF eJeFdddZ]eeMdd d!Z^ee$d"  eFdd#d$d%Z_ee&e$e e#e$e d&f df eMd'd(d)Z`ee&e$e e#e$e d&f df eMd*d+d,ZaeMd-d.d/ZbeFeMd0d1d2Zce%d3Zdeedef eedef eedef d4d5d6Zeeeef edd7d8d9Zfd:d;eKeKeKeMd<d=d>Zged? eeFd@f e$dA dBdCdDdEZhe&e$d" e$dF f e$d" dGdHdIZieFeFdJdKdLZjeFeFdJdMdNZke%dOZleFdPe&eel e#eld&f f eelgeFf eel dQdRdSZmG dTdU dUeFZnG dVdW dWZoG dXdY dYeoZpG dZd[ d[eoZqG d\d] d]Zrd^d_d`dadbdcdddedfZsdgeFdhdidjZte%dkZueueudGdldmZveFeMdndodpZwh dqZxeFeMdndrdsZyez Z{ee ee eMdtdudvZ|e eFe dwdxdyZ}eeF eFeFdzd{d|Z~eeFe#eFe#eFd&f f d}d~dZe$e eFe#eFe#e#eFd&f d&f f dddZe%dZe%dZer\G dd deZeeef ZnG dd deZZdS )    N)OrderedDictdefaultdictdeque)deepcopy)islicezip_longest)BuiltinFunctionTypeCodeTypeFunctionTypeGeneratorType
LambdaType
ModuleType)TYPE_CHECKINGAbstractSetAnyCallable
CollectionDict	GeneratorIterableIteratorListMappingMutableMappingNoReturnOptionalSetTupleTypeTypeVarUnion)	Annotated   )ConfigError)NoneTypeWithArgsTypesall_literal_valuesdisplay_as_typeget_args
get_originis_literal_typeis_union)version_info)	Signature)Path)
BaseConfig)	Dataclass)
ModelField	BaseModel)AbstractSetIntStrDictIntStrAnyIntStrMappingIntStrAnyReprArgs)import_stringsequence_likevalidate_field_namelenient_isinstancelenient_issubclass
in_ipythonis_valid_identifierdeep_updateupdate_not_nonealmost_equal_floats	get_modelto_camelis_valid_fieldsmart_deepcopyPyObjectStrRepresentation
GetterDict
ValueItemsr,   ClassAttribute	path_typeROOT_KEYget_unique_discriminator_alias"get_discriminator_alias_and_valuesDUNDER_ATTRIBUTESLimitedDictZ__root__IMMUTABLE_NON_COLLECTIONS_TYPESBUILTIN_COLLECTIONS)dotted_pathreturnc              
   C   s   ddl m} z| ddd\}}W n6 ty\ } ztd|  d|W Y d}~n
d}~0 0 ||}zt||W S  ty } z$td	| d
| d|W Y d}~n
d}~0 0 dS )z
    Stolen approximately from django. Import a dotted module path and return the attribute/class designated by the
    last name in the path. Raise ImportError if the import fails.
    r   )import_module .r"   "z!" doesn't look like a module pathNzModule "z" does not define a "z" attribute)	importlibrV   striprsplit
ValueErrorImportErrorgetattrAttributeError)rT   rV   module_path
class_nameemodule re   _/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/pydantic/utils.pyr9   {   s    (r9   P   )max_len)vrh   rU   c                C   s   t dt t| tr>t| |d kr>| d|d  d  S z|  } W n tyh   | j| } Y n0 t| |kr| d|d  d } | S )z`
    Truncate a value and add a unicode ellipsis (three dots) to the end if it was too long
    z:`truncate` is no-longer used by pydantic and is deprecated   N   u   …r"   )	warningswarnDeprecationWarning
isinstancestrlen__repr__	TypeError	__class__)ri   rh   re   re   rf   truncate   s    ru   ri   rU   c                 C   s   t | ttttttfS N)ro   listtupleset	frozensetr   r   ri   re   re   rf   r:      s    r:   r3   )bases
field_namerU   c                 C   s0   | D ]&}t ||drtd| d| dqdS )zZ
    Ensure that the field's name does not shadow an existing attribute of the model.
    NzField name "zI" shadows a BaseModel attribute; use a different field name with "alias='z'".)r_   	NameError)r}   r~   basere   re   rf   r;      s    r;   .)oclass_or_tuplerU   c                 C   s&   zt | |W S  ty    Y dS 0 d S NF)ro   rs   )r   r   re   re   rf   r<      s    r<   )clsr   rU   c                 C   s@   zt | tot| |W S  ty:   t | tr4Y dS  Y n0 d S r   )ro   type
issubclassrs   r%   )r   r   re   re   rf   r=      s    
r=   rU   c                   C   s*   zt d W n ty    Y dS 0 dS dS )zU
    Check whether we're in an ipython environment, including jupyter notebooks.
    Z__IPYTHON__FTN)evalr   re   re   re   rf   r>      s
    r>   )
identifierrU   c                 C   s   |   ot|  S )z
    Checks that a string is a valid identifier and not a Python keyword.
    :param identifier: The identifier to test.
    :return: True if the identifier is valid.
    )isidentifierkeyword	iskeyword)r   re   re   rf   r?      s    r?   KeyType)mappingupdating_mappingsrU   c                 G   sd   |   }|D ]R}| D ]D\}}||v rTt|| trTt|trTt|| |||< q|||< qq|S rw   )copyitemsro   dictr@   )r   r   Zupdated_mappingZupdating_mappingkri   re   re   rf   r@      s     r@   )r   updaterU   c                 K   s   |  dd | D  d S )Nc                 S   s   i | ]\}}|d ur||qS rw   re   ).0r   ri   re   re   rf   
<dictcomp>       z#update_not_none.<locals>.<dictcomp>)r   r   )r   r   re   re   rf   rA      s    rA   g:0yE>)delta)value_1value_2r   rU   c                C   s   t | | |kS )z4
    Return True if two floats are almost equal
    )abs)r   r   r   re   re   rf   rB      s    rB   ).Nr1   r/   r-   )initfieldsconfigrU   c                 C   s|  ddl m}m}m} ddlm} || j }i }d}	d}
t|ddD ] }|j	|j
u r\|}	qF|||j< qF|	r|j}| D ]t\}}|j}||v sz||v rqzn t|s|rt|r|}nd}
qz|jsd|jini }|||jfd	|ji|||< qz|j|ju rd}
|	rh|
rhd
|jfd|j
fg}dd |D |kr<d}n|	j}||v rX|d7 }qB|	j|d||< |t| ddS )z:
    Generate signature for model based on its fields
    r   )	Parameterr-   	signaturer"   )ExtraNFTdefault
annotationZ__pydantic_self__datac                 S   s   g | ]}|j |jfqS re   )namekind)r   pre   re   rf   
<listcomp>  r   z,generate_model_signature.<locals>.<listcomp>
extra_data_r   )
parametersreturn_annotation)inspectr   r-   r   r   r   r   valuesr   r   VAR_KEYWORDr   Zallow_population_by_field_namer   aliasr?   requiredr   KEYWORD_ONLYr   extraZallowPOSITIONAL_OR_KEYWORDreplacerx   )r   r   r   r   r-   r   r   Zpresent_paramsZmerged_paramsZvar_kwZ
use_var_kwparamZallow_namesr~   field
param_namekwargsZdefault_model_signatureZvar_kw_namere   re   rf   generate_model_signature   sV    
r   r0   )objrU   c                 C   sD   ddl m} z
| j}W n ty,   | }Y n0 t||s@td|S )Nr"   r2   z7Unsupported type, must be either BaseModel or dataclass)mainr3   __pydantic_model__r`   r   rs   )r   r3   	model_clsre   re   rf   rC   .  s    


rC   )stringrU   c                 C   s   d dd | dD S )N c                 s   s   | ]}|  V  qd S rw   )
capitalize)r   wordre   re   rf   	<genexpr><  r   zto_camel.<locals>.<genexpr>r   )joinsplit)r   re   re   rf   rD   ;  s    rD   c                 C   s4   t | dkr,t| }|d  |dd   S |  S )Nr"   r   )rq   rD   lower)r   Zpascal_stringre   re   rf   to_lower_camel?  s    r   T)name_factory)
input_listr   rU   c                C   sJ   g }g }| D ]8}||}||vr6| | | | q||||< q|S )z
    Make a list unique while maintaining order.
    We update the list if another one with the same name is set
    (e.g. root validator overridden in subclass)
    )appendindex)r   r   resultZresult_namesri   Zv_namere   re   rf   unique_listI  s    

r   c                   @   s   e Zd ZdZedddZdS )rG   z
    String class where repr doesn't include quotes. Useful with Representation when you want to return a string
    representation of something that valid (or pseudo-valid) python.
    r   c                 C   s   t | S rw   )rp   selfre   re   rf   rr   f  s    zPyObjectStr.__repr__N)__name__
__module____qualname____doc__rp   rr   re   re   re   rf   rG   `  s   rG   c                   @   s   e Zd ZU dZe Zeedf ed< ddddZ	eddd	Z
eed
ddZeegef eeeddf dddZedddZedddZddddZdS )rH   z
    Mixin to provide __str__, __repr__, and __pretty__ methods. See #884 for more details.

    __pretty__ is used by [devtools](https://python-devtools.helpmanual.io/) to provide human readable representations
    of objects.
    .	__slots__r8   r   c                    s"    fdd j D }dd |D S )a6  
        Returns the attributes to show in __str__, __repr__, and __pretty__ this is generally overridden.

        Can either return:
        * name - value pairs, e.g.: `[('foo_name', 'foo'), ('bar_name', ['b', 'a', 'r'])]`
        * or, just values, e.g.: `[(None, 'foo'), (None, ['b', 'a', 'r'])]`
        c                 3   s   | ]}|t  |fV  qd S rw   )r_   )r   sr   re   rf   r   |  r   z/Representation.__repr_args__.<locals>.<genexpr>c                 S   s    g | ]\}}|d ur||fqS rw   re   r   ari   re   re   rf   r   }  r   z0Representation.__repr_args__.<locals>.<listcomp>)r   )r   attrsre   r   rf   __repr_args__t  s    zRepresentation.__repr_args__c                 C   s   | j jS )zA
        Name of the instance's class, used in __repr__.
        )rt   r   r   re   re   rf   __repr_name__  s    zRepresentation.__repr_name__)join_strrU   c                 C   s   | dd |  D S )Nc                 s   s0   | ](\}}|d u rt |n| d|V  qd S )N=)reprr   re   re   rf   r     r   z.Representation.__repr_str__.<locals>.<genexpr>)r   r   )r   r   re   re   rf   __repr_str__  s    zRepresentation.__repr_str__N)fmtr   rU   c                 k   s^   |   d V  dV  |  D ]0\}}|dur6|d V  ||V  dV  dV  qdV  dV  dS )	z
        Used by devtools (https://python-devtools.helpmanual.io/) to provide a human readable representations of objects
        (r"   Nr   ,r   ))r   r   )r   r   r   r   valuere   re   rf   
__pretty__  s    

zRepresentation.__pretty__c                 C   s
   |  dS )NrW   )r   r   re   re   rf   __str__  s    zRepresentation.__str__c                 C   s   |    d| d dS )Nr   , r   )r   r   r   re   re   rf   rr     s    zRepresentation.__repr__RichReprResultc                 c   s0   |   D ]"\}}|du r |V  q||fV  qdS )zGet fields for Rich libraryN)r   )r   r   Z
field_reprre   re   rf   __rich_repr__  s    zRepresentation.__rich_repr__)r   r   r   r   ry   r   r   rp   __annotations__r   r   r   r   r   r   r   r   rr   r   re   re   re   rf   rH   j  s   
&rH   c                   @   s   e Zd ZdZdZedddZeedddZd%eeed
ddZ	e
e dddZee dddZee dddZeeeef  dddZee dddZedddZeedddZeedddZd dd!d"Zedd#d$Zd	S )&rI   z
    Hack to make object's smell just enough like dicts for validate_model.

    We can't inherit from Mapping[str, Any] because it upsets cython so we have to implement all methods ourselves.
    _obj)r   c                 C   s
   || _ d S rw   r   )r   r   re   re   rf   __init__  s    zGetterDict.__init__)keyrU   c              
   C   sB   zt | j|W S  ty< } zt||W Y d }~n
d }~0 0 d S rw   )r_   r   r`   KeyError)r   r   rc   re   re   rf   __getitem__  s    zGetterDict.__getitem__N)r   r   rU   c                 C   s   t | j||S rw   )r_   r   )r   r   r   re   re   rf   get  s    zGetterDict.getr   c                 C   s   t  S )zn
        We don't want to get any other attributes of obj if the model didn't explicitly ask for them
        )rz   r   re   re   rf   
extra_keys  s    zGetterDict.extra_keysc                 C   s   t | S )z
        Keys of the pseudo dictionary, uses a list not set so order information can be maintained like python
        dictionaries.
        )rx   r   re   re   rf   keys  s    zGetterDict.keysc                    s    fdd D S )Nc                    s   g | ]} | qS re   re   r   r   r   re   rf   r     r   z%GetterDict.values.<locals>.<listcomp>re   r   re   r   rf   r     s    zGetterDict.valuesc                 c   s   | D ]}||  |fV  qd S rw   )r   )r   r   re   re   rf   r     s    zGetterDict.itemsc                 c   s$   t | jD ]}|ds
|V  q
d S )Nr   )dirr   
startswith)r   r   re   re   rf   __iter__  s    
zGetterDict.__iter__c                 C   s   t dd | D S )Nc                 s   s   | ]
}d V  qdS )r"   Nre   )r   r   re   re   rf   r     r   z%GetterDict.__len__.<locals>.<genexpr>)sumr   re   re   rf   __len__  s    zGetterDict.__len__itemrU   c                 C   s   ||   v S rw   )r   r   r   re   re   rf   __contains__  s    zGetterDict.__contains__)otherrU   c                 C   s   t | t | kS rw   )r   r   )r   r   re   re   rf   __eq__  s    zGetterDict.__eq__r8   c                 C   s   d t | fgS rw   )r   r   re   re   rf   r     s    zGetterDict.__repr_args__c                 C   s   dt | j dS )NzGetterDict[])r'   r   r   re   re   rf   r     s    zGetterDict.__repr_name__)N)r   r   r   r   r   r   r   rp   r   r   r   r   r   r   r   r   r   r   r   intr   boolr   r  r   r   re   re   re   rf   rI     s   rI   c                   @   s   e Zd ZdZdZeed ddddZeedd	d
Z	eedddZ
deed  dddZdeddddZed'eeeedddZeed ddddZeeedddZeeed d!d"Zd#d$d%d&ZdS )(rJ   zY
    Class for more convenient calculation of excluded or included fields on values.
    )_items_type)r4   r7   N)r   r   rU   c                 C   s2   |  |}t|ttfr(| |t|}|| _d S rw   )_coerce_itemsro   rx   ry   _normalize_indexesrq   r  )r   r   r   re   re   rf   r     s    
zValueItems.__init__r   c                 C   s   |  | j|S )z`
        Check if item is fully excluded.

        :param item: key or index of a value
        )is_truer  r   r   re   re   rf   is_excluded  s    zValueItems.is_excludedc                 C   s
   || j v S )zh
        Check if value is contained in self._items

        :param item: key or index of value
        r  r   re   re   rf   is_included  s    zValueItems.is_includedr6   )rc   rU   c                 C   s   | j |}| |s|S dS )z
        :param e: key or index of element on value
        :return: raw values for element if self._items is dict and contain needed element
        N)r  r   r	  )r   rc   r   re   re   rf   for_element  s    zValueItems.for_elementr7   r5   )r   v_lengthrU   c           	      C   s  i }d}|  D ]\}}t|tsLt|tsL| |sLtd| d|j |dkr`| |}qt|tsrtd|dk r|| n|}| 	||
|||< q|s|S | |rt|D ]}||d q|S t|D ]*}||i }| |s| 	||||< q|S )af  
        :param items: dict or set of indexes which will be normalized
        :param v_length: length of sequence indexes of which will be

        >>> self._normalize_indexes({0: True, -2: True, -1: True}, 4)
        {0: True, 2: True, 3: True}
        >>> self._normalize_indexes({'__all__': True}, 4)
        {0: True, 1: True, 2: True, 3: True}
        Nz,Unexpected type of exclude value for index "z" __all__zExcluding fields from a sequence of sub-models or dicts must be performed index-wise: expected integer keys or keyword "__all__"r   .)r   ro   r   r   r	  rs   rt   _coerce_valuer  merger   range
setdefault)	r   r   r  Znormalized_itemsZ	all_itemsiri   Znormalized_inormalized_itemre   re   rf   r    s2    



zValueItems._normalize_indexesF)r   override	intersectrU   c                    s   |  |    du r  S |  s2 du r6S | rL|rH S S |rvfdd D  fddD  }nt  fddD  }i }|D ]0}| j |||d}|dur|||< q|S )ae  
        Merge a ``base`` item with an ``override`` item.

        Both ``base`` and ``override`` are converted to dictionaries if possible.
        Sets are converted to dictionaries with the sets entries as keys and
        Ellipsis as values.

        Each key-value pair existing in ``base`` is merged with ``override``,
        while the rest of the key-value pairs are updated recursively with this function.

        Merging takes place based on the "union" of keys if ``intersect`` is
        set to ``False`` (default) and on the intersection of keys if
        ``intersect`` is set to ``True``.
        Nc                    s   g | ]}| v r|qS re   re   r   )r  re   rf   r   N  r   z$ValueItems.merge.<locals>.<listcomp>c                    s   g | ]}| v r|qS re   re   r   r   re   rf   r   N  r   c                    s   g | ]}| vr|qS re   re   r   r  re   rf   r   P  r   )r  )r  r	  rx   r  r   )r   r   r  r  Z
merge_keysmergedr   Zmerged_itemre   )r   r  rf   r  3  s"    


&
zValueItems.merge)r   rU   c                 C   sD   t | trn4t | tr$t| d} nt| dd}t| d|  | S )N.rt   z???z!Unexpected type of exclude value )ro   r   r   r   fromkeysr_   assert_never)r   rb   re   re   rf   r  Z  s    

zValueItems._coerce_items)r   rU   c                 C   s    |d u s|  |r|S | |S rw   )r	  r  )r   r   re   re   rf   r  h  s    zValueItems._coerce_valuerv   c                 C   s   | du p| du S )NT.re   r|   re   re   rf   r	  n  s    zValueItems.is_truer8   r   c                 C   s   d | j fgS rw   r  r   re   re   rf   r   r  s    zValueItems.__repr_args__)F)r   r   r   r   r   r   r    r   r  r
  r  r   r  r  r  classmethodr  staticmethodr  r  r	  r   re   re   re   rf   rJ     s    	'&rJ   c                   @   s<   e Zd ZdZdZeeddddZeee dddd	Z	dS )
rK   z1
    Hide class attribute from its instances
    r   r   N)r   r   rU   c                 C   s   || _ || _d S rw   r  )r   r   r   re   re   rf   r     s    zClassAttribute.__init__)instanceownerrU   c                 C   s*   |d u r| j S t| jd|jdd S )Nz attribute of z is class-only)r   r`   r   r   )r   r  r   re   re   rf   __get__  s    zClassAttribute.__get__)
r   r   r   r   r   rp   r   r   r   r!  re   re   re   rf   rK   v  s   rK   	directoryfilezmount pointsymlinkzblock devicezchar deviceZFIFOsocket)is_diris_fileis_mount
is_symlinkis_block_deviceis_char_deviceis_fifo	is_socketr.   )r   rU   c                 C   s:   |   sJ dt D ]\}}t| | r|  S qdS )z0
    Find out what sort of thing a path is.
    zpath does not existunknown)exists
path_typesr   r_   )r   methodr   re   re   rf   rL     s
    
rL   Objc              
   C   sZ   | j }|tv r| S z&| s6|tv r6|tu r,| n|  W S W n tttfyP   Y n0 t| S )z
    Return type as is for immutable built-in types
    Use obj.copy() for built-in empty collections
    Use copy.deepcopy() for non-empty collections and unknown objects
    )	rt   rR   rS   ry   r   rs   r]   RuntimeErrorr   )r   obj_typere   re   rf   rF     s    rF   )r   rU   c                 C   s   |  dsdS t| kS )Nr   T)r   rM   r   re   re   rf   rE     s    
rE   >   __orig_bases____classcell__r   r   r   r   __orig_class__c                 C   s   t |  o| tvS rw   )rE   rP   r   re   re   rf   is_valid_private_name  s    r8  )leftrightrU   c                 C   s*   t | |tdD ]\}}||ur dS qdS )a  
    Check that the items of `left` are the same objects as those in `right`.

    >>> a, b = object(), object()
    >>> all_identical([a, b, a], [a, b, a])
    True
    >>> all_identical([a, b, [a]], [a, b, [a]])  # new list object, while "equal" is not "identical"
    False
    )	fillvalueFT)r   _EMPTY)r9  r:  Z	left_itemZ
right_itemre   re   rf   all_identical  s    
r=  )r   msgrU   c                 C   s   t |dS )z
    Helper to make sure that we have covered all possible types.

    This is mostly useful for ``mypy``, docs:
    https://mypy.readthedocs.io/en/latest/literal_types.html#exhaustive-checks
    N)rs   )r   r>  re   re   rf   r    s    r  )all_aliasesdiscriminator_keyrU   c                 C   s<   t | }t|dkr4td|ddt|  d| S )zNValidate that all aliases are the same and if that's the case return the aliasr"   zAliases for discriminator z must be the same (got r   r   )rz   rq   r#   r   sortedpop)r?  r@  Zunique_aliasesre   re   rf   rN     s    rN   )tpr@  rU   c              
   C   sx  t | dd}t| tu r$t| d } t| dr4| j} tt| rdt| |\}}|tdd |D fS |r| j	t
 j}t||\}}tt|dkrtd|d	t| ||d fS z| j	| j}W nv ty  } z td
| jd|W Y d}~nFd}~0  ty< } z$td| jd||W Y d}~n
d}~0 0 t|s`td|d| jd| j	| jt|fS dS )z
    Get alias and all valid values in the `Literal` type of the discriminator field
    `tp` can be a `BaseModel` class or directly an `Annotated` `Union` of many.
    Z__custom_root_type__Fr   r   c                 s   s   | ]}|D ]
}|V  q
qd S rw   re   )r   r   ri   re   re   rf   r     r   z5get_discriminator_alias_and_values.<locals>.<genexpr>r"   zField z& is not the same for all submodels of zType z* is not a valid `BaseModel` or `dataclass`NzModel z% needs a discriminator field for key z
 of model z needs to be a `Literal`)r_   r)   r!   r(   hasattrr   r+   _get_union_alias_and_all_valuesry   Z
__fields__rM   type_rq   rz   r#   r'   r`   rs   r   r   r*   r   r&   )rC  r@  Zis_root_modelr   
all_values
union_typeZt_discriminator_typerc   re   re   rf   rO     s2    
(.
rO   )rH  r@  rU   c                    s0    fddt | D }t| \}}t| |fS )Nc                    s   g | ]}t | qS re   )rO   )r   tr@  re   rf   r   "  r   z3_get_union_alias_and_all_values.<locals>.<listcomp>)r(   ziprN   )rH  r@  Zzipped_aliases_valuesr?  rG  re   rJ  rf   rE    s    rE  KTVTc                   @   s   e Zd ZdedddZdS )rQ     
size_limitc                 C   s   d S rw   re   r   rP  re   re   rf   r   -  s    LimitedDict.__init__N)rN  )r   r   r   r  r   re   re   re   rf   rQ   ,  s   rQ   c                       sN   e Zd ZdZded fddZeedd fdd	Zeed
ddZ  Z	S )rQ   a)  
        Limit the size/length of a dict used for caching to avoid unlimited increase in memory usage.

        Since the dict is ordered, and we always remove elements from the beginning, this is effectively a FIFO cache.

        Annoying inheriting from `MutableMapping` breaks cython.
        rN  rO  c                    s   || _ t   d S rw   )rP  superr   rQ  rt   re   rf   r   ;  s    rR  N)_LimitedDict__key_LimitedDict__valuerU   c                    s\   t  || t| | jkrXt| | j | jd  }t|  d | }|D ]
}| |= qLd S )N
   )rS  __setitem__rq   rP  rx   r   )r   rU  rV  excess	to_remover   rT  re   rf   rX  ?  s    zLimitedDict.__setitem__)argsrU   c                 G   s   d S rw   re   )r   r[  re   re   rf   __class_getitem__G  s    zLimitedDict.__class_getitem__)rN  )
r   r   r   r   r  r   r   rX  r\  r6  re   re   rT  rf   rQ   2  s   )r   rl   weakrefcollectionsr   r   r   r   r   	itertoolsr   r   typesr   r	   r
   r   r   r   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    Ztyping_extensionsr!   errorsr#   r$   r%   r&   r'   r(   r)   r*   r+   versionr,   r   r-   pathlibr.   r   r/   dataclassesr0   r   r1   r   r3   r4   r5   r6   r7   r8   rp   r   r  rM   r  floatcomplexr  bytesr   refNotImplementedrt   EllipsisrR   r   rx   rz   ry   r{   r   rS   r9   ru   r:   r;   r<   r=   r>   r?   r   r@   rA   rB   r   rC   rD   r   r   r   rG   rH   rI   rJ   rK   r0  rL   r2  rF   rE   rP   r8  objectr<  r=  r  rN   rO   rE  rL  rM  rQ   re   re   re   rf   <module>   s   
 T(
*,,		*A$
<> 

"*	