o
    ~j6h#                     @  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 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Zd#ddZd$ddZd%dd Zd!S )&    )annotations)	dataclassfield)	TypedDict)ComputedField
CoreSchemaDefinitionReferenceSchema	SerSchema)	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   p/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/pydantic/_internal/_schema_gather.pyr      s   
 r   c                   @  s   e Zd ZdZd	ddZdS )
MissingDefinitionErrorz7A reference was pointing to a non-existing core schema.schema_referencestrreturnNonec                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   r   r   r   r      s    r   c                   @  sF   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 )GatherContextzThe 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   schemactxr   r   c                 C  s2   |  d}|d urd|v r|j|  d S d S d S )Nmetadata%pydantic_internal_union_discriminator)getr   append)r&   r'   metar   r   r   traverse_metadata?   s   
r-   def_ref_schemar   c                 C  st   | d }||j vr3|j|}|d u rt|| |j |< t|| d| v r,t| d | t| | d S d |j |< d S )N
schema_refserialization)r   r!   r*   r   traverse_schemar-   )r.   r'   r/   
definitionr   r   r   traverse_definition_refE   s   


r3   contextc                 C  s2  | d }|dkrt | | d S |dkr(t| d | | d D ]}t|| qn|dv r9d| v r7t| d | n|dkrOd| v rM| d D ]}t|| qEn|dkrkd	| v r^t| d	 | d
| v rit| d
 | n|dkr| d D ]}t|trt|d | qst|| qsn||dkr| d  D ]}t|| qnh|dkr| d D ]}t|| qnV|dkrt| d | t| d | nB|dkrt| d | t| d | n.|dv rd| v rt| d | d| v r| d D ]}t|| q| d  D ]}t|| qn|dkr,d| v r| d D ]}t|| q| d D ]}t|| q"n|dkrY| d D ]
}t|d | q5d| v rLt| d | d| v rXt| d | n|d krn| d D ]
}t|d | qbn|d!krt| d | d"| v rt| d" | n|d#krt| d" | nr|d$krd| v rt| d | d%| v rt| d% | nT|d&krd"| v rt| d" | d%| v rt| d% | n6|d'krd"| v rt| d" | d| v rt| d | d%| v rt| d% | nd| v rt| d | d(| v rt| d( | t| | d S ))Ntypezdefinition-refr!   r&   >   setr$   	frozenset	generatoritems_schematupler%   keys_schemavalues_schemaunionchoicesr   ztagged-unionchainstepszlax-or-strict
lax_schemastrict_schemazjson-or-pythonjson_schemapython_schema>   
typed-dictmodel-fieldsextras_schemacomputed_fieldsfieldszdataclass-args	argumentsarguments_schemavar_args_schemavar_kwargs_schemazarguments-v3callreturn_schemazcomputed-fieldzfunction-beforejson_schema_input_schemazfunction-plainzfunction-wrapr0   )r3   r1   
isinstancer:   valuesr-   )r&   r4   schema_typer2   schoicevstepr   r   r   r1   Z   s   























r1   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
   
rX   N)r&   r   r'   r   r   r   )r.   r   r'   r   r   r   )r&   r   r4   r   r   r   )r&   r   r!   r    r   r   )
__future__r   dataclassesr   r   typingr   pydantic_core.core_schemar   r   r   r	   typing_extensionsr
   r   r   r   LookupErrorr   r   r-   r3   r1   rX   r   r   r   r   <module>   s   


f