
    df_             	         U d Z ddlmZ ddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZmZmZ dd	lmZ dd
lmZ ddlmZmZmZ ddl
mZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ ddlm,Z, ddl-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z<m=Z= ddl>m?Z?m@Z@ ddlAmBZBmCZCmDZD ddlEmFZFmGZGmHZH ddlImJZJ ddlKmLZL ddlmMZM ddlNmOZOmPZPmQZQmRZR ddlSmTZTmUZU ddlVmWZWmXZX ddlYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_ ddlOm`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZl ddlmmnZnmoZo ddlpmqZq dd lrmsZsmtZtmuZumvZv dd!lwmxZx dd"lRmyZy dd#lzm{Z{ erdd$l|m}Z} dd%l~mZ dd&lmZ dd'lwmZ e	j                  d(k\  Z ee3ed)f         Ze)ehedecf   Z e(d*e+      Ze)eaeh   eaed   eaec   f   Ze<Ze!e ege0j\                  f   Zee
j                  gZd,ed-<   ee
j$                  ej&                  j(                  gZd,ed.<   ee
j.                  ej&                  j0                  gZd,ed/<   ee
j6                  ej&                  j.                  gZd,ed0<   ee
jD                  ej&                  j<                  ej&                  jL                  gZd,ed1<   	 	 	 	 	 	 dSd2ZdTd3Z	 	 	 	 	 	 dUd4Z	 	 	 	 	 	 	 	 dVd5Z	 	 	 	 	 	 	 	 dWd6Ze"e'e    e@f   Z	 	 	 	 	 	 	 	 dXd7Z G d8 d9      Zd: d; d< d= d> d? d@ dA dBZdCedD<   	 	 	 	 	 	 	 	 dYdEZdZdFZ	 	 	 	 	 	 	 	 d[dGZd\dHZd]dIZ G dJ dKe7      ZddddddL	 	 	 	 	 	 	 	 	 	 	 	 	 d^dMZ G dN dO      Zd_dPZ G dQ dR      Zy)`z-Convert python types to pydantic-core schema.    )annotationsN)contextmanager)copydeepcopy)Enum)partial)	Parameter_ParameterKind	signature)chain)
attrgetter)FunctionType
LambdaType
MethodType)TYPE_CHECKINGAnyCallableDict
ForwardRefIterableIteratorMappingTypeTypeVarUnioncastoverload)warn)
CoreSchemaPydanticUndefinedcore_schemato_jsonable_python)	AnnotatedFinalLiteralTypeAliasType	TypedDictget_args
get_originis_typeddict   )GetCoreSchemaHandlerGetJsonSchemaHandler)
ConfigDictJsonEncoder)PydanticSchemaGenerationErrorPydanticUndefinedAnnotationPydanticUserError)AliasChoices	AliasPath	FieldInfo)JsonSchemaValue)version_short)PydanticDeprecatedSince20   )_decorators_discriminated_union_known_annotated_metadata_typing_extra)ConfigWrapperConfigWrapperStack)CoreMetadataHandlerbuild_metadata_dict),NEEDS_APPLY_DISCRIMINATED_UNION_METADATA_KEYCoreSchemaOrFielddefine_expected_missing_refsget_refget_type_ref%is_list_like_schema_with_items_schema)ComputedFieldInfo	DecoratorDecoratorInfosFieldSerializerDecoratorInfoFieldValidatorDecoratorInfoModelSerializerDecoratorInfoModelValidatorDecoratorInfoRootValidatorDecoratorInfoValidatorDecoratorInfoget_attribute_from_basesinspect_field_serializerinspect_model_serializerinspect_validator)collect_dataclass_fieldsget_type_hints_infer_globalns)PydanticRecursiveRef)get_standard_typevars_maphas_instance_in_typerecursively_defined_type_refsreplace_types)CallbackGetCoreSchemaHandler)is_finalvar)lenient_issubclass	BaseModel)FieldValidatorModes)StandardDataclass)GetJsonSchemaFunction)      {   FieldDecoratorInfoType)boundz
list[type]TUPLE_TYPES
LIST_TYPES	SET_TYPESFROZEN_SET_TYPES
DICT_TYPESc                ~    t        | t        t        f      rd| j                  v ry| j                  D ]	  }||k(  s	 y y)zCheck if field name is in validator fields.

    Args:
        info: The field info.
        field: The field name to check.

    Returns:
        `True` if field name is in validator fields, `False` otherwise.
    *TF)
