o
    ú©ZhŸ"  ã                   @  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   úX/var/www/html/lang_env/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ÚmetadataZ%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   


r2   Úcontextc                 C  sö  | 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ƒr‚t|d |ƒ qst||ƒ qsn^|dkrž| d  ¡ D ]}t||ƒ q”nJ|dkr°| d D ]}t||ƒ q¦n8|dkrÄt| d |ƒ t| d |ƒ n$|dkrØt| d |ƒ t| d |ƒ n|dv rd| v rèt| d |ƒ d| v rø| d D ]}t||ƒ qð| d  ¡ D ]}t||ƒ qþná|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 |ƒ qbnz|d!kr‡t| d |ƒ d"| v r†t| d" |ƒ na|d#kr”t| d" |ƒ nT|d$kr²d"| v r¥t| d" |ƒ d%| v r±t| d% |ƒ n6|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&   >   Ú	frozensetÚ	generatorÚsetr$   Z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-plainZjson_schema_input_schemazfunction-wrapr/   )r2   r0   Ú
isinstancer8   Úvaluesr,   )r&   r3   Zschema_typer1   ÚsÚchoiceÚvÚstepr   r   r   r0   Z   sÄ   
ÿ€€€
üÿÿ
ÿ

ÿ


€
ÿ

€



€



€

r0   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)r&   r   r'   r   r   r   )r-   r   r'   r   r   r   )r&   r   r3   r   r   r   )r&   r   r!   r    r   r   )Ú
__future__r   Údataclassesr   r   Útypingr   Zpydantic_core.core_schemar   r   r   r	   Útyping_extensionsr
   r   r   r   ÚLookupErrorr   r   r,   r2   r0   rE   r   r   r   r   Ú<module>   s   


a