
    Ki\#                        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
e      Z G d de      Ze G d d             ZddZddZddZddZy)    )annotations)	dataclassfield)	TypedDict)ComputedField
CoreSchemaDefinitionReferenceSchema	SerSchemaiter_union_choices)	TypeAliasz&CoreSchema | SerSchema | ComputedFieldr   
AllSchemasc                  (    e Zd ZU dZded<   	 ded<   y)GatherResultzSchema traversing result.+dict[str, DefinitionReferenceSchema | None]collected_referenceslist[CoreSchema]deferred_discriminator_schemasN)__name__
__module____qualname____doc____annotations__     m/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/pydantic/_internal/_schema_gather.pyr   r      s    #EE %54Qr   r   c                      e Zd ZdZddZy)MissingDefinitionErrorz7A reference was pointing to a non-existing core schema.c                   || _         y )N)schema_reference)selfr   s     r   __init__zMissingDefinitionError.__init__%   s
     0r   N)r   strreturnNone)r   r   r   r   r!   r   r   r   r   r   "   s
    A1r   r   c                  \    e Zd ZU dZded<   	  ede      Zded<   	  ede      Z	ded	<   y
)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&   )   sI    
 '&$7<%Y]7^"$4^
 INSXjnHoEor   r&   c                l    | j                  d      }|!d|v r|j                  j                  |        y y y )Nmetadata%pydantic_internal_union_discriminator)getr   append)schemactxmetas      r   traverse_metadatar5   E   s;    ::j!DCtK**11&9 Lr   c                   | d   }||j                   vrc|j                  j                  |      }|t        |      | |j                   |<   t	        ||       d| v rt	        | d   |       t        | |       y d |j                   |<   y )N
schema_refserialization)r   r(   r0   r   traverse_schemar5   )def_ref_schemar3   r7   
definitions       r   traverse_definition_refr<   K   s    -J111__((4
(44 0>  ,
C(n,N?;SA.#. 04  ,r   c                   | d   }|dk(  rt        | |       y |dk(  r't        | d   |       | d   D ]  }t        ||        n|dv rd| v rt        | d   |       n|dk(  rd| v r| d   D ]  }t        ||        n|dk(  r)d	| v rt        | d	   |       d
| v rt        | d
   |       n|dk(  rt        |       D ]  }t        ||        nm|dk(  r&| d   j                         D ]  }t        ||        nB|dk(  r| d   D ]  }t        ||        n%|dk(  r t        | d   |       t        | d   |       n |dk(  r t        | d   |       t        | d   |       n|dv rSd| v rt        | d   |       d| v r| d   D ]  }t        ||        | d   j                         D ]  }t        ||        n|dk(  r2d| v r| d   D ]  }t        ||        | d   D ]  }t        ||        nM|dk(  rB| d   D ]  }t        |d   |        d| v rt        | d   |       d| v rt        | d   |       n|dk(  r| d   D ]  }t        |d   |        n|d k(  r#t        | d   |       d!| v rt        | d!   |       n|d"k(  rt        | d!   |       n|d#k(  r'd| v rt        | d   |       d$| v rt        | d$   |       n~|d%k(  r'd!| v rt        | d!   |       d$| v rbt        | d$   |       nR|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	        | |       y )(Ntypezdefinition-refr(   r2   >   setr+   	frozenset	generatoritems_schematupler,   keys_schemavalues_schemaunionztagged-unionchoices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-wrapr8   )r<   r9   r   valuesr5   )r2   contextschema_typer;   schoicevsteps           r   r9   r9   `   s"    .K&&0		%x('2 / 	1JJ0	1	A	AV#F>2G<		V#N+ ,7+,		F"F=17;f$F?3W=		(0 	-FFG,	-		&	"))+ 	(AAw'	(		7O 	+DD'*	+		'|,g6/9	(	(}-w7/9	6	6f$F?3W=&-. ,7+,!((* 	(AAw'	(	(	(&-. ,7+,! 	(AAw'	(		#*+ 	2AAhK1	2&F#45w?&(F#67A		&*+ 	2AAhK1	2		12G<f$F?3W=	(	(/9	)	)vF8,g6%/F#=>H	(	(f$F?3W=%/F#=>H		'f$F?3W=vF8,g6%/F#=>HvF8,g6& /9fg&r   c                b    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&   r9   r   r   )r2   r(   r[   s      r   gather_schemas_for_cleaningrb      s6     K(GFG$ !( < <*1*P*P r   N)r2   r   r3   r&   r#   r$   )r:   r	   r3   r&   r#   r$   )r2   r   r[   r&   r#   r$   )r2   r   r(   r'   r#   r   )
__future__r   dataclassesr   r   typingr   pydantic_core.core_schemar   r   r	   r
   r   typing_extensionsr   r   r   r   LookupErrorr   r&   r5   r<   r9   rb   r   r   r   <module>ri      sp    " (   (@
I @R9 R1[ 1   6:4*`'Fr   