isinstancerP   rL   fields)infofieldv_field_names      \/home/api-vastappli/venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py)check_validator_fields_against_field_namerv   p   sG     $/1LMN$++ 5      c           	     Z   t        |      }| D ]  }t        |j                  t        t        f      rd|j                  j
                  v r<|j                  j                  du rU|j                  j
                  D ].  }||vst        d|j                   d|j                   dd        y)	av  Check if the defined fields in decorators exist in `fields` param.

    It ignores the check for a decorator if the decorator has `*` as field or `check_fields=False`.

    Args:
        decorators: An iterable of decorators.
        fields: An iterable of fields name.

    Raises:
        PydanticUserError: If one of the field names does not exist in `fields` param.
    ro   Fz*Decorators defined with incorrect fields: .zO (use check_fields=False if you're inheriting from the model and intended this)zdecorator-missing-fieldcodeN)
setrp   rr   rP   rL   rq   check_fieldsr2   cls_refcls_var_name)
decoratorsrq   decrs   s       ru   check_decorator_fields_existr      s     [F chh!79T UV[^bebjbjbqbq[q88  E)XX__ 	EF"'@QsO_O_N`ef2 	rw   c                Z    | D cg c]  }t        |j                  |      s| c}S c c}w N)rv   rr   )validator_functionsrs   r   s      ru   $filter_field_decorator_info_by_fieldr      s*     /mC2[\_\d\dfk2lCmmms   ((c                t   | d   dk(  rt        | d   ||      | d<   | S t        |       r:| j                  dd       }|t        j                         }t        |||      | d<   | S | d   dk(  r:| j                  dd       }|t        j                         }t        |||      | d<   | S |rt        d| d          | S )Ntypenullableschemaitems_schemadictvalues_schemazO`@validator(..., each_item=True)` cannot be applied to fields with a schema of )apply_each_item_validatorsrG   getr!   
any_schemaapply_validators	TypeError)r   each_item_validators
field_nameinner_schemas       ru   r   r      s     f~#5fX6FH\^hix	.v	6zz.$7&113L!1,@TV`!a~ M 
6	! zz/48&113L"2<AUWa"b
 M	 
]^dek^l]mn
 	
 Mrw   c                    ||       }|j                  |      }d|v r|d   }|j                          d|ig|d<   d|vr|j                  |d<   |j                  }|rd|vrt	        j
                  |      |d<   |S )a0  Add title and description for model-like classes' JSON schema.

    Args:
        schema_or_field: The schema data to generate a JSON schema from.
        handler: The `GetCoreSchemaHandler` instance.
        cls: The model-like class.

    Returns:
        JsonSchemaValue: The updated JSON schema.
    z$refallOftitledescription)resolve_ref_schemaclear__name____doc__inspectcleandoc)schema_or_fieldhandlerclsjson_schemaoriginal_schemaref	docstrings          ru   modify_model_json_schemar      s     /*K00=O f%%+SM? o%#&<< I]/9)0)9)9))D&rw   c                "   | s|S d|v r|S |gt        |d|j                  j                        dd D ]Y  }| j                  |      }|t	        j
                  dt                dt               t        j                  |d      |d<   |c S  |S )	a  Iterate over the json_encoders and add the first matching encoder to the schema.

    Args:
        json_encoders: A dictionary of types and their encoder functions.
        tp: The type to check for a matching encoder.
        schema: The schema to add the encoder to.
    serialization__mro__Nz=`json_encoders` is deprecated. See https://docs.pydantic.dev/z</concepts/serialization/#custom-serializers for alternativesjson)	when_used)
getattr	__class__r   r   warningsr   r7   r8   r!   $plain_serializer_function_ser_schema)json_encoderstpr   baseencoders        ru   ,_add_custom_serialization_from_json_encodersr      s     &  Hgb)R\\-A-AB3BGH ##D)?KMOK\  ]Y  Z%	
 #."R"RSZfl"m Mrw   c                  L   e Zd ZdZdZ	 dD	 	 	 	 	 	 	 dEdZe	 	 	 	 	 	 	 	 	 	 dFd       ZedGd       Z	edHd       Z
edId       ZdJd	ZdKd
ZdLdZdKdZdKdZdKdZdMdZdNdZdOdZdPdZdQdZdRdZ	 dS	 	 	 	 	 dTdZdUdZdQdZdVdZdWdZedXd       ZedYd       ZdZd[dZdWdZd\dZ d]d Z!d^d!Z"d^d"Z#d^d#Z$d_d$Z%dd%	 	 	 	 	 	 	 	 	 d`d&Z&	 	 	 	 	 	 	 	 dad'Z'	 	 	 	 	 	 	 	 dbd(Z(dcd)Z)ddd*Z*	 	 	 	 dOd+Z+ded,Z,dfd-Z-dgd.Z.e/j`                  df	 	 	 	 	 	 	 	 	 dhd/Z1did0Z2djd1Z3dkd2Z4dld3Z5dmd4Z6dnd5Z7djd6Z8	 	 	 	 	 	 dod7Z9dpd8Z:dqd9Z;	 	 	 	 	 	 drd:Z<dsd;Z=	 	 	 	 	 	 dtd<Z>d= f	 	 	 	 	 	 	 dud>Z?dvd?Z@	 	 	 	 	 	 dvd@ZA	 	 	 	 	 	 	 	 dwdAZB	 dZ	 	 	 	 	 	 	 dxdBZC	 	 	 	 	 	 dydCZDy)zGenerateSchemaz\Generate core schema for a Pydantic model, dataclass and types like `str`, `datetime`, ... .)_config_wrapper_stack_types_namespace_typevars_map _needs_apply_discriminated_union_has_invalid_schemafield_name_stackdefsNc                    t        |      | _        || _        || _        d| _        d| _        t               | _        t               | _	        y NF)
r?   r   r   r   r   r   _FieldNameStackr   _Definitionsr   )selfconfig_wrappertypes_namespacetypevars_maps       ru   __init__zGenerateSchema.__init__  sE     &8%G" /)05-#(  / 1 N	rw   c                    | j                  |       }||_        ||_        ||_        d|_        d|_        t               |_        ||_        |S r   )	__new__r   r   r   r   r   r   r   r   )r   config_wrapper_stackr   r   r   objs         ru   __from_parentzGenerateSchema.__from_parent$  sQ     kk#$8!.(/4,"'.0
rw   c                .    | j                   j                  S r   )r   tailr   s    ru   _config_wrapperzGenerateSchema._config_wrapper6  s    ))...rw   c                    | j                   j                  xs t        }|j                  | j                  | j
                  | j                  | j                        S r   )r   schema_generatorr   _GenerateSchema__from_parentr   r   r   r   )r   r   s     ru   _current_generate_schemaz'GenerateSchema._current_generate_schema:  sM    ""33E~  &&!!II	
 	
rw   c                .    | j                   j                  S r   )r   arbitrary_types_allowedr   s    ru   _arbitrary_typeszGenerateSchema._arbitrary_typesD  s    ##;;;rw   c                *    t        j                         S )zGenerate a CoreSchema for `str`)r!   
str_schemar   s    ru   r   zGenerateSchema.str_schemaH  s    %%''rw   c                J    t        j                  | j                  |            S r   )r!   list_schemagenerate_schemar   r   
items_types      ru   _list_schemazGenerateSchema._list_schemaN  s    &&t';';J'GHHrw   c                j    t        j                  | j                  |      | j                  |            S r   )r!   dict_schemar   )r   r   	keys_typevalues_types       ru   _dict_schemazGenerateSchema._dict_schemaQ  s,    &&t';';I'FH\H\]hHijjrw   c                J    t        j                  | j                  |            S r   )r!   
set_schemar   r   s      ru   _set_schemazGenerateSchema._set_schemaT  s    %%d&:&::&FGGrw   c                J    t        j                  | j                  |            S r   )r!   frozenset_schemar   r   s      ru   _frozenset_schemaz GenerateSchema._frozenset_schemaW  s    ++D,@,@,LMMrw   c                J    t        j                  | j                  |            S r   )r!   tuple_variable_schemar   r   s      ru   _tuple_variable_schemaz%GenerateSchema._tuple_variable_schemaZ  s    001E1Ej1QRRrw   c                r    |D cg c]  }| j                  |       }}t        j                  |      S c c}w r   )r   r!   tuple_positional_schema)r   r   items_typesr   items_schemass        ru   _tuple_positional_schemaz'GenerateSchema._tuple_positional_schema]  s7    LWXj--j9XX22=AA Ys   4c                    t        |t              s't        |dt               t	        j
                         S t	        j                  |      S )Na   is not a Python type (it may be an instance of an object), Pydantic will allow any object with no validation since we cannot even enforce that the input is an instance of the given type. To get rid of this error wrap the type with `pydantic.SkipValidation`.)rp   r   r   UserWarningr!   r   is_instance_schema)r   r   s     ru   _arbitrary_type_schemaz%GenerateSchema._arbitrary_type_schemaa  sL    "d#& Z Z  ))++--b11rw   c                     t        d|d      )N,Unable to generate pydantic-core schema for a  . Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.)r0   r   r   s     ru   _unknown_type_schemaz#GenerateSchema._unknown_type_schemam  s#    +:3' Bf f
 	
rw   c                    	 t        j                  ||      S # t         j                  $ r> t        j                  ||       d|v rd|d   t        <   nt        di|d<   d| _        |cY S w xY w)NmetadataT)r;   apply_discriminatorMissingDefinitionForUnionRefset_discriminatorrB   r   )r   r   discriminators      ru   _apply_discriminator_to_unionz,GenerateSchema._apply_discriminator_to_unionx  s    	';;  $@@ 	 22 V#SWz"#OP&RTX%Yz"48D1M	s    AA)(A)c                *   t        d|j                  dd             }|r|| j                  j                  |<   d|v rt	        j
                  |d         }t	        j                  |t        | j                  j                  j                                     S )N
str | Noner   )	r   r   r   definitionsr!   definition_reference_schemadefinitions_schemalistvalues)r   r   r   s      ru   collect_definitionsz"GenerateSchema.collect_definitions  s|    <E4!89)/DII!!#&F? <<VE]KF--&&--/0
 	
rw   c                ~    t        |      j                  }|j                  dg       }||vr|j                  |       y y )Npydantic_js_functions)r@   r   
setdefaultappend)r   metadata_schemajs_functionr   r  s        ru   _add_js_functionzGenerateSchema._add_js_function  sD    &7@@ ( 3 34KR P 33!((5 4rw   Tc                H   d}|r| j                  ||      }||}|| j                  |      }t        ||      }|4t        || j                  j
                        }|r| j                  ||       t        | j                  j                  ||      }| j                  |      }|S )a  Generate core schema.

        Args:
            obj: The object to generate core schema for.
            from_dunder_get_core_schema: Whether to generate schema from either the
                `__get_pydantic_core_schema__` function or `__pydantic_core_schema__` property.

        Returns:
            The generated core schema.

        Raises:
            PydanticUndefinedAnnotation:
                If it is not possible to evaluate forward reference.
            PydanticSchemaGenerationError:
                If it is not possible to generate pydantic-core schema.
            TypeError:
                - If `alias_generator` returns a non-string value.
                - If V1 style validator with `each_item=True` applied on a wrong field.
            PydanticUserError:
                - If `typing.TypedDict` is used instead of `typing_extensions.TypedDict` on Python < 3.12.
                - If `__modify_schema__` method is used instead of `__get_pydantic_json_schema__`.
        N)_generate_schema_from_property_generate_schema!_extract_get_pydantic_json_schemaresolve_original_schemar   r  r  r   r   r   _post_process_generated_schema)r   r   from_dunder_get_core_schemar   from_propertymetadata_js_functionr  s          ru   r   zGenerateSchema.generate_schema  s    6 %)& ??SIM(&>**3/F@fM+5fdii>S>STO%%o7KL=d>R>R>`>`begmn44V<rw   c                N   | j                   j                  |      5 \  }}||cddd       S |j                  }|j                  }|j                  }t        t        |j                  j                         |j                  j                         |j                  j                               h |j                         |j                                t        |j                  d      }|j                  |      }t        t!        t"        |      g      }	|j$                  j                         }
d}|j'                  d      dk(  r|g|j(                  D ]  }|j*                  j'                  dd      }|"t-        |      }|t.        t0        fvrt3        d	      | j5                  |j*                  d   d
      d   }|t6        usr| j9                  |      } n | j:                  j=                  |      5  | j>                  } |j@                  r]| jC                  d|d   |      }|d   }tE        ||
d      }tG        jH                  ||tK        |dd      d
tK        |dd      |||	      }n	tG        jL                  |jO                         D ci c]  \  }}|| jQ                  |||       c}}|j                         D cg c]  }| jS                  ||j                          c}||jT                        }tW        ||jX                  j                         d      }t[        |t]                     }||}tE        ||
d      }tG        jH                  ||tK        |dd      dtK        |dd      |||	      }| j_                  ||j`                  j                               }tE        ||
d      }| jc                  |      | j                   jd                  |<   tG        jf                  |      cddd       cddd       S c c}}w c c}w # 1 sw Y   nxY w	 ddd       y# 1 sw Y   yxY w)z%Generate schema for a Pydantic model.NF)checkr   js_functionsextra_fields_behaviorallow__pydantic_extra__zEThe type annotation for `__pydantic_extra__` must be `Dict[str, ...]`Trequiredr9   rootr   inner__pydantic_custom_init____pydantic_post_init__)custom_init
root_model	post_initconfigr   r   )computed_fieldsextras_schema
model_nameouter)4r   get_schema_or_refmodel_fields__pydantic_decorators__r-  r   r   field_validatorsr	  field_serializers
validatorskeysr>   model_configcore_configrA   r   r   model_validatorsr   r   __annotations__r)   r   r   r0    _get_args_resolving_forward_refsr   r   r   pushr   __pydantic_root_model___common_field_schemaapply_model_validatorsr!   model_schemar   model_fields_schemaitems_generate_md_field_schema_computed_field_schemar   r   root_validatorsrD   rZ   _apply_model_serializersmodel_serializersr  r  r  )r   r   	model_refmaybe_schemarq   r   r-  r   r9  r   r:  r.  r   extras_annotationextra_items_type
root_fieldr   rA  kvdfields_schemanew_inner_schemar   s                           ru   _model_schemazGenerateSchema._model_schema  s:   YY((- U	J1J)\'#U	J U	J %%F44J(88O(//66800779))002
 :&++-9/"6"6"89 +3+;+;5IN(44S9K*AY_b9c8deH)::AAC M677B-- "B(+(;(;(?(?@TVZ([%(4'(9:dD\1"? g#  ,0+P+P//0DE%) ,Q , ,( ,36,0,@,@AQ,RM!"  ++00@ .J44..!%!:!:66&>S]!^J#-h#7L#9,HXZa#bL#.#;#;$$+C1KT$R#'")#/G"N*%!)	$L =H<[<[Y_YeYeYghQUQRTUD::1aLLh &5%;%;%=) ! !77:;W;WX) '4#&<<=M $4M:C]C]CdCdCfhl#mL'CLRoRq'r$'3'7#9,HXZa#bL#.#;#;$$+C1KT$R#(")#/G"N*%!)	$L 66|ZEaEaEhEhEjk/8H'R373V3VW]3^		%%i0">>yI].J .JOU	J U	Jr i)'.J .J .JOU	J U	J U	JsV   PEP6AP/P5BPO:+P #P #DP'	P:PP	
PP$c                    dd}|d   dk(  rB| j                   j                  j                  |d   D ci c]  } ||      | c}       |d   }|S c c}w )zuUnpack all 'definitions' schemas into `GenerateSchema.defs.definitions`
        and return the inner schema.
        c                    | d   S )Nr    )ss    ru   rE   z1GenerateSchema._unpack_refs_defs.<locals>.get_ref0  s    U8Orw   r   r  r   )rW  r   returnstr)r   r  update)r   r   rE   rW  s       ru   _unpack_refs_defsz GenerateSchema._unpack_refs_defs+  sZ    
	 &>]*II!!((AV)WA'!*a-)WXH%F *Xs   Ac                   | j                   j                  |      5 \  }}||cddd       S 	 ddd       ||u rd}nd}t        |dd      }|\t        |dd      }|yt        dt               t        j                   |       D cg c]  }t        j                  |       c}      }	nSt        t        j                  |      j                        dk(  r	 ||      }	n ||t        | j                  | |            }	| j                  |	      }	t        |	      }
|
r=| j!                  |	      | j                   j"                  |
<   t        j$                  |
      S | j!                  |	      }	|	S # 1 sw Y   ?xY wc c}w )	a0  Try to generate schema from either the `__get_pydantic_core_schema__` function or
        `__pydantic_core_schema__` property.

        Note: `__get_pydantic_core_schema__` takes priority so it can
        decide whether to use a `__pydantic_core_schema__` attribute, or generate a fresh schema.
        Nunpackzto-def__get_pydantic_core_schema____get_validators__zc`__get_validators__` is deprecated and will be removed, use `__get_pydantic_core_schema__` instead.r9   )ref_mode)r   r1  r   r   r8   r!   chain_schema"with_info_plain_validator_functionlenr   r   
parametersr\   r  r[  rE   r  r  r  )r   r   source_rJ  r`  
get_schemar6  rO  r   r   s              ru   r  z-GenerateSchema._generate_schema_from_property8  sx    YY((- 	$1B!\'#	$ 	$'	$ &=HH S"@$G
 &:DAJ!u) !--jtjv.wef{/]/]^_/`.wxF7$$Z0;;<A#F+#89N9NPT_gh ''/fo)-)L)LV)TDII!!#&::3??44V<K	$ 	$$ /xs   E+E8+E5c                .   	 t        j                  || j                        }t        |t              rt	        |j                  d|       | j                  rt        || j                        }|S # t        $ r}t	        j
                  |      |d }~ww xY w)N)globalnsz%Unable to evaluate forward reference )r=   evaluate_fwd_refr   	NameErrorr1   from_name_errorrp   r   __forward_arg__r   r[   )r   r   es      ru   _resolve_forward_refz#GenerateSchema._resolve_forward_refg  s    	H00t?T?TUC
 c:&-c.A.AEjknjoCpqqT%7%78C
  	H-==a@aG	Hs   !A0 0	B9BBc                     y r   rV  )r   r   r$  s      ru   r<  z/GenerateSchema._get_args_resolving_forward_refs}      rw   c                     y r   rV  r   s     ru   r<  z/GenerateSchema._get_args_resolving_forward_refs  rq  rw   c           	         t        |      }|r<t        |D cg c]%  }t        |t              r| j	                  |      n|' c}      }|S |rt        d| d      |S c c}w )Nz	Expected z+ to have generic parameters but it had none)r(   tuplerp   r   ro  r   )r   r   r$  argsas        ru   r<  z/GenerateSchema._get_args_resolving_forward_refs  sk    }dhi_`*Q
:S$33A6YZZijD  iu,WXYY js   *Ac                >    | j                  |      }|st        S |d   S )Nr   )r<  r   )r   r   ru  s      ru   _get_first_arg_or_anyz$GenerateSchema._get_first_arg_or_any  s#    44S9JAwrw   c                    | j                  |      }|st        t        fS t        |      dk  rt        |      }t	        d| d      |d   |d   fS )Nr+   z Expected two type arguments for z, got 1r   r9   )r<  r   rc  r)   r   )r   r   ru  origins       ru   _get_first_two_args_or_anyz)GenerateSchema._get_first_two_args_or_any  s[    44S9:t9q=_F>vhgNOOAwQrw   c                l    d|v r|d   }| j                   |t        <   |S t        | j                   i|d<   |S )Nr   )r   rB   )r   r   r   s      ru   r  z-GenerateSchema._post_process_generated_schema  sL    j)HEIEjEjHAB
  =d>c>c"F: rw   c                    | j                   }d| _         | j                  }d| _        | j                  | j                  |            }| j                   xs || _         | j                  xs || _        |S )zJRecursively generate a pydantic-core schema for any supported python type.F)r   r   r  _generate_schema_inner)r   r   has_invalid_schemaneeds_apply_discriminated_unionr   s        ru   r  zGenerateSchema._generate_schema  ss    !55#( *.*O*O'05-44T5P5PQT5UV#'#;#;#Q?Q 040U0U0xYx-rw   c                   t        |t              r| j                  |      S t        |t              r|S t        |t              rt        |      }t        |t
              r | j                  | j                  |            S ddlm	} t        ||      r| j                  |      S t        |t              r t        j                  |j                        S | j!                  |      S )Nr+   r_   )
schema_ref)rp   _AnnotatedType_annotated_schemar   rY  r   r   ro  mainr`   r^   rS  rW   r!   r  type_ref
match_type)r   r   r`   s      ru   r~  z%GenerateSchema._generate_schema_inner  s    c>*))#..c4 Jc3S/Cc:&''(A(A#(FGG$c9-%%c**c/0::cllSSs##rw   c                   |t         u r| j                         S |t        u rt        j                         S |t
        u rt        j                         S |t        u rt        j                         S |t        u rt        j                         S |t        u s|t        u rt        j                         S ||t        j                  u rt        j                          S |t"        v r| j%                  |      S |t&        v r!| j)                  || j+                  |            S |t,        v r!| j/                  || j+                  |            S |t0        v r!| j3                  || j+                  |            S |t4        v r" | j6                  |g| j9                  |       S t;        |t<              r| j?                  |      S |t@        k(  r| jC                         S t        jD                  |      rt        jF                         S t        jH                  |      r| jK                  |      S tM        |      r| jO                  |d      S t        jP                  |      r| jS                  |d      S t        jT                  |      r| jW                  |jX                        S |tZ        j\                  k(  r| j_                  |      S |t`        jb                  jd                  u s|tf        jd                  u r| ji                         S t;        |tf        jj                        r| jm                  |      S to        |      r<|tp        u rt        j                         S | jW                  | j+                  |            S t;        |tr        tt        tv        tx        f      r| j{                  |      S t}        j~                  |      r3t        |t              r#ddlBmC}  ||| j                  j                        S t        j                  |      r| j                  |d      S | j                  |d      }||\  }}| j                  ||      S t        |      }|| j                  ||      S | j                  r| j                  |      S | j                  |      S )a  Main mapping of types to schemas.

        The general structure is a series of if statements starting with the simple cases
        (non-generic primitive types) and then handling generics and other more complex cases.

        Each case either generates a schema directly, calls into a public user-overridable method
        (like `GenerateSchema.tuple_variable_schema`) or calls into a private method that handles some
        boilerplate before calling into the user-facing method (e.g. `GenerateSchema._tuple_schema`).

        The idea is that we'll evolve this into adding more and more user facing methods over time
        as they get requested and we figure out what the right API for them is.
        Nr9   )get_enum_core_schemarV  )OrY  r   bytesr!   bytes_schemaint
int_schemafloatfloat_schemaboolbool_schemar   objectr   r=   NoneTypenone_schemari   _tuple_schemarj   r   rx  rk   r   rl   r   rm   r   r{  rp   r&   _type_alias_type_schemar   _type_schemais_callable_typecallable_schemais_literal_type_literal_schemar*   _typed_dict_schemais_namedtuple_namedtuple_schemais_new_typer   __supertype__rePattern_pattern_schemacollectionsabcHashabletyping_hashable_schemar   _unsubstituted_typevar_schemar]   r$   r   r   r   r   _callable_schemar   isclass
issubclassr   _std_types_schemar  r   config_dictis_dataclass_dataclass_schema0_get_prepare_pydantic_annotations_for_known_type_apply_annotationsr)   _match_generic_typer   r   r   )r   r   r  ressource_typer   rz  s          ru   r  zGenerateSchema.match_type  s    #:??$$E\++--CZ))++E\++--D[**,,CZ3&=))++[C=#9#99**,,K%%c**J$$S$*D*DS*IJJI##C)C)CC)HII$$))#t/I/I#/NOOJ$4$$SP4+J+J3+OPP]+//44D[$$&&++C0..00**3/'',,#**355((-**355&&s+''(9(9::BJJ'',,KOO,,,v0F((**V^^,55c::e|"--//''**3/  lJ
GLM((--__S!jd&;?'T-A-A-M-MNN%%c*))#t44CCCL?'*$K**;DDC++C88  ..s33((--rw   c                f   t        |t              r| j                  |      S t        j                  |      r| j                  ||      S t        j                  |      r| j                  ||      S | j                  ||      }||S t        j                  |      r| j                  |      S |t        v r| j                  |      S |t        v r!| j                  || j                  |            S |t         v r!| j#                  || j                  |            S |t$        v r!| j'                  || j                  |            S |t(        v r" | j*                  |g| j-                  |       S t/        |      r| j1                  ||      S |t2        j4                  t6        fv r| j9                  |      S |t2        j:                  t<        j>                  j:                  hv r| jA                  |      S |t2        jB                  t<        j>                  jB                  t2        jD                  t<        j>                  jD                  hv r| jG                  |      S |tH        jJ                  t2        jJ                  fv r| jM                  |      S | jN                  r| jQ                  |      S | jS                  |      S r   )*rp   r&   r  r=   r  r  r  r  r  origin_is_union_union_schemari   r  rj   r   rx  rk   r   rl   r   rm   r   r{  r*   r  r  r   r   _subclass_schemaSequencer  r  _sequence_schemar   	Generator_iterable_schemar  r  r  r   r   r   )r   r   rz  r  s       ru   r  z"GenerateSchema._match_generic_type   sR   fm,//44 %%f-))#v66&&v.**377;;FCH$  ((0%%c**{"%%c**z!$$S$*D*DS*IJJy ##C)C)CC)HII''))#t/I/I#/NOOz!$4$$SP4+J+J3+OPP&!**377T**((--)A)ABB((--)A)A6CSCSU`UdUdUnUnoo((--

FNN33'',,  ..v66((--rw   r#  c          	         | j                  |||      }t        j                  |d   |j                         sdn||d   |d   |d   |d         S )zAPrepare a TypedDictField to represent a model or typeddict field.r   Fserialization_excludevalidation_aliasserialization_aliasr   )r$  r  r  r  r   )r?  r!   typed_dict_fieldis_required)r   name
field_infor   r$  common_fields         ru   _generate_td_field_schemaz(GenerateSchema._generate_td_field_schemaL  sf     00z:N++"","8"8":U"./F"G)*<= ,-B C!*-
 	
rw   c           	         | j                  |||      }t        j                  |d   |d   |d   |d   |d   |d         S )z0Prepare a ModelField to represent a model field.r   r  r  r  frozenr   r  r  r  r  r   )r?  r!   model_fieldr   r  r  r   r  s        ru   rD  z(GenerateSchema._generate_md_field_schema_  s^     00z:N&&""./F"G)*<= ,-B C)!*-
 	
rw   c                    | j                  |||      }t        j                  ||d   |j                  xs d|j                  rdnd|d   |d   |d   |d   |d   		      S )
zJPrepare a DataclassField to represent the parameter/field, of a dataclass.r   NFr  r  r  r  r   )	init_onlykw_onlyr  r  r  r  r   )r?  r!   dataclass_fieldinit_varr  r  s        ru   _generate_dc_field_schemaz(GenerateSchema._generate_dc_field_schemap  s|     00z:N**" ))1T&..DE"./F"G)*<= ,-B C)!*-

 
	
rw   c                    t        j                  t        t        f      r j                  } j
                  r[|xs i j                         }|j                   j
                  j                         D ci c]  \  }}|j                  | c}}       t        j                  j                  |d       }|j                  urt        |t              s|_        j                  j                  }	}d fd}
 j                  j                  |      5  j                    j#                  ||	|
      }n j#                  ||	      }d d d        t%        |j&                  j)                         |      }t+        |      rd_        |D cg c]  }|j.                  j0                  du s| }}|D cg c]	  }||vs| }}t3        ||      }t5        |t%        ||      |      }t5        |t%        |j6                  j)                         |      |      }j9                         st;        |      } j=                  |t%        |j>                  j)                         |            }j@                  jB                  tE        jF                        dj                         D ci c]  \  }}|	|| c}}jH                  dfd}tK        |g      } jL                  jN                  }|rjjP                  jP                  dk  rO ||      }tS        |t              stU        d| d	|jV                         |_,        |_-        |_.        d_(        tS        jZ                  t^        t`        f      rjZ                  jc                         }njZ                  }te        |jf                  rdnd |j\                  jh                  |
      S c c}}w # 1 sw Y   xY wc c}w c c}w c c}}w )Nc                @    j                  | j                        } | S r   )r  r  )r   r  r   s    ru   r   z>GenerateSchema._common_field_schema.<locals>.set_discriminator  s     77
@X@XYFMrw   )transform_inner_schemaT)r   r   examplesc                    i  ||       }t        t              r|j                  t                     |S t	              r |       |S r   )rp   r   rZ  r"   callable)r   r   r   json_schema_extrajson_schema_updatess      ru   json_schema_update_funczDGenerateSchema._common_field_schema.<locals>.json_schema_update_func  sX    DWV_D0CDK+T2""#56G#HI  +,!+.rw   js_annotation_functionsr9   alias_generator  must return str, not r  r   r   rX  r   r   rC   r   r-   rX  r6   )5rY   
annotationr   rY  r   r   r   rZ  rC  r   r=   eval_type_lenientrW   r   r   r=  r  r  r   r6  r	  $_validators_require_validate_defaultvalidate_defaultrr   	each_itemr   r   r4  r  wrap_default_apply_field_serializersr5  r   r   r"   r  r  rA   r   alias_generatoralias_priorityrp   r   r   aliasr  r  r3   r4   convert_to_aliases_common_fieldexcluder  )r   r  r  r   r   rN  rO  	evaluatedr  r   r   r   this_field_validatorsr   r  r   r  r  r  r  r  s   ` `                @@ru   r?  z#GenerateSchema._common_field_schema  s   
 5 5
C7HI"33O!!#2#8b">">"@&&$BTBTBZBZB\']$!Q

A']^%77
8M8M`deI
 5 55>RS\^r>s(1
%#-#8#8*:M:M[	 ""''- 	''300kbs0t00		 !EZEZEZEaEaEcei j/0EF*.J'+@]aAFFDTDTX\D\]],A cqQNbEb c c+F4H$O!&*NOdfj*kmqr!89T9T9[9[9]_cdfj
 %%'!*f5F..89U9U9\9\9^`de
  %%%11*:+>+>?

 1D0I0I0K]1q}q!t]&88	 '@W?XY ..>>
 9 9 AZE^E^bcEc#D)EeS)"2?2CCYZ_ZiZiYj kll$J*/J'-2J*()J%j11L)3LM)::MMO)::*4*<*<$$- * > >$$
 	
