a
    ¦¿hš#  ã                   @  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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)Ú	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   ú]/var/www/html/assistant/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 )Ú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   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_metadata?   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_refE   s    


r2   )r&   Úcontextr   c                 C  sR  | 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ŠnŽ|dkrÖd	| v r¼t| d	 |ƒ d
| v rÒt| d
 |ƒ nV|dkr| d D ]*}t|tƒrt|d |ƒ qèt||ƒ qèn|dkrD| d  ¡ D ]}t||ƒ q.nè|dkrl| d D ]}t||ƒ qVnÀ|dkr–t| 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rtd| v rV| d D ]}t||ƒ qD| d D ]}t||ƒ q^n¸|dkrÐ| d D ]}t|d |ƒ q†d| 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rHt| d" |ƒ nä|d$kr„d| v rjt| 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 rDt| d( |ƒ t| |ƒ d S ))NÚtypezdefinition-refr!   r&   >   Úsetr$   Ú	generatorÚ	frozensetZitems_schemaÚtupler%   Zkeys_schemaZvalues_schemaÚunionÚchoicesr   ztagged-unionÚchainZstepszlax-or-strictZ
lax_schemaZstrict_schemazjson-or-pythonZjson_schemaZpython_schema>   z
typed-dictzmodel-fieldsZ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-wrapr/   )r2   r0   Ú
isinstancer8   Úvaluesr,   )r&   r3   Zschema_typer1   ÚsÚchoiceÚvÚstepr   r   r   r0   Z   s²    





























r0   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   r0   r   r   )r&   r!   r3   r   r   r   Úgather_schemas_for_cleaningÀ   s
    
þrE   N)Ú
__future__r   Zdataclassesr   r   Útypingr   Zpydantic_core.core_schemar   r   r   r	   Ztyping_extensionsr
   r   r   r   ÚLookupErrorr   r   r,   r2   r0   rE   r   r   r   r   Ú<module>   s   f