a
    “˜ëj\#  ã                   @  sÜ   U d dl mZ d dlmZmZ d dlmZ d dlmZm	Z	m
Z
mZmZ d dlmZ dZded< G d	d
„ d
eƒZG dd„ deƒZeG dd„ dƒƒZddddœdd„Zddddœdd„Zddddœdd„Zddd
dœdd„ZdS ) é    )Úannotations)Ú	dataclassÚfield)Ú	TypedDict)ÚComputedFieldÚ
CoreSchemaÚDefinitionReferenceSchemaÚ	SerSchemaÚiter_union_choices)Ú	TypeAliasz&CoreSchema | SerSchema | ComputedFieldr   Ú
AllSchemasc                   @  s"   e Zd ZU dZded< ded< dS )ÚGatherResultzSchema traversing result.ú+dict[str, DefinitionReferenceSchema | None]Úcollected_referencesúlist[CoreSchema]Údeferred_discriminator_schemasN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© r   r   ú`/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pydantic/_internal/_schema_gather.pyr      s   
r   c                   @  s    e Zd ZdZdddœdd„ZdS )ÚMissingDefinitionErrorz7A reference was pointing to a non-existing core schema.ÚstrÚNone)Úschema_referenceÚreturnc                C  s
   || _ d S )N)r   )Úselfr   r   r   r   Ú__init__%   s    zMissingDefinitionError.__init__N)r   r   r   r   r   r   r   r   r   r   "   s   r   c                   @  sB   e Zd ZU dZded< eded�Zded< eded�Z	ded	< d
S )ÚGatherContextz�The current context used during core schema traversing.

    Context instances should only be used during schema traversing.
    údict[str, CoreSchema]ÚdefinitionsF)ÚinitÚdefault_factoryr   r   r   r   N)
r   r   r   r   r   r   Úlistr   Údictr   r   r   r   r   r    )   s
   
r    r   )ÚschemaÚctxr   c                 C  s*   |   d¡}|d ur&d|v r&|j | ¡ d S )NÚmetadataZ%pydantic_internal_union_discriminator)Úgetr   Úappend)r'   r(   Úmetar   r   r   Útraverse_metadataE   s    
r-   r   )Údef_ref_schemar(   r   c                 C  sr   | d }||j vrd|j |¡}|d u r.t|ƒ‚| |j |< t||ƒ d| v rXt| d |ƒ t| |ƒ n
d |j |< d S )NÚ
schema_refÚserialization)r   r"   r*   r   Útraverse_schemar-   )r.   r(   r/   Ú
definitionr   r   r   Útraverse_definition_refK   s    


r3   )r'   Úcontextr   c                 C  s4  | d }|dkrt | |ƒ d S |dkrPt| d |ƒ | d D ]}t||ƒ q<�n¾|dv rrd| v rnt| d |ƒ �nœ|dkržd| v rš| d D ]}t||ƒ qŠ�np|dkrÖd	| v r¼t| d	 |ƒ d
| v rÒt| d
 |ƒ �n8|dkrút| ƒD ]}t||ƒ qæ�n|dk�r&| d  ¡ D ]}t||ƒ �q�nè|dk�rN| d D ]}t||ƒ �q8�nÀ|dk�rxt| d |ƒ t| d |ƒ �n–|dk�r¢t| d |ƒ t| d |ƒ �nl|dv �r
d| v �rÄt| d |ƒ d| v �rè| d D ]}t||ƒ �qÖ| d  ¡ D ]}t||ƒ �qô�n|dk�rVd| v �r8| d D ]}t||ƒ �q&| d D ]}t||ƒ �q@�n¸|dk�r²| d D ]}t|d |ƒ �qhd| v �r–t| d |ƒ d| v �rt| d |ƒ �n\|dk�rÞ| d D ]}t|d |ƒ �qÄ�n0|d k�rt| d |ƒ d!| v �rt| d! |ƒ nþ|d"k�r*t| d! |ƒ nä|d#k�rfd| v �rLt| d |ƒ d$| v �rt| d$ |ƒ n¨|d%k�r¢d!| v �rˆt| d! |ƒ d$| v �rt| d$ |ƒ nl|d&k�röd!| v �rÄt| d! |ƒ d| v �rÜt| d |ƒ d$| v �rt| d$ |ƒ nd| v �rt| d |ƒ d'| v �r&t| d' |ƒ t| |ƒ d S )(NÚtypezdefinition-refr"   r'   >   r%   ÚsetÚ	frozensetÚ	generatorZitems_schemaÚtupler&   Zkeys_schemaZvalues_schemaÚunionztagged-unionÚchoicesÚchainZstepszlax-or-strictZ
lax_schemaZstrict_schemazjson-or-pythonZjson_schemaZpython_schema>   zmodel-fieldsz
typed-dictZextras_schemaZcomputed_fieldsÚfieldszdataclass-argsÚ	argumentsZarguments_schemaZvar_args_schemaZvar_kwargs_schemazarguments-v3ÚcallZreturn_schemazcomputed-fieldzfunction-beforeZjson_schema_input_schemazfunction-plainzfunction-wrapr0   )r3   r1   r
   Úvaluesr-   )r'   r4   Zschema_typer2   ÚsÚchoiceÚvÚstepr   r   r   r1   `   s®    




























r1   r   r!   )r'   r"   r   c                 C  s    t |ƒ}t| |ƒ |j|jdœS )a]  Traverse the core schema and definitions and return the necessary information for schema cleaning.

    During the core schema traversing, any `'definition-ref'` schema is:

    - Validated: the reference must point to an existing definition. If this is not the case, a
      `MissingDefinitionError` exception is raised.
    - Stored in the context: the actual reference is stored in the context. Depending on whether
      the `'definition-ref'` schema is encountered more that once, the schema itself is also
      saved in the context to be inlined (i.e. replaced by the definition it points to).
    )r   r   )r    r1   r   r   )r'   r"   r4   r   r   r   Úgather_schemas_for_cleaningÃ   s
    
þrE   N)Ú
__future__r   Zdataclassesr   r   Útypingr   Zpydantic_core.core_schemar   r   r   r	   r
   Ztyping_extensionsr   r   r   r   ÚLookupErrorr   r    r-   r3   r1   rE   r   r   r   r   Ú<module>   s   c