c (^	 	   ^ c, ^s6   9O
4OO,,O,6	O1 O1)
O64O6O)c                ^   | j                  |d      }g }d}|D ]9  }||t        j                  u rd}|j                  | j	                  |             ; t        |      dk(  r|d   }t        |t              r|d   n|}nt        j                  |      }|rt        j                  |      }|S )zGenerate schema for a Union.Tr#  Fr9   r   )r<  r=   r  r  r   rc  rp   rt  r!   union_schemanullable_schema)r   
union_typeru  choicesr   argfirst_choicerW  s           ru   r  zGenerateSchema._union_schema  s    44Z$4O=? 	:C{c]%;%;;t33C89		: w<1"1:L#-lE#BQA((1A++A.Arw   c                   t        |      }|xs |}| j                  j                  |      5 \  }}||cd d d        S | j                  xs i j	                         }i t        j                  |      |}|j                  }|| _        t        |      }t        ||      }| j                  |      }	|	d   dk7  sJ ||	d<   |xs d | _        |	| j                  j                  |<   t        j                  |      cd d d        S # 1 sw Y   y xY w)Nr   r  r   )r)   r   r1  r   r   r=   get_cls_types_namespace	__value__rX   r[   r   r  r!   r  )
r   r   rz  r   rJ  	namespacenew_namespacer  r   r   s
             ru   r  z&GenerateSchema._type_alias_type_schema  s    C3YY((0 	@4GS,'#	@ 	@ ..4"::<IZ}DDVLZPYZM))J$1D!4S9L&z<@J))*5F&>]22F5M$-$5D!)/DII!!#&::3?!	@ 	@ 	@s   DB9DD
c                n    t        j                  |      }|s
J d|        t        j                  |      S )zGenerate schema for a Literal.z(literal "expected" cannot be empty, obj=)r=   all_literal_valuesr!   literal_schema)r   literal_typeexpecteds      ru   r  zGenerateSchema._literal_schema  s6     33LARCL>RR))(33rw   c                   | j                   j                  |      5 \  }}||cddd       S t        |      }||}t        s%t	        |      j
                  dk(  rt        dd      	 t        |d      }| j                  j                  |      5  | j                  j                  |      }| j                  } |j                  }i }	t        j                   |      }
t#        || j$                  d      j'                         D ]  \  }}t)        ||      }||v }t+        |      t,        j.                  k(  rd}| j1                  |d	      d
   }n4t+        |      t,        j2                  k(  rd}| j1                  |d	      d
   }t5        j6                  |      }| j9                  |||
|	      |	|<    t;        t=        t>        |      g|      }tA        jB                  |	|
jD                  jG                         D cg c]  }| jI                  ||
jJ                          c}|||      }| jM                  ||
jN                  jG                               }tQ        ||
jR                  jG                         d      }| jU                  |      | j                   jV                  |<   tA        jX                  |      cddd       cddd       S # t        $ r d}Y ]w xY wc c}w # 1 sw Y   nxY w	 ddd       y# 1 sw Y   yxY w)a  Generate schema for a TypedDict.

        It is not possible to track required/optional keys in TypedDict without __required_keys__
        since TypedDict.__new__ erases the base classes (it replaces them with just `dict`)
        and thus we can track usage of total=True/False
        __required_keys__ was added in Python 3.9
        (https://github.com/miss-islington/cpython/blob/1e9939657dd1f8eb9f596f77c1084d2d351172fc/Doc/library/typing.rst?plain=1#L1546-L1548)
        however it is buggy
        (https://github.com/python/typing_extensions/blob/ac52ac5f2cb0e00e7988bae1e2a1b8257ac88d6d/src/typing_extensions.py#L657-L666).

        On 3.11 but < 3.12 TypedDict does not preserve inheritance information.

        Hence to avoid creating validators that do not do what users expect we only
        support typing.TypedDict on Python >= 3.12 or typing_extension.TypedDict on all versions
        Nr  zXPlease use `typing_extensions.TypedDict` instead of `typing.TypedDict` on Python < 3.12.ztyped-dict-versionrz   __pydantic_config__T)localnsinclude_extrasr#  r   Fr  )r  typed_dict_cls)r-  r   r   r,  all)-r   r1  rX   _SUPPORTS_TYPEDDICTr   
__module__r2   rQ   AttributeErrorr   r=  r   r9  r   __required_keys__rJ   buildrV   r   rC  r[   r)   r=   Requiredr<  NotRequiredr5   from_annotationr  rA   r   r   r!   typed_dict_schemar-  r	  rE  r5  rG  rH  r@  r:  r  r  r  )r   r  rz  typed_dict_refrJ  r   r,  r9  required_keysrq   r   r   r  r$  r  r   rP  	td_schemar   s                      ru   r  z!GenerateSchema._typed_dict_schema  s)     YY((8 H	O<Z^\'#H	O H	O 5^DL!!'&4+?+J+Jh+V'n- 
,D^Uj,k ++008 5O"22>>~N440>0P0P@B+11.A
.K"D,A,ARV/%'*J
 "/z<!HJ)]:H!*-1G1GG#'%)%J%J&%) &K & &
 $J/=3L3LL#(%)%J%J&%) &K & &

 "+!:!::!FJ)-)G)G"J
X *H *F:&)0 /")*B"W!Xiw (99 ",!;!;!B!B!D% 33Az7S7ST% '%&		 66y*B^B^BeBeBgh/
8S8S8Z8Z8\^cd8<8[8[\b8c		%%n5">>~Nk5O 5O'H	O H	O  " X%S5O 5O 5O'H	O H	O H	Os`   K0:K0(K4K0E(K7#KBK0	K0KK0KK0KK#	K00K9c                   | j                   j                  |      5 \  }}||cddd       S t        |      }||}t        |d| j                        }|s|j
                  D ci c]	  }|t         }}|r-|j                         D 	ci c]  \  }}	|t        |	|       }}}	t        j                  |j                         D 	cg c]A  \  }}	| j                  ||	|j                  j                  |t        j                              C c}	}t!        d            }
t        j"                  |
||      cddd       S c c}w c c}	}w c c}	}w # 1 sw Y   yxY w)z!Generate schema for a NamedTuple.NT)r  r  )default)js_prefer_positional_arguments)r   )r   )r   r1  rX   rV   r   _fieldsr   rC  r[   r!   arguments_schema_generate_parameter_schema_field_defaultsr   r	   emptyrA   call_schema)r   namedtuple_clsrz  namedtuple_refrJ  r   r   rN  r   r  r  s              ru   r  z!GenerateSchema._namedtuple_schemar  sv   YY((8 	a<Z^\'#	a 	a 5^DL!!'*GtT=R=R+K /=/E/EF!q#vFF 3>2C2C2E.
J j, GG 
  +;;
 3>2C2C2E	 /
J 33"J8V8V8Z8Z[egpgvgv8w 4  -DQ  **+;^Q_`;	a 	a G+	a 	as;   E7E$E 2E	E %EAE+E EEc                N   |t         j                  u rt        j                  |      }nt        j                  ||      }|j
                  J d       |j
                  |j                  }}| j                  j                  |      5  | j                  ||      }ddd       |j                         st        |      }t        j                  |      }	|||	d<   |j                  |j                  |	d<   |	S | j                  j                   }
|
r |
|      |	d<   |	S # 1 sw Y   xY w)zXPrepare a ArgumentsParameter to represent a field in a namedtuple or function signature.Nz<field.annotation should not be None when generating a schemamoder  )r	   r  r5   r  from_annotated_attributer  r   r   r=  r  r  r  r!   arguments_parameterr  r   r  )r   r  r  r  r   rs   r  r   r   parameter_schemar  s              ru   r  z)GenerateSchema._generate_parameter_schema  s$    ioo%--j9E66z7KE+k-kk#(#3#3U^^[""''- 	G,,[+FF	G   "!%0F&::4H'+V$;;"(-W%
   #22BBO,;D,A )	G 	Gs   DD$c                   t        |      | j                  |      }r|rt        fd|D              }|s1|t        v rt	        j
                         S t	        j                  g       S |d   t        u r.t        |      dk(  r| j                  ||d         S t        d      t        |      dk(  r|d   dk(  r| j                  |g       S | j                  |t        |            S )zIGenerate schema for a Tuple, e.g. `tuple[int, str]` or `tuple[int, ...]`.c              3  6   K   | ]  }t        |        y wr   )r[   ).0paramr   s     ru   	<genexpr>z/GenerateSchema._tuple_schema.<locals>.<genexpr>  s     R%==Rs   r   r+   r   z&Variable tuples can only have one typer9   rV  )rX   r<  rt  ri   r!   r   r   Ellipsisrc  r   
ValueErrorr   r  )r   
tuple_typeparamsr   s      @ru   r  zGenerateSchema._tuple_schema  s     1<66zBFR6RRF [("88:: #::2>>BZ8#6{a22:vayII !!IJJ[A&)r/ 00R@@00T&\JJrw   c                `    t        j                  t        j                  t              dd      S )Nis_typezInput should be a typecustom_error_typecustom_error_message)r!   custom_error_schemar   r   r   s    ru   r  zGenerateSchema._type_schema  s)    ..**40'!9
 	
rw   c           	        | j                  |      }|t        k(  r| j                         S t        |t        j
                        r|j                  rt        j                  |j                        S |j                  rMt        j                  |j                  D cg c]$  }| j                  t        j                  |         & c}      S | j                         S t        j                  t        |            rV| j!                  |d      }t        j                  |D cg c]$  }| j                  t        j                  |         & c}      S t        j                  |      S c c}w c c}w )z-Generate schema for a Type, e.g. `Type[int]`.Tr#  )rx  r   r  rp   r  r   	__bound__r!   is_subclass_schema__constraints__r  r   r   r=   r  r)   r<  )r   type_
type_paramcru  s        ru   r  zGenerateSchema._subclass_schema  s"   //6
$$&&
FNN3##"55j6J6JKK++"//CMC]C]^aT))&++a.9^  ((****:j+AB88d8SD++ae,fY]T-A-A&++dBS-T,fgg11*== _ -gs   )E")E'c                X   | j                  |      }t        j                  | j                  |            }t        j                  t
        j                  d      }|t        k7  r1ddlm	} t        j                  |t        j                  ||      g      }t        j                  ||      S )z5Generate schema for a Sequence, e.g. `Sequence[int]`.r  )cls_reprr9   )sequence_validator)r   python_schema)rx  r!   r   r   r   r  r  r   _validatorsr<  ra  no_info_wrap_validator_functionjson_or_python_schema)r   sequence_type	item_typer   r=  r<  s         ru   r  zGenerateSchema._sequence_schema  s    ..}=	!--d.B.B9.MN#66vQ[\7'44 K KL^`k lmM 00[Xeffrw   c                l    | j                  |      }t        j                  | j                  |            S )z$Generate a schema for an `Iterable`.)rx  r!   generator_schemar   )r   r7  rB  s      ru   r  zGenerateSchema._iterable_schema  s.    ..u5	++D,@,@,KLLrw   c                   ddl m} t        d g      }t        j                  t        d      dt        j                               }|t        j                  k(  s|t        j                  k(  r"t        j                  |j                  ||      S | j                  |d	
      d   }|t        k(  r"t        j                  |j                  ||      S |t        k(  r"t        j                  |j                   ||      S t#        d|d      )Nr9   )r>  c                    dddS )Nstringregex)r   formatrV  )_1_2s     ru   <lambda>z0GenerateSchema._pattern_schema.<locals>.<lambda>  s    XahDi rw   r  patternr   )r   return_schema)r   r   Tr#  r   r   ry   ) r>  rA   r!   r   r   r   r  r  r   no_info_plain_validator_functionpattern_either_validatorr<  rY  pattern_str_validatorr  pattern_bytes_validatorr0   )r   pattern_typer>  r   serr'  s         ru   r  zGenerateSchema._pattern_schema  s   !&5i4jk>>y!V;CYCYC[
 6>>)\RZZ-G??44CRZ  55 6 
  C<??11x  e^??333QY  02^_k^nno0pqqrw   c                    t        j                  t        j                  t        j                  j
                        dd      S )Nis_hashablezInput should be hashabler/  )r!   r2  r   r  r  r  r   s    ru   r  zGenerateSchema._hashable_schema  s3    ..**;??+C+CD+!;
 	
rw   c                *     j                   j                  |      5 \  }}||cddd       S t        |      }||}t        |dd      } j                  j                  |      5   j                  j                  |      } j                   ddl	m
}  ||      rIt        |j                        }	|rJ|	j                         D ]  }
|
j                  | j                           nt!        | j                  |      }	|j"                  j%                  d      xs t'        j(                  |      t+         fd|	j-                         D        d 	      }t/        |d
      }t/        |d      }t1        j2                  |j4                  |j6                  j                         D cg c]  } j9                  |j:                          c}|      }t=        |j>                  j                         d      }j@                  j                         }tC        ||d      }t1        jD                  ||||t        jF                  |      D 
cg c]  }
|
jH                   c}
||      } jK                  |jL                  j                               }tC        ||d      } jO                  |       j                   jP                  |<   t1        jR                  |      cddd       cddd       S c c}w c c}
w # 1 sw Y   nxY w	 ddd       y# 1 sw Y   yxY w)z Generate schema for a dataclass.Nr  r+   )is_pydantic_dataclass)r   r3  c              3  J   K   | ]  \  }}j                  ||        y wr   )r  )r&  rN  rO  r   r   s      ru   r(  z3GenerateSchema._dataclass_schema.<locals>.<genexpr>E  s$     a$!QT33Aq*Eas    #c                (    | j                  d      duS )Nr  Fr   )rv  s    ru   rL  z2GenerateSchema._dataclass_schema.<locals>.<lambda>F  s    !%%	"2%"? rw   )key__post_init__	__slots__)r-  collect_init_onlyr&  )r+  r   rq   slotsr,  r0  )*r   r1  rX   r   r   r=  r   r9  r   dataclassesrY  r   __pydantic_fields__r	  apply_typevars_mapr   rU   __dict__r   rJ   r  sortedrC  hasattrr!   dataclass_args_schemar   r-  rE  r5  r   rF  r:  r@  dataclass_schemarq   r  rG  rH  r  r  r  )r   	dataclassrz  dataclass_refrJ  r   r,  r9  rY  rq   rs   ru  has_post_init	has_slotsrP  args_schemar   r:  	dc_schemar   r   s   `                   @ru   r  z GenerateSchema._dataclass_schema"  s    YY((3 @	N7T|'#@	N @	N 5Y?L!"	Y(=tDF++008 7N"22>>yI44?(3%i&C&CDF#%+]]_ ZE!44\4CXCXYZ 6!--%1F
 '//334MNqR`RfRfgpRq
 aRXR^R^R`a? !(	? C#I{;	)??&& ",!;!;!B!B!D% 33Az7S7ST% '4  0Z=W=W=^=^=`bfg#-#>#>#E#E#G 5lDTV]^'88 +%4?4F4Fy4QR5EJJR#&	 66y*B^B^BeBeBgh/8H'R7;7Z7Z[a7b		%%m4">>}Mo7N 7N@	N @	NP%" Sa7N 7N 7N@	N @	N @	NsI   L	7L	&D>K3$#K)A?K3K.A=K3	L	)
K33K<	8L		Lc                   t        |      }t        j                  |      }t        j                  dt        j
                  dt        j                  di}g }d}d}|j                  j                         D ]  \  }}	|	j                  |j                  u rt        }
n||   }
|j                  |	j                        }|0| j                  ||
|	j                  |      }|j!                  |       w|	j                  t        j"                  k(  r| j%                  |
      }|	j                  t        j&                  k(  sJ |	j                         | j%                  |
      } d}| j(                  }|j*                  r$|j                  d      }|| j%                  |      }t-        j.                  t-        j0                  ||||j2                        ||      S )zsGenerate schema for a Callable.

        TODO support functional validators once we support them in Config
        positional_onlypositional_or_keywordkeyword_onlyNrX  )var_args_schemavar_kwargs_schemapopulate_by_name)rN  )r   r=   get_function_type_hintsr	   POSITIONAL_ONLYPOSITIONAL_OR_KEYWORDKEYWORD_ONLYrd  rC  r  r  r   r   kindr  r  r  VAR_POSITIONALr   VAR_KEYWORDr   validate_returnr!   r  r  rv  )r   functionsig
type_hintsmode_lookuparguments_listrt  ru  r  pr  parameter_mode
arg_schemarN  r   return_hints                   ru   r  zGenerateSchema._callable_schemah  s   
 !"::8D
 %%'8++-D""Nr
 @B9=;?~~++- 	EGD!||syy( 
'-
(__QVV4N)!<<T:qyyZhi
%%j19333"&"6"6z"Bvv!6!66>>$($8$8$D!	E  8<--))$..2K& $ 4 4[ A&&(( /"3!/!@!@	 '	
 		
rw   c                   t        |t        j                        sJ |j                  }|j                  }t               }t        |d|      }|d ut        |      dk7  z   ||uz   dkD  rt        d      ||ur| j                  |      S |r"| j                  t        j                  |         S |r@| j                  |      }t        j                  d t        j                               |d<   |S t        j                         S )N__default__r   r9   zZPydantic does not support mixing more than one of TypeVar bounds, constraints and defaultsc                     ||       S r   rV  )xhs     ru   rL  z>GenerateSchema._unsubstituted_typevar_schema.<locals>.<lambda>  s
    QqT rw   )r   r   )rp   r  r   r4  r6  r  r   rc  NotImplementedErrorr   r  r   r!   #wrap_serializer_function_ser_schemar   )r   typevarrh   constraintsnot_setr  r   s          ru   r  z,GenerateSchema._unsubstituted_typevar_schema  s    '6>>22!!--('=':#k"2a"78G7<RSVWW%l  '!''00%%fll;&?@@))%0F&1&U&U!+*@*@*B'F?# M))++rw   c                   	 t        j                  j                  j                  j                  | j
                        }|t        u rt        dd      t        || j                        }| j                  |      }| j                  |t        |j!                         j"                        d      }| j$                  j&                  }|rj                  j(                  j                  j(                  dk  r_ |j"                        }t+        |t,              st/        d| d|j0                         |j                  _        dj                  _        dfd	}t5        |g
      }	t7        j8                  j"                  |j                  j2                  |	      S # t        $ r}t        j                  |      |d }~ww xY w)NzComputed field is missing return type annotation or specifying `return_type` to the `@computed_field` decorator (e.g. `@computed_field(return_type=int|str)`)zmodel-field-missing-annotationrz   Tcomputed_fieldr9   r  r  c                     ||       }d|d<   j                   j                  }|||d<   j                   j                  }|||d<   |S )NTreadOnlyr   r   )rr   r   r   )r   r   r   r   r   rP  s        ru   set_computed_field_metadatazJGenerateSchema._computed_field_schema.<locals>.set_computed_field_metadata  sX    !&/K&*K
#FFLLE ',G$&&,,K&-8M*rw   r  )rN  r  r   r  )r:   get_function_return_typefuncrr   return_typer   rk  r1   rl  r    r2   r[   r   r   r  r   r	  r   r   r  r  rp   rY  r   r   r  rA   r!   r  )
r   rP  r5  r  rn  return_type_schemar  r  r  r   s
    `        ru   rE  z%GenerateSchema._computed_field_schema  s   
	H%>>qvvqvvGYGY[_[p[pqK ++#d5  $K1C1CD!11+>!::01B1I1I1KQ^^\ ; 
 ..>> 5 5 =AVAVZ[A[#ANN3EeS)"2?2CCYZ_ZiZiYj kll AFFL$%AFF!	 '@[?\]))NN*<AFFLL[c
 	
Y  	H-==a@aG	Hs   ?F$ $	G-GGc                    | j                  |d      ^}}| j                  ||      }|D ]  }t        |t              st	        ||      }! |S )zdGenerate schema for an Annotated type, e.g. `Annotated[int, Field(...)]` or `Annotated[int, Gt(0)]`.Tr#  )r<  r  rp   r5   r  )r   annotated_typer  r   r   r  s         ru   r  z GenerateSchema._annotated_schema  se    $($I$I %J %
!k ((kB & 	:J*i0%j&9	: rw   c                    ddl m} 	 t        |       |D ]&  } |||| j                  j
                        }|$|c S  y # t        $ r Y y w xY w)Nr9   )PREPARE_METHODS)r  r  hashr   r   r  )r   r   r   r  genr  s         ru   r  z?GenerateSchema._get_prepare_pydantic_annotations_for_known_type  sa     	7	I
 # 	Cc;(<(<(H(HIC
	
   		s   ? 	A
Ac                    | S r   rV  )r  s    ru   rL  zGenerateSchema.<lambda>  s    q rw   c                    t        t        j                  |            } j                  |t	        |            }||\  }}g }d fd}t        |       }|D ]  }| j                  |||      }  ||      }	|r6t        |	      j                  }
|
j                  dg       j                  |       t         j                  j                  ||	      S )a  Apply arguments from `Annotated` or from `FieldInfo` to a schema.

        This gets called by `GenerateSchema._annotated_schema` but differs from it in that it does
        not expect `source_type` to be an `Annotated` object, it expects it to be  the first argument of that
        (in other words, `GenerateSchema._annotated_schema` just unpacks `Annotated`, this process it).
        c                    j                  | |       }|j                  |       }n|}t        | |      }|4t        |j                  j
                        }|j                  ||        |      S r   )r  r  r  r  r   r  r  )r   r  r   r  r  r   r  s        ru   inner_handlerz8GenerateSchema._apply_annotations.<locals>.inner_handler"  s{     ??SIM$..s3&#DS&#Q #/"9&$))BWBW"X".))/;OP)&11rw    pydantic_js_annotation_functionsr   r   rX  r   )r  r<   expand_grouped_metadatar  rt  r\   _get_wrapped_inner_schemar@   r   r  extendr   r   r   )r   r  r   r  r  r  r  get_inner_schemar  r   r   s   `  `       ru   r  z!GenerateSchema._apply_annotations  s     4LL[YZCCKQVWbQcd?'*$KHJ(	2 8tL% 	J!#== *.N 	 "+.+*62;;H BBGNNOop;D<P<P<^<^`kmsttrw   c                   t        |t              rM|j                  D ]  }| j                  ||      } |j                  | j                  ||j                        }|S |d   dk(  r?|j                  dt        j                               }| j                  ||      }|r||d<   |S |}|j                  dd       }|X|j                         }|dt        |       z   }|| j                  j                  v r| j                  j                  |   S ||d<   n|d   dk(  r|d   }|| j                  j                  v rn| j                  j                  |   j                         }|dt        |       z   }|| j                  j                  v r| j                  j                  |   S ||d<   t        j                  ||j                               }||S |S )Nr   r   r   r   rf  definition-refr  )rp   r5   r   _apply_single_annotationr  r  r   r!   r   r   reprr   r  r<   apply_known_metadata)	r   r   r   field_metadatar&  r   r   new_refmaybe_updated_schemas	            ru   r  z'GenerateSchema._apply_single_annotation>  s   h	*"*"3"3 O66v~NO %%1;;FHDZDZ[M&>Z'JJx)?)?)ABE11%BE#(x M jj%?[[]FaX/00G$))///yy,,W55#F5MF^//&Cdii+++..s388:!DN#3 44dii333990099 'u8MMhX^XcXcXef+''rw   c                   t        |t              r|j                  D ]  }| j                  ||      } i |j                  r|j                  d<   |j
                  r|j
                  d<   |j                  rt        |j                        d<   |j                  srA	 	 	 	 	 	 dfd}t        |      j                  j                  dg       j                  |       |S )Nr   r   r  c                     ||       }|j                         t        t              r|j                  t                     |S t	              r |       |S r   )rZ  rp   r   r"   r  )r!   r   r   r  json_schema_updates      ru   r  zTGenerateSchema._apply_single_annotation_json_schema.<locals>.json_schema_update_funcw  s_     #*+"6K&&'9:!"3T:#**+=>O+PQ '& ""34)+6&&rw   r  )r!   rC   r   r-   rX  r6   )rp   r5   r   $_apply_single_annotation_json_schemar   r   r  r"   r  r@   r  r  )r   r   r   r  r  r  r  s        @@ru   r  z3GenerateSchema._apply_single_annotation_json_schemaf  s     h	*"*"3"3 [BB6>Z[24~~.6nn"7+##4<4H4H"=1  1CHDUDU1V":. ( : :!%6	'!2	'=Q	'$	' $F+44??@bdfgnn+ rw   c                \     t        dd       xs d d fd}t        |       S )Nr^  c                     ||       S r   rV  )re  r   s     ru   rL  z:GenerateSchema._get_wrapped_inner_schema.<locals>.<lambda>  s
    GFO rw   c                     |       }j                  |      }j                  |      }t        |      }|j                  |       |S r   )r  r  r  r  )re  r   r  r  r  metadata_get_schemar  r   s      ru   new_handlerz=GenerateSchema._get_wrapped_inner_schema.<locals>.new_handler  s\    (1ABF226:FF>>vzRF#DZQW#X #/0778LMMrw   )re  r   rX  core_schema.CoreSchema)r   r\   )r   r  r  r  r  r  s   ```` @ru   r  z(GenerateSchema._get_wrapped_inner_schema  s9     6=ZIgim5n 6
3 		 	 ,K>>rw   c                   |rt        |      }|d   dk(  r|d   }| j                  ||      |d<   |S t        j                  d|j	                  dd            }|t        j                  |      }|d   }t        |j                  |j                  j                  |      \  }}	 t        j                  |j                  |j                  j                  | j                        }	|	t$        u rd}n| j'                  |	      }|j                  j                  d	k(  r=t        j(                  |j                  ||||j                  j*                  
      |d<   |S |j                  j                  dk(  sJ t        j,                  |j                  ||||j                  j*                  
      |d<   |S # t        $ r}
t!        j"                  |
      |
d}
~
ww xY w)z$Apply field serializers to a schema.r   r  r   zstr|Noner   Nr   r  wrap)is_field_serializerinfo_argrN  r   r   plain)r   r  r  r   r   r!   r  rR   r  rr   r   r:   r  r  r   rk  r1   rl  r    r   r  r   r   )r   r   serializersr  r   r   
serializerr  r  r  rn  rN  s               ru   r  z'GenerateSchema._apply_field_serializers  s    &\Ff~.%h/#'#@#@{#[x kk*fjj.EF?(DDSIF %RJ,D!5!5n-)L)BBOOZ__%@%@$BWBW // $ $ 4 4[ A##v-*5*Y*YOO(;%"/(oo77+'   "++w66*5*Z*ZOO(;%"/(oo77+' 3  L1AA!D!KLs   %?F. .	G7GGc                   |j                  dd      }|r!t        |      d   }t        |j                  |j                  j
                        }	 t        j                  |j                  |j                  j                  | j                        }|t        u rd}n| j                  |      }|j                  j
                  dk(  r8t        j                   |j                  |||j                  j"                        }	n7t        j$                  |j                  |||j                  j"                        }	|	|d<   |r||d<   |S # t        $ r}t        j                  |      |d}~ww xY w)z$Apply model serializers to a schema.r   Nr   r  )r  rN  r   r   )popr  rS   r  rr   r   r:   r  r  r   rk  r1   rl  r    r   r!   r  r   r   )
r   r   r  r   r  r  r  rn  rN  
ser_schemas
             ru   rG  z'GenerateSchema._apply_model_serializers  s=    !**UD1k*2.J/
AUAUVHL)BBOOZ__%@%@$BWBW
 // $ $ 4 4[ A##v-4?4c4cOO%"/(oo77	5
 )MMOO%"/(oo77	
 '1F?#F5M3  L1AA!D!KLs   ?E   	E$	EE$r   )r   r>   r   dict[str, Any] | Noner   dict[Any, Any] | NonerX  None)
r   r?   r   r  r   r  r   r   rX  r   )rX  r>   )rX  r   )rX  r  )rX  r   )r   r   r   r   rX  r   )r   r   r   r   r   r   rX  r   )r   r   r   	list[Any]rX  r   )r   r   rX  r   r  )r   r   r  r   rX  r   r  )r  r   r  Callable[..., Any]rX  r  )T)r   r   r  r  rX  r  )r   ztype[BaseModel]rX  r  )r   r   re  r   rX  zcore_schema.CoreSchema | None)r   r   rX  r   )r   r   r$  zLiteral[True]rX  tuple[Any, ...])r   r   rX  tuple[Any, ...] | None)F)r   r   r$  r  rX  r  )r   r   rX  ztuple[Any, Any])r   r  rX  r  )r   r   rX  r  )r   r   rz  r   rX  r   )
r  rY  r  r5   r   rJ   r$  r  rX  zcore_schema.TypedDictField)r  rY  r  r5   r   rJ   rX  zcore_schema.ModelField)r  rY  r  r5   r   rJ   rX  zcore_schema.DataclassField)r  rY  r  r5   r   rJ   rX  _CommonField)r  r   rX  r  )r   r   rX  r   )r  r   rz  r   rX  r  )r  r   rz  r   rX  r  )
r  rY  r  z	type[Any]r  r   r   zJLiteral['positional_only', 'positional_or_keyword', 'keyword_only'] | NonerX  zcore_schema.ArgumentsParameter)r+  r   rX  r  )rX  r  )r7  r   rX  r  )rA  r   rX  r  )r7  r   rX  zcore_schema.GeneratorSchema)rT  r   rX  r  )rj  ztype[StandardDataclass]rz  ztype[StandardDataclass] | NonerX  r  )r  r  rX  zcore_schema.CallSchema)r  ztyping.TypeVarrX  r  )rP  zDecorator[ComputedFieldInfo]r5  z2dict[str, Decorator[FieldSerializerDecoratorInfo]]rX  zcore_schema.ComputedField)r  r   rX  r  )r   r   r   r  rX  ztuple[Any, list[Any]] | None)r  r   r   r  r  z"Callable[[CoreSchema], CoreSchema]rX  r   )r   r  r   r   rX  r  )r  r,   r  r   r  zlist[GetJsonSchemaFunction]rX  r\   )r   r  r  z-list[Decorator[FieldSerializerDecoratorInfo]]r  r  rX  r  )r   r  r  z1Iterable[Decorator[ModelSerializerDecoratorInfo]]rX  r  )Er   r	  __qualname__r   r_  r   classmethodr   propertyr   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r   rS  r[  r  ro  r   r<  rx  r{  r  r  r~  r  r  r  rD  r  r?  r  r  r  r  r  r	   r  r  r  r  r  r  r  r  r  r  r  r  rE  r  r  r  r  r  r  r  rG  rV  rw   ru   r   r     s   fI /3	#%# /# ,	#
 
# 0 / ,	
  
 " / / 
 
 < <(IkHNSB
2	
&	
	6 -1// &*/ 
 	/bWJr-^,     	$0U.n*.d 

 
 #	
 
 
$
&

 
 #	

 
 
"

 
 #	

 
$
(_
B*@@ 
@04XOtaJ ![_     	 
 Y  
( >K<
>(gMr8
DN0DN:XDN	DNL3
j,45
'5
 N5
 
#	5
n%4	%. FQ	-u-u -u !C	-u
 
-u^&P,8;	B?.? ? +F	?
 
&?4  %	5&5 C5 	5
 
 5n&,&;l&	&rw   r   c                .    t        j                  | |      S r   )r!   !no_info_before_validator_functionfr   rf  s      ru   rL  rL    s    0]0]^_ag0h rw   c                .    t        j                  | |      S r   )r!    no_info_after_validator_functionr  s      ru   rL  rL    s    {/[/[\]_e/f rw   c                ,    t        j                  |       S r   )r!   rP  )r  rJ  rK  s      ru   rL  rL    s    K,X,XYZ,[ rw   c                .    t        j                  | |      S r   )r!   r?  r  s      ru   rL  rL    s    k.Y.YZ[]c.d rw   c                2    t        j                  | ||      S N)r   )r!   #with_info_before_validator_functionr  r   r   s      ru   rL  rL    s    ;;j;j	6j< rw   c                2    t        j                  | ||      S r  )r!   "with_info_after_validator_functionr  s      ru   rL  rL    s    +:h:h	6j; rw   c                0    t        j                  | |      S r  )r!   rb  )r  rf  r   s      ru   rL  rL    s    [5c5c	j6 rw   c                2    t        j                  | ||      S r  )r!   !with_info_wrap_validator_functionr  s      ru   rL  rL    s    9f9f	6j: rw   ))beforeno-info)afterr  )r  r  )r  r  )r  	with-info)r  r  )r  r  )r  r  zMapping[tuple[FieldValidatorModes, Literal['no-info', 'with-info']], Callable[[Callable[..., Any], core_schema.CoreSchema, str | None], core_schema.CoreSchema]]_VALIDATOR_F_MATCHc                    |D ]b  }t        |j                  |j                  j                        }|rdnd}t	        |j                  j                  |f   |j                  | |      } d | S )a  Apply validators to a schema.

    Args:
        schema: The schema to apply validators on.
        validators: An iterable of validators.
        field_name: The name of the field if validators are being applied to a model field.

    Returns:
        The updated schema.
    r  r  )rT   r  rr   r   r  )r   r6  r   	validatorr  val_types         ru   r   r     sg    "   i	$Y^^Y^^5H5HI"*;	#Y^^%8%8($CDY^^U[]gh	i
 Mrw   c                B    | D ]  }|j                   j                  s y y)a?  In v1, if any of the validators for a field had `always=True`, the default value would be validated.

    This serves as an auxiliary function for re-implementing that logic, by looping over a provided
    collection of (v1-style) ValidatorDecoratorInfo's and checking if any of them have `always=True`.

    We should be able to drop this function and the associated logic calling it once we drop support
    for v1-style validator decorators. (Or we can extend it and keep it if we add something equivalent
    to the v1-validator `always` kwarg to `field_validator`.)
    TF)rr   always)r6  r  s     ru   r  r  -  s(       	>>   rw   c                \   | j                  dd      }|D ]  }|dk(  r|j                  j                  dk7  r#|dk(  r|j                  j                  dk(  rBt        |j                  |j                  j                        }|j                  j                  dk(  rF|r"t        j                  |j                  |       } t        j                  |j                  |       } |j                  j                  dk(  rH|r#t        j                  |j                  |       } 	t        j                  |j                  |       } ,|j                  j                  dk(  sJ |r#t        j                  |j                  |       } lt        j                  |j                  |       }  |r|| d<   | S )	a  Apply model validators to a schema.

    If mode == 'inner', only "before" validators are applied
    If mode == 'outer', validators other than "before" are applied
    If mode == 'all', all validators are applied

    Args:
        schema: The schema to apply validators on.
        validators: An iterable of validators.
        mode: The validator mode.

    Returns:
        The updated schema.
    r   Nr&  r  r0  r  )r  r   r  )r  rr   r   rT   r  r!   r  r?  r  r  r  r  )r   r6  r   r   r  r  s         ru   r@  r@  =  s`   & jj-C n	7?y~~22h>7?y~~22h>$Y^^Y^^5H5HI>>&($FFPYP^P^gmn$DDinnekl^^  H,$HHR[R`R`iop$FFPYP^P^gmn>>&&'11$GGQZQ_Q_hno$EEy~~flm+n, uMrw   c                    | j                   r,t        j                  || j                   | j                        S | j                  t
        ur,t        j                  || j                  | j                        S |S )a  Wrap schema with default schema if default value or `default_factory` are available.

    Args:
        field_info: The field info object.
        schema: The schema to apply default on.

    Returns:
        Updated schema by default value or `default_factory`.
    )default_factoryr  )r  r  )r  r!   with_default_schemar  r  r    )r  r   s     ru   r  r  l  sr     !!..J$>$>Q[QlQl
 	
 
		#4	4..J..A\A\
 	
 rw   c                F   t        | dd      }t        | d      r@ddlm} |duxr% |j                  j
                  |t        |dd      fv}|st        dd	      t        | d
      r8t        | t        t        t        df               st        | j                  |      S |y|S )z`Extract `__get_pydantic_json_schema__` from a type, handling the deprecated `__modify_schema__`.__get_pydantic_json_schema__N__modify_schema__r   r_   __func__zkThe `__modify_schema__` method is not supported in Pydantic v2. Use `__get_pydantic_json_schema__` instead.zcustom-json-schemarz   
__origin__placeholder)r   rg  pydanticr`   r  r  r2   rp   r   r#   r  r  r  )r   r   js_modify_functionr`   has_custom_v2_modify_js_funcs        ru   r  r    s     %CTJr&'& d* W66??&0BJPT(UVW 	% ,#>)  r< BYsMGY=Z8[)\0GG!rw   c                  J    e Zd ZU ded<   ded<   ded<   ded<   ded	<   d
ed<   y)r  r  r   4str | list[str | int] | list[list[str | int]] | Noner  r  r  bool | Noner  r  zdict[str, Any]r   N)r   r	  r  r;  rV  rw   ru   r  r    s&    ""JJ##&&rw   r  )r  r  r  r  r   c                   | |||||dS )Nr   r  r  r  r  r   rV  r  s         ru   r  r    s      ,2!6 rw   c                  *    e Zd ZdZddZedd       Zy)r   z*Keeps track of references and definitions.c                0    t               | _        i | _        y r   )r|   seenr  r   s    ru   r   z_Definitions.__init__  s    !e	>@rw   c              #  H  K   t        |      }|| j                  v s|| j                  v r|t        j                  |      f y| j                  j                  |       	 |df | j                  j                  |       y# | j                  j                  |       w xY ww)ao  Get a definition for `tp` if one exists.

        If a definition exists, a tuple of `(ref_string, CoreSchema)` is returned.
        If no definition exists yet, a tuple of `(ref_string, None)` is returned.

        Note that the returned `CoreSchema` will always be a `DefinitionReferenceSchema`,
        not the actual definition itself.

        This should be called for any type that can be identified by reference.
        This includes any recursive types.

        At present the following types can be named/recursive:

        - BaseModel
        - Dataclasses
        - TypedDict
        - TypeAliasType
        N)rF   r  r  r!   r  adddiscard)r   r   r   s      ru   r1  z_Definitions.get_schema_or_ref  s     ( 2$))sd&6&66??DEEIIMM#'Dk!		!!#&		!!#&s   AB" B &B"BB"NrX  r  )r   r   rX  z3Iterator[tuple[str, None] | tuple[str, CoreSchema]])r   r	  r  r   r   r   r1  rV  rw   ru   r   r     s    4A ' 'rw   r   c                Z    | d   dk(  r|j                  | d   d       S | d   dk(  r| d   S | S )Nr   r  r  r  r   r\  )r   r  s     ru   r  r    sA    f~))vl3T::	=	(hrw   c                  2    e Zd ZdZddZedd       ZddZy)	r   _stackc                    g | _         y r   r	  r   s    ru   r   z_FieldNameStack.__init__  s	    !#rw   c              #  ~   K   | j                   j                  |       d  | j                   j                          y wr   )r
  r  r  )r   r   s     ru   r=  z_FieldNameStack.push  s)     :&s   ;=c                :    | j                   r| j                   d   S y )Nr   r	  r   s    ru   r   z_FieldNameStack.get  s    ;;;;r?"rw   Nr  )r   rY  rX  zIterator[None])rX  r  )r   r	  r  r_  r   r   r=  r   rV  rw   ru   r   r     s%    I$  
rw   r   )rr   FieldDecoratorInfors   rY  rX  r  )r   zIterable[AnyFieldDecorator]rq   zIterable[str]rX  r  )r   z+Iterable[Decorator[FieldDecoratorInfoType]]rs   rY  rX  z'list[Decorator[FieldDecoratorInfoType]])r   r  r   z'list[Decorator[ValidatorDecoratorInfo]]r   r  rX  r  )r   rC   r   r-   r   r   rX  r6   )r   zJsonEncoders | Noner   r   r   r   rX  r   )r   r  r6  zIterable[Decorator[RootValidatorDecoratorInfo]] | Iterable[Decorator[ValidatorDecoratorInfo]] | Iterable[Decorator[FieldValidatorDecoratorInfo]]r   r  rX  r  )r6  z+Iterable[Decorator[ValidatorDecoratorInfo]]rX  r  )r   r  r6  z0Iterable[Decorator[ModelValidatorDecoratorInfo]]r   z Literal['inner', 'outer', 'all']rX  r  )r  r5   r   r  rX  r  )r   r   r   r   rX  zGetJsonSchemaFunction | None)r   r  r  r  r  r  r  r  r  r  r   r   rX  r  )r   r   r  zdict[str, CoreSchema]rX  zCoreSchema | None)r   
__future__r   _annotationscollections.abcr  rb  r   r  sysr  r   
contextlibr   r   r   enumr   	functoolsr   r	   r
   r   	itertoolsr   operatorr   typesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   pydantic_corer   r    r!   r"   typing_extensionsr#   r$   r%   r&   r'   r(   r)   r*   annotated_handlersr,   r-   r,  r.   r/   errorsr0   r1   r2   rq   r3   r4   r5   r   r6   versionr7   r8   rO  r:   r;   r<   r=   _configr>   r?   _core_metadatar@   rA   _core_utilsrB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   r  rU   rV   _forward_refrW   	_genericsrX   rY   rZ   r[   _schema_generation_sharedr\   r]   _utilsr^   r  r`   r6  ra   _dataclassesrb   rc   version_infor  r   r  r  r  rg   AnyFieldDecoratorModifyCoreSchemaWrapHandlerGetCoreSchemaFunctionrt  Tupleri   r;  r  Listr  MutableSequencerj   r|   Set
MutableSetrk   	frozenset	FrozenSetrl   r   MutableMappingrm   rv   r   r   r   r   JsonEncodersr   r   r  r   r  r@  r  r  r  r  r   r  r   rV  rw   ru   <module>r3     s	   3 2    	 
   %    8 8   6 6     X X u u u K , b b 7 7 ) # 0 Y Y 6     M . t t ' & 0/@&&'1 iS)*13NPllm  !9AST $%)**+-  3  #'B!C[E[E[![\  !&,,/Z /[__-L-LM
J Mfjj+//*D*DE	: E )6+;+;[__=P=PQ * Q[__-K-K[__MdMde
J e
 
,6nDnMPn,n"A  	@&1EOR8 DI{*+&,/9CDr rr/ if[d   ."7
  2 ,",@, +, 	,^,<9  NR&*)-" K $	
 '   &$' $'N rw   