
    )i9                   X   % S r SSKJr  SSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKrSSKrSSKJrJrJrJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJrJrJ r   SSK!J"r"J#r#J$r$J%r%J&r&J'r'  SSK(J)r)  SSK*J+r+  SSK,J-r-J.r.J/r/J0r0  SSKJ1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:  SSK;J<r<  SSK=J>r>  SSK?r?SSK@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrHJIrI  SSK?JJrJJKrKJLrLJMrMJNrN  SSKOJPrP  SSKQJRrRJSrSJTrT  SSKUJVrVJWrW  SSKXJYrYJZrZ  SSK[J\r\J]r]J^r^J_r_  SSK`JaraJbrbJcrc  SSKdJereJfrfJgrgJhrhJiri  SSKjJkrk  SSKlJmrm  SSKJnrnJoroJprpJqrq  S S!KrJsrsJtrtJuruJvrvJwrw  S S"KxJyryJzrz  S S#K{J|r|J}r}  S S$K~JrJrJr  S S%KsJrJrJrJrJrJrJrJrJrJrJrJr  S S&KJr  S S'KJrJrJrJrJr  S S(KJr  S S)KJrJr  S S*KJrJr  S S+KJr  S S,KJrJr  S S-KJrJr  S S.KJr  S S/KJrJr  \1(       a   SS0KJrJr  SS1KJr  SS2K,Jr  S S3KJr  S S4KJr  \GRh                  S5:  r\8\\\4   r\7" S6\S79r\8\\   \\   \\   4   r\YrS8\S9'   \3\2\/\HR                  4   rS8\S:'   S;rS8\S<'   \GRz                  \/rS=\S>'   \GR                  \\GR                  GR                  /rS=\S?'   \GR                  \\GR                  GR                  /rS=\S@'   \GR                  \\GR                  GR                  /rS=\SA'   \GR                  \/rS=\SB'   \"\#\$\%\&\'/rS=\SC'   \GR                  \GR                  GR                  /rS=\SD'   \R                   \GR                  R                   \R                  \GR                  R                  /rS=\SE'   \GR                  \/rS=\SF'   \GR                  \GR                  /rS=\SG'   \	GR                  \
GR                  \
GR                  \
GR                  \
GR                  \
GR                  /rS=\SH'   \R$                  \GR                  \GR                  R$                  \GR                  GR                  \GR                  \?GR                  \GR                  \GR                  /r\GR                  \GR                  /r\GR                  \GR                  /rS=\SI'   \8\/\-\0\4   r\L" \5      rSJSKSLSM\F4SNSOSPSQSRSSSTSUSV/rSW\SX'    \f\e\h\iSY.rSZ\S['         SS\ jrSS] jr      SS^ jr      SS_ jr    SS` jr\\\2   \^4   r        SSa jr " Sb Sc\5      r " Sd Se5      rSf Sg Sh Si Sj Sk Sl Sm Sn.rSo\Sp'         SSq jrSSr jr    SSs jr        SSt jrSSu jrSSv jrSSx jr    SSy jr " Sz Sw5      Gr  " S{ S|5      Gr " S} S~5      Grg)z-Convert python types to pydantic-core schema.    )annotationsN)	GeneratorIterableIteratorMapping)contextmanager)copy)Decimal)Enum)Fraction)partial)	Parameter_ParameterKind	signature)IPv4AddressIPv4InterfaceIPv4NetworkIPv6AddressIPv6InterfaceIPv6Network)chain)
attrgetter)FunctionTypeGenericAlias
LambdaType
MethodType)
TYPE_CHECKINGAnyCallableFinal
ForwardRefLiteralTypeVarUnioncastoverload)UUID)ZoneInfo)	MISSING
CoreSchemaMultiHostUrlPydanticCustomError$PydanticSerializationUnexpectedValuePydanticUndefinedUrlcore_schemato_jsonable_python)	TypeAliasTypeAliasTypeget_args
get_originis_typeddict)typing_objects)AnnotationSourceget_literal_valuesis_union_origin   )AliasChoices	AliasPath)GetCoreSchemaHandlerGetJsonSchemaHandler)
ConfigDictJsonDictJsonEncoderJsonSchemaExtraCallable)PydanticSchemaGenerationErrorPydanticUndefinedAnnotationPydanticUserError)AfterValidatorBeforeValidatorFieldValidatorModesPlainValidatorWrapValidator)JsonSchemaValue)version_short)ArbitraryTypeWarningPydanticDeprecatedSince20TypedDictExtraConfigWarning UnsupportedFieldAttributeWarning   )_decorators_discriminated_union_known_annotated_metadata_repr_typing_extra)ConfigWrapperConfigWrapperStack)CoreMetadataupdate_core_metadata)get_refget_type_ref%is_list_like_schema_with_items_schema)	DecoratorDecoratorInfosFieldSerializerDecoratorInfoFieldValidatorDecoratorInfoModelSerializerDecoratorInfoModelValidatorDecoratorInfoRootValidatorDecoratorInfoValidatorDecoratorInfoget_attribute_from_basesinspect_field_serializerinspect_model_serializerinspect_validator)extract_docstrings_from_cls)collect_dataclass_fieldsrebuild_dataclass_fieldsrebuild_model_fieldstakes_validated_data_argumentupdate_field_from_config)PydanticRecursiveRef)get_standard_typevars_mapreplace_types)import_cached_base_modelimport_cached_field_info)MockCoreSchema)NamespacesTuple
NsResolver)MissingDefinitionErrorgather_schemas_for_cleaning)CallbackGetCoreSchemaHandler)lenient_issubclasssmart_deepcopy)ComputedFieldInfo	FieldInfo	BaseModel)Discriminator)StandardDataclass)GetJsonSchemaFunction)      FieldDecoratorInfoType)boundr2   ModifyCoreSchemaWrapHandlerGetCoreSchemaFunctionz1Callable[[int, str, Any], Literal['skip'] | None]ParametersCallbackz
list[type]TUPLE_TYPES
LIST_TYPES	SET_TYPESFROZEN_SET_TYPES
DICT_TYPESIP_TYPESSEQUENCE_TYPESITERABLE_TYPES
TYPE_TYPESPATTERN_TYPES
PATH_TYPESDEQUE_TYPES)aliasN)validation_aliasN)serialization_aliasNdefault)default_factoryN)excludeN)
deprecatedN)reprT)validate_defaultN)frozenN)initN)init_varN)kw_onlyNlist[tuple[str, Any]]+UNSUPPORTED_STANDALONE_FIELDINFO_ATTRIBUTES)beforeafterplainwrapzbdict[FieldValidatorModes, type[BeforeValidator | AfterValidator | PlainValidator | WrapValidator]]_mode_to_validatorc                :    U R                   nSU;   =(       d    X;   $ )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.
*)fields)infofieldr   s      c/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/pydantic/_internal/_generate_schema.py)check_validator_fields_against_field_namer      s     [[F&=+EO+    c           	     (   [        U5      nU  H  nSUR                  R                  ;   a  M  UR                  R                  SL a  M:  UR                  R                   H-  nX1;  d  M
  [	        SUR
                   SUR                   S3SS9e   M     g)	aZ  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.
r   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)setr   r   check_fieldsrF   cls_refcls_var_name)
decoratorsr   decr   s       r   check_decorator_fields_existr      s     [F#((//!88  E)XX__E"'@QsO_O_N`ef2  % r   c                l    U  Vs/ s H"  n[        UR                  U5      (       d  M   UPM$     sn$ s  snf N)r   r   )validator_functionsr   r   s      r   $filter_field_decorator_info_by_fieldr      s0     /m.C2[\_\d\dfk2lC.mmms   11c                   U(       d  U $ U S   S:X  a  [        U S   U5      U S'   U $ U S   S:X  a.  U R                  S5      =nb  [        U S   U   U5      U S   U'   U $ [        U 5      (       a5  U R                  S[        R
                  " 5       5      n[        X15      U S'   U $ U S   S:X  a5  U R                  S[        R
                  " 5       5      n[        X15      U S'   U $ [        S	U S    35      e)
Ntypenullableschematuplevariadic_item_indexitems_schemadictvalues_schemazO`@validator(..., each_item=True)` cannot be applied to fields with a schema of )apply_each_item_validatorsgetapply_validatorsr^   r0   
any_schema	TypeError)r   each_item_validatorsr   inner_schemas       r   r   r      s     
 f~#5fX6FH\]x	7	"#)::.C#DDQ:J~&':;$;F>"#67 M 
/v	6	6zz.+2H2H2JK!1,!U~ M 
6	!zz/;3I3I3KL"2<"V
 M ]^dek^l]mn
 	
r   c                N   U R                   U R                  [        U R                  5      =(       d    U R                  S:H  =(       d    S [	        U R
                  5      S.nUR                  5        VVs0 s H  u  p#Uc  M
  X#_M     nnnU=(       d    S U R                  4$ s  snnf )N )titledescriptionr   examples)r   r   boolr   r1   r   itemsjson_schema_extra)r   json_schema_updateskvs       r   )_extract_json_schema_info_from_field_infor     s     ''4??+Lt"/DL&t}}5	 -@,E,E,GY,GDA1414,GY'4)?)?@@ Zs   4	B!B!c                4   U (       d  U$ SU;   a  U$ U/[        USUR                  R                  5      SS Q7 HZ  nU R                  U5      nUc  M  [        R
                  " S[        5        S3[        5        [        R                  " USS9US'   Us  $    U$ )	zIterate 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   warningswarnrM   rO   r0   $plain_serializer_function_ser_schema)json_encoderstpr   baseencoders        r   ,_add_custom_serialization_from_json_encodersr   )  s     &  Hgb)R\\-A-AB3BGH##D)?KMOK\  ]Y  Z%	
 #."R"RSZfl"m I Mr   c                      \ rS rSrSrSrg)InvalidSchemaErroriK  zThe core schema is invalid. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r   r   r   r   r   K  s    %r   r   c                  x  ^  \ rS rSrSrSr  SL       SMS jjrSNU 4S jjr\SOS j5       r	\SPS j5       r
\SQS	 j5       rSRS
 jrSSS jrSRS jrSRS jrSTS jrSUS jrSVS jrSRS jrSWS jrSXS jrSUS jrSYS jr      SZS jrS[S jrS\S jr    S]S jrS^S jrS_S jrS`S jrS_S jr\ SaS j5       r!\ SbS j5       r!ScSdS  jjr!S_S! jr"SeS" jr#S]S# jr$S]S$ jr%SfS% jr&S&S'.         SgS( jjr'        ShS) jr(        SiS* jr)        SjS+ jr*SkS, jr+SlS- jr,SmS. jr-SnS/ jr.SoS0 jr/\0Rb                  S4           SpS1 jjr2\0Rb                  4           SqS2 jjr3SrS3 jr4SsS4 jr5SsS5 jr6SkS6 jr7StS7 jr8SuS8 jr9SvS9 jr:SwS: jr;SsS; jr<      SxS< jr=SyS= jr> Sz     S{S> jjr? Sz     S|S? jjr@S}S@ jrA      S~SA jrBSSB jrCSC S&4         SSD jjrD S       SSE jjrE      SSF jrFSSG jrG Sc         SSH jjrH      SSI jrI      SSJ jrJSKrKU =rL$ )GenerateSchemaiO  z\Generate core schema for a Pydantic model, dataclass and types like `str`, `datetime`, ... .)_config_wrapper_stack_ns_resolver_typevars_mapfield_name_stackmodel_type_stackdefsNc                    [        U5      U l        U=(       d
    [        5       U l        X0l        [        5       U l        [        5       U l        [        5       U l
        g r   )rY   r   rx   r   r   _FieldNameStackr   _ModelTypeStackr   _Definitionsr   )selfconfig_wrapperns_resolvertypevars_maps       r   __init__GenerateSchema.__init__[  sE     &8%G"'7:<) / 1 / 1 N	r   c                V   > [         TU ]  5         [        R                  " S[        SS9  g )NzeSubclassing `GenerateSchema` is not supported. The API is highly subject to change in minor versions.r;   )
stacklevel)super__init_subclass__r   r   UserWarning)clsr   s    r   r   GenerateSchema.__init_subclass__i  s#    !#s	
r   c                .    U R                   R                  $ r   )r   tailr  s    r   _config_wrapperGenerateSchema._config_wrapperq  s    ))...r   c                .    U R                   R                  $ r   )r   types_namespacer  s    r   _types_namespaceGenerateSchema._types_namespaceu  s      000r   c                .    U R                   R                  $ r   )r  arbitrary_types_allowedr  s    r   _arbitrary_typesGenerateSchema._arbitrary_typesy  s    ##;;;r   c                L    [         R                  " U R                  U5      5      $ r   )r0   list_schemagenerate_schemar  
items_types     r   _list_schemaGenerateSchema._list_schema  s    &&t';';J'GHHr   c                l    [         R                  " U R                  U5      U R                  U5      5      $ r   )r0   dict_schemar!  )r  	keys_typevalues_types      r   _dict_schemaGenerateSchema._dict_schema  s,    &&t';';I'FH\H\]hHijjr   c                L    [         R                  " U R                  U5      5      $ r   )r0   
set_schemar!  r"  s     r   _set_schemaGenerateSchema._set_schema  s    %%d&:&::&FGGr   c                L    [         R                  " U R                  U5      5      $ r   )r0   frozenset_schemar!  r"  s     r   _frozenset_schema GenerateSchema._frozenset_schema  s    ++D,@,@,LMMr   c           	     >  ^^
^^^ [        TR                  R                  5       5      m
[        T5      mTR                  (       d  S O[
        R                  " TR                  5      nUS:X  a  S nTR                  US.mTR                  5        VVs0 s H  u  p4Uc  M
  X4_M     snnmS m[        T[        5      (       a  Sm[        R                  " S5      nOs[        T[        5      (       a  Sm[        R                  " S5      nOE[        T[        5      (       a  Sm[        R                  " S5      nO[        R                  " S 5      nT
(       a  SU4S jjn[!        TR"                  SS 5      [$        R"                  R&                  L n[        R(                  " TT
TU(       a  S OTR"                  TS	U/0S
9nU R*                  R,                  (       a  [        R.                  " [1        S5      XS9nU$ SU
UUUU4S jjn	[        R2                  " TS	U	/0S9$ s  snnf )NzAn enumeration.)r   r   intstrfloatc                    U $ r   r   xs    r   <lambda>-GenerateSchema._enum_schema.<locals>.<lambda>  s    XYr   c                \   > U" U 5      nUR                  U5      nUR                  T5        U$ r   )resolve_ref_schemaupdate)r   handlerjson_schemaoriginal_schema
js_updatess       r   get_json_schema4GenerateSchema._enum_schema.<locals>.get_json_schema  s0    %fo")"<"<["I&&z2""r   __func__pydantic_js_functions)sub_typemissingrefmetadatavalue)r   c           	        > U" [         R                  " TTTTS95      nUR                  U5      nUR                  T5        U$ )N)rH  rJ  )r0   enum_schemar>  r?  )	_r@  rA  rB  casesenum_ref	enum_typerC  rH  s	       r   get_json_schema_no_cases=GenerateSchema._enum_schema.<locals>.get_json_schema_no_cases  sD    %k&=&=iYago&pq")"<"<["I&&z2""r   rK  )r   r*   r@  r?   returnrL   )r@  r?   rV  rL   )list__members__valuesr]   r   inspectcleandocr   r   
issubclassr5  r0   simple_ser_schemar6  r7  r   r   	_missing_r   rF  rN  r  use_enum_values no_info_after_validator_functionr   is_instance_schema)r  rR  r   r   r   value_ser_typerD  default_missingrN  rS  rP  rQ  rC  rH  s    `        @@@@r   _enum_schemaGenerateSchema._enum_schema  s   	 5 5 < < >?	*"+"3"3d9I9I)J[J[9\,,K(11+N
'1'7'7'9K'9tqQdad'9K
:>i%%H4?4Q4QRW4XN	3''H(::5AN	5))H(::7CN )MMkZN# &i&9&9:tLPTP^P^PgPggO%11! /Y5H5H1O3DEK ##33)JJw' # # 1114L3MN s Ls   	HHc                  ^^ SSK JnJn  [        S[        S[
        S[        S[        S[        S0mSU4S	 jjn[        R                  " [        R                  " UT   5      [        R                  " [        R                  " T[        R                  " 5       5      [        R                  " T5      S
9[        R                   " USSS9SUU4S j/0S9$ )NrR   )IP_VALIDATOR_LOOKUPIpTypeipv4ipv4networkipv4interfaceipv6ipv6networkipv6interfacec           	        > [        U T[        45      (       d  [        ST S[        U 5       SU  S35      eUR                  S:X  a  U $ [        U 5      $ Nz
Expected `z` but got `z` with value `'z-'` - serialized value may not be as expected.python
isinstancer6  r-   r   mode)ipr   r   s     r   ser_ip)GenerateSchema._ip_schema.<locals>.ser_ip  sZ    b2s),,: KRzLyz  yyH$	r7Nr   rA  python_schemaTalwaysinfo_argr   rG  c                   > STT   S.$ )Nstringr   formatr   )_1_2ip_type_json_schema_formatr   s     r   r;  +GenerateSchema._ip_schema.<locals>.<lambda>  s    (VpqsVt9ur   
lax_schemastrict_schemar   rK  )ru  r   r   core_schema.SerializationInforV  zstr | IpType)_validatorsrg  rh  r   r   r   r   r   r   r0   lax_or_strict_schema no_info_plain_validator_functionjson_or_python_schemar`  
str_schemara  r   )r  r   rg  rh  rv  r  s    `   @r   
_ip_schemaGenerateSchema._ip_schema  s    < ???
"	 //"CCDWXZD[\%;;'HH[McMcMef)<<R@ &JJ6\`ltu'*u)v

 
	
r   c           
       ^^^	 T[         R                  L a5  T[        [        1;  a%  [        R
                  " T5      (       d
  [        SSS9eT[         R                  L a  [        R                  OTm	T[        L a  [        R                  " SS9O[        R                  " SS9nT[        L a  [        R                  " 5       O[        R                  " 5       nSU	U4S jjnSU4S jjn[        R                  " [        R                  " XT5      [        R                  " T5      S9n[        R                  " [        R                   " U[        R                  " XS5      /S	S
T 3S9U[        R"                  " USSS9SS /0S9nU$ )Nz;`os.PathLike` can only be used with `str`, `bytes` or `Any`zschema-for-unknown-typer   Tstrictc                L  >  T[         L a3  [        U [         5      (       a   U R                  5       n O-[	        SS5      e[        U [
        5      (       d  [	        SS5      eT" U 5      $ ! [         a  n[	        SS5      UeS nAff = f! [         a  n[	        SS5      UeS nAff = f)N
bytes_typezInput must be valid byteszInput must be bytes	path_typezInput is not a valid path)bytesrs  decodeUnicodeDecodeErrorr,   r6  r   )input_valueepath_constructorr  s     r   path_validator3GenerateSchema._path_schema.<locals>.path_validator   s    [%!+u55h*5*<*<*>K 2,@UVV#K55-k;VWW'44  2 h"5lD_"`fggh  [)+7RSYZZ[s9   B A( 5B (
B2A??BB 
B#BB#c           	        > [        U T[        45      (       d  [        ST S[        U 5       SU  S35      eUR                  S:X  a  U $ [        U 5      $ rp  rr  )pathr   r   s     r   ser_path-GenerateSchema._path_schema.<locals>.ser_path  s[    dRI..: KT
|?4&P}~  yyH$t9r   rx  r  zInput is not a valid path for custom_error_typecustom_error_messagerz  r{  rG  c                    0 U" U 5      ESS0E$ )Nr  r  r   )sourcer@  s     r   r;  -GenerateSchema._path_schema.<locals>.<lambda>*  s    Hm7SY?Hm\dflHmr   r  )r  zstr | bytesrV  zos.PathLike[Any])r  r   r   r  rV  zstr | os.PathLike[Any])osPathLiker6  r  r7   is_anyrF   pathlibPurePathr0   bytes_schemar  r  r`  ra  r  union_schemar   )
r  r   r  strict_inner_schemalax_inner_schemar  r  instance_schemar   r  s
    ``      @r   _path_schemaGenerateSchema._path_schema  sV   )C<"?H]H]^gHhHh#MTm  02R[[/@7++b6?56HK$$D1{OeOemqOr 	 ;Du:L;335S^SiSiSk	[ 	["	 &;;#DD^f%88<

 11"//#@@e #.'EbT%J *%JJ8^bnvw-0m/no
 r   c           
     z   SSK Jn  SSKJn  U R	                  U5      n[
        R                  " USS9n[
        R                  " U[
        R                  " [        R                  SS9S9n[
        R                  " X55      n[
        R                  " U[
        R                  " Xg/5      [
        R                  " X$S	S
9S9$ )NrR   serialize_sequence_via_list)deque_validatorFr  Dequecls_reprrx  Tr   r|  r  r  r   )_serializersr  r  r  r!  r0   r   r  ra  collectionsdequeno_info_wrap_validator_functionr  chain_schema#wrap_serializer_function_ser_schema)r  r#  r  r  item_type_schemar   check_instancer  s           r   _deque_schemaGenerateSchema._deque_schema.  s    =0//
; "--.>uM$::#%889J9JU\]

 !@@^
//!%22N3OP%II+t
 	
r   c           
        SSK JnJnJn  XA   nU R	                  U5      n[
        R                  " 5          [
        R                  " S[        S9  U R	                  U5      n	S S S 5        [        R                  " UW	SS9n
U[        L a  U
nU$ [        R                  " U
[        R                  " U5      S9nU[        R                  L a*  U" U5      n[!        [        R"                  [!        X]S95      nO[!        [        R$                  U5      nU" U
5      n[        R&                  " X/5      n[        R(                  " UU[        R*                  " S	 U
SS
9S9nU$ ! , (       d  f       N= f)NrR   )MAPPING_ORIGIN_MAPdefaultdict_validator'get_defaultdict_default_default_factoryignorecategoryFr  rx  )default_default_factoryc                    U" U 5      $ r   r   )r   hs     r   r;  0GenerateSchema._mapping_schema.<locals>.<lambda>o  s    1r   r  r  )r  r  r  r  r!  r   catch_warningssimplefilterrQ   r0   r'  r   r  ra  r  defaultdictr   r  r`  r  r  r  )r  r   r(  r)  r  r  r  mapped_originkeys_schemar   r'  r   r  r  coerce_instance_wrapr  r  s                    r   _mapping_schemaGenerateSchema._mapping_schemaG  sJ   ss*.**95$$& !!(5UV 00=M ' "--k=QVWD  F6 3 )>>')<<]KN
 [,,,*QR]*^''.??1c($
 (/{/[/[]j'k$-k:J'44n5QRM 55%+)MM%kEF O '&s   +E
E%c           	        SSK Jn  [        R                  " [        R                  " U5      [        R
                  " [        R                  " U5      [        R                  " [        5      S9[        R                  " SS9SS /0S9$ )	z7Support for [`fractions.Fraction`][fractions.Fraction].rR   )fraction_validatorrx  rz  r   rG  c                    SSS.$ )Nr~  fractionr  r   r  r  s     r   r;  1GenerateSchema._fraction_schema.<locals>.<lambda>  s
    \f?gr   r  )	r  r  r0   r  r  r  ra  r   to_string_ser_schema)r  r  s     r   _fraction_schemaGenerateSchema._fraction_schemau  sp    3 //"CCDVW%;;'HHI[\)<<XF
 &::XN-0g/hi	
 		
r   c                    [        U[        5      (       d4  [        R                  " U< S3[        5        [
        R                  " 5       $ [
        R                  " U5      $ )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`.)rs  r   r   r   rN   r0   r   ra  )r  r   s     r   _arbitrary_type_schema%GenerateSchema._arbitrary_type_schema  sS    "d##MM& Z Z % ))++--b11r   c                "    [        SU< S35      e)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.)rD   r  objs     r   _unknown_type_schema#GenerateSchema._unknown_type_schema  s#    +:3' Bf f
 	
r   c                    Uc  U$  [         R                  " UUU R                  R                  5      $ ! [         R                   a    [         R
                  " UU5        Us $ f = fr   )rT   apply_discriminatorr   _definitionsMissingDefinitionForUnionRefset_discriminator_in_metadata)r  r   discriminators      r   _apply_discriminator_to_union,GenerateSchema._apply_discriminator_to_union  sl      M	';;		&& 
 $@@ 	 >> M	s   +3 -A#"A#c                8    U R                   R                  U5      $ r   )r   finalize_schema)r  r   s     r   clean_schemaGenerateSchema.clean_schema  s    yy((00r   c                    UR                  S0 5      nUR                  S/ 5      nX$;  a  UR                  U5        X1S'   g )NrK  rG  )r   
setdefaultappend)r  metadata_schemajs_functionrK  rG  s        r   _add_js_functionGenerateSchema._add_js_function  sF    "&&z26 ( 3 34KR P
 3!((5&.
#r   c                   U R                  X5      nUc  U R                  U5      n[        U5      nUb-  [        X R                  5      nU(       a  U R                  XC5        [        U R                  R                  X5      nU$ )a  Generate core schema.

Args:
    obj: The object to generate core schema for.

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 disallowed type (must be str, AliasPath or AliasChoices).
        - 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__`.
)	'_generate_schema_from_get_schema_method_generate_schema_inner!_extract_get_pydantic_json_schemaresolve_original_schemar   r  r   r  r   )r  r  r   metadata_js_functionr  s        r   r!  GenerateSchema.generate_schema  sw    0 ==cG>005F@E+5fiiHO%%oL=d>R>R>`>`benr   c                >   [        5       nU R                  R                  U5       u  p4Ub  UsSSS5        $ UR                  R	                  S5      nUbz  [        U[        5      (       de  US   S:X  a  U R                  R                  U5      n[        U5      nU(       a$  U R                  R                  U5      sSSS5        $ UsSSS5        $ [        UR                  SS9nU R                  R                  U5         U R                  R                  U5         U R                  R!                  UR"                  S9nUR$                  (       d  XL a  ['        US0 5      n	OgSUR                  ;  a#  [)        UR"                  S	UR"                  < S
3S9e [+        UU R                  U R                  U R,                  =(       d    0 S9n	UR2                  nUR4                  n[7        [9        UR:                  R=                  5       UR>                  R=                  5       UR@                  R=                  5       5      1 U	RC                  5       kURC                  5       k5        URD                  R=                  5       nSnSnUR	                  S5      S:X  Ga/  URF                  S   UL d   eURF                  S   [H        L d   eURF                  SS  H  n['        US0 5      R	                  SS5      nUc  M%  [        U[J        5      (       a5  [L        RN                  " [L        RP                  " USSS9/U RR                  Q76 n[U        U5      nU[V        ;  a  [Y        S5      eU R[                  USS9u  nnU[J        La  U R]                  U5      n[^        R`                  " U5      (       d  U R]                  U5      nUc  Uc  M    O   ['        US0 5      R	                  S5      nURb                  (       aX  U Re                  SU	S   U5      u  nn[g        UUS5      n[h        Rj                  " UUU['        USS5      S['        USS5      UUS9nO[h        Rl                  " U	Ro                  5        VVs0 s H  u  nnUU Rq                  UUU5      _M     snnUR=                  5        Vs/ s H  nU Rs                  UUR>                  5      PM!     snUUUR"                  S9n[u        UURv                  R=                  5       5      n[g        UUS5      n[h        Rj                  " UUU['        USS5      S['        USS5      UUS9nU Ry                  UURz                  R=                  5       5      n[g        X]S5      nU R                  R                  U5      sSSS5        sSSS5        sSSS5        $ ! [.         a  n
[(        R0                  " U
5      U
eSn
A
ff = fs  snnf s  snf ! , (       d  f       O= fSSS5        O! , (       d  f       O= fSSS5        g! , (       d  f       g= f) z%Generate schema for a Pydantic model.N__pydantic_core_schema__r   definitionsF)checkr   __pydantic_fields__zClass z is not defined)namemessager  r  r  extra_fields_behaviorallowr   r   __annotations____pydantic_extra__T)is_argumentis_classzEThe type annotation for `__pydantic_extra__` must be `dict[str, ...]`required__pydantic_generic_metadata__originrootinner__pydantic_custom_init____pydantic_post_init__)generic_origincustom_init
root_model	post_initconfigrJ  )computed_fieldsextras_schemaextras_keys_schema
model_nameouter)>rt   r   get_schema_or_ref__dict__r   rs  rv   unpack_definitionsr\   "create_definition_reference_schemarX   model_configr   pushr   r  core_configr   __pydantic_fields_complete__r   rE   rn   r   	NameErrorfrom_name_error__pydantic_decorators__r"  r   r   field_validatorsrY  field_serializers
validatorskeysmodel_validatorsr   objectr6  rW   eval_type_backport_make_forward_refr  r5   r   rD    _get_args_resolving_forward_refsr!  r7   r  __pydantic_root_model___common_field_schemaapply_model_validatorsr0   model_schemamodel_fields_schemar   _generate_md_field_schema_computed_field_schemar   root_validators_apply_model_serializersmodel_serializers)r  r  
BaseModel_	model_refmaybe_schemar   rJ  r  r-  r   r  r   r"  r6  r#  r$  candidate_clsextras_annotationr   extra_keys_typeextra_items_typer  r   rO  r>  r   r   dfields_schemas                                r   _model_schemaGenerateSchema._model_schema  s   -/
YY((-1J)'# .- \\%%&@AF!*V^*L*L&>]2!YY99&AFfo99GGO .- " .- +3+;+;5IN++00@$BSBSBXBXY\B]"22>>S\\>R33s7H$S*?DF,CLL@ :!$&,S\\,<O$L T!5+/+?+?(,(9(9)-););)Ar	" !88
","<"<,"33::<"44;;="--446
 >fkkm=o&:&:&<= $.#>#>#E#E#G  $%)"??#:;wF;;q>S000;;r?f444),Sb)9,3MCTVX,Y,],]0$-) -8)*;SAA4A4T4T$1$C$C(9uW[%&5" &*%:%:	5" 1 ",,=!>B!3&C$k'" !" AE@e@e 1)- Af A=O-=  /c9595I5I/5Z 2#1#8#89I#J#J040D0DEU0V1=AZ %5 *:8 :AFegi9j9n9now9x..&*&?&?vXb&cOL!#9,HXZa#bL#.#;#;$'5$+C1KT$R#'")#/G"N*%	$L =H<[<[Y_YeYeYghYgQUQRTUD::1aLLYgh &5%;%;%=)%= !77:;W;WX%=) '4+=#&<<	=M $4M:C]C]CdCdCf#gL#9,HXZa#bL#.#;#;$'5$+C1KT$R#(")#/G"N*%	$L 66|ZEaEaEhEhEjk/'RyyCCFKq C^B]@@! .-X % T9II!LRSSTF i)A C^B]@@@! .--s   XBXX/X>W4A:W3V&D'W3CW>B,W*!WW &WCW
	W4	X&
W	0W	W	W
W($W4+	X4
X	>X
Xc                T    U R                   R                  5       nUc
  [        SSS9eU$ )Nz(`typing.Self` is invalid in this contextzinvalid-self-typer   )r   r   rF   r  s     r   _resolve_self_type!GenerateSchema._resolve_self_types  s/    ##'');#$NUhii
r   c           	     p   [        5       n[        USS 5      n[        USS 5      UR                  R                  L nUb  U(       d  U R                  R                  U5       u  pgUb  UsS S S 5        $  S S S 5        XL a  SnOSnU" U[        U R                  XS95      n	U	S   S:X  a  U R                  R                  U	5      n	[        U	5      n
U
(       a  U R                  R                  U	5      $ U	$ Uc  [        USS 5      =nb  S	S
KJn  [        X5      (       a*  [        R                  " SUR                    S3["        5        O[        R                  " S[$        5        [&        R(                  " U" 5        Vs/ s H  n[&        R*                  " U5      PM     sn5      $ g g ! , (       d  f       GN6= fs  snf )N__get_pydantic_core_schema__rF  unpackzto-def)ref_moder   r  __get_validators__r   r   zeMixing V1 models and V2 models (or constructs, like `TypeAdapter`) is not supported. Please upgrade `z` to V2.zc`__get_validators__` is deprecated and will be removed, use `__get_pydantic_core_schema__` instead.)rt   r   rT  rF  r   r'  r{   r  r)  r\   r*  pydantic.v1r   r\  r   r   r   r  rO   r0   r  "with_info_plain_validator_function)r  r  r  rE  
get_schemais_base_model_get_schemarO  rG  rV  r   rJ  r4  BaseModelV1r   s                 r   r   6GenerateSchema._generate_schema_from_get_schema_methody  s   -/
S"@$G
J
D1Z5\5\5e5ee 	!
 " - ,,S15Fa+' 21+ 2 }##4T5P5PRVjF f~.55f=&/CyyCCFKK M>RTX1Y#Y:"f<#++{|  }I  }I  |J  JR  S
 y- ++hrht,uhtcd[-[-[\]-^ht,uvv #g- 21F -vs    F!8 F3!
F0c                D    [         R                  " U/U R                  Q76 n[        U[        5      (       a  [	        UR                  SU 35      eU R                  (       a  [        XR                  5      nU$ ! [         a  n[        R
                  " U5      UeS nAff = f)Nz%Unable to evaluate forward reference )rW   r8  r  r/  rE   r0  rs  r!   __forward_arg__r   rs   )r  r  r  s      r   _resolve_forward_ref#GenerateSchema._resolve_forward_ref  s    	H223O9N9NOC
 c:&&-c.A.AEjknjoCpqq%7%78C
  	H-==a@aG	Hs   !A9 9
BBBc                    g r   r   )r  r  r  s      r   r:  /GenerateSchema._get_args_resolving_forward_refs  s    fir   c                    g r   r   r  s     r   r:  rc    s    TWr   c                   ^  [        U5      nU(       a5  [        U[        5      (       a	  S U 5       n[        U 4S jU 5       5      nU$ U(       a  [	        SU S35      eU$ )Nc              3  |   #    U  H2  n[        U[        5      (       a  [        R                  " U5      OUv   M4     g 7fr   )rs  r6  rW   r9  ).0as     r   	<genexpr>BGenerateSchema._get_args_resolving_forward_refs.<locals>.<genexpr>  s0     fae\]jC>P>P77:VWWaes   :<c              3  t   >#    U  H-  n[        U[        5      (       a  TR                  U5      OUv   M/     g 7fr   )rs  r!   r`  )rg  rh  r  s     r   ri  rj    s1     hcg^_Az9R9R2215XYYcgs   58z	Expected z+ to have generic parameters but it had none)r4   rs  r   r   r   )r  r  r  argss   `   r   r:  rc    s^    }#|,,faefhcghhD  iu,WXYYr   c                H    U R                  U5      nU(       d  [        $ US   $ )Nr   )r:  r   )r  r  rl  s      r   _get_first_arg_or_any$GenerateSchema._get_first_arg_or_any  s#    44S9JAwr   c                    U R                  U5      nU(       d  [        [        4$ [        U5      S:  a  [        U5      n[	        SU S35      eUS   US   4$ )Nr;   z Expected two type arguments for z, got 1r   rR   )r:  r   lenr5   r   )r  r  rl  r  s       r   _get_first_two_args_or_any)GenerateSchema._get_first_two_args_or_any  s[    44S9:t9q=_F>vhgNOOAwQr   c                   [         R                  " U5      (       a  U R                  U5      n[         R                  " [	        U5      5      (       a  U R                  U5      $ [        U[        5      (       a  U$ [        U[        5      (       a  [        U5      n[        U[        5      (       a   U R                  U R                  U5      5      $ [        5       n[        X5      (       a6  U R                  R                  U5         U R!                  U5      sS S S 5        $ [        U["        5      (       a  [$        R&                  " UR(                  S9$ U R+                  U5      $ ! , (       d  f       NR= f)N)
schema_ref)r7   is_selfrQ  is_annotatedr5   _annotated_schemars  r   r6  r!   r!  r`  rt   r|   r   r,  rN  rq   r0   definition_reference_schematype_ref
match_type)r  r  r   s      r   r  %GenerateSchema._generate_schema_inner  s   !!#&&))#.C&&z#77))#..c4  Jc3S/Cc:&&''(A(A#(FGG,.	c--&&++C0))#. 10 c/00::cllSSs## 10s   E""
E0c                   U[         L a  [        R                  " 5       $ U[        L a  [        R                  " 5       $ U[
        L a  [        R                  " 5       $ U[        L a  [        R                  " 5       $ U[        L a  [        R                  " 5       $ U[        L a  [        R                  " 5       $ [        R                  " U5      (       d	  U[        L a  [        R                   " 5       $ U["        R$                  L a  [        R&                  " 5       $ U["        R"                  L a  [        R(                  " 5       $ U["        R*                  L a  [        R,                  " 5       $ U["        R.                  L a  [        R0                  " 5       $ U[2        L a  [        R4                  " 5       $ U[6        L a  [        R8                  " 5       $ U[:        L a  [        R<                  " 5       $ U[>        L a  U RA                  5       $ U[B        L a  [        RD                  " 5       $ Ub  U[F        RH                  L a  [        RJ                  " 5       $ U[L        L a  [        RN                  " 5       $ U[P        ;   a  U RS                  U5      $ U[T        ;   a  U RW                  U5      $ U[X        ;   a  U R[                  [\        5      $ U[^        ;   a  U Ra                  [\        5      $ U[b        ;   a  U Re                  [\        5      $ U[f        ;   a  U Ri                  [\        5      $ U[j        ;   a  U Rm                  U5      $ U[n        ;   a  U Rq                  [\        [\        5      $ U[r        ;   a  U Ru                  U[\        5      $ U[v        ;   a  U Ry                  [\        5      $ U[z        ;   a  U R}                  U[\        [\        5      $ U[~        ;   a  U R}                  U[\        [
        5      $ [        R                  " U5      (       a  U R                  U5      $ U[        L a  U R                  5       $ [F        R                  " U5      (       a  [        R                  " 5       $ [        R                  " [        U5      5      (       a  U R                  U5      $ [        U5      (       a  U R                  US5      $ [F        R                  " U5      (       a  U R                  US5      $ [        R                  " U5      (       a  U R                  UR                  5      $ U[        ;   a  U R                  U5      $ [F        R                  " U5      (       a  U R                  5       $ [        U[        R                  5      (       a  U R                  U5      $ [F        R                  " U5      (       a>  U[        L a  [        R                   " 5       $ U R                  U R                  U5      5      $ [        U[        5      (       a  U R                  U5      $ [        R                  " U5      (       a&  [        U[        5      (       a  U R                  U5      $ U[        L a  U R                  5       $ [        R                  " U5      (       a  U R                  US5      $ [        U5      nUb  U R                  X5      $ U R                  (       a  U R                  U5      $ U R                  U5      $ )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.
N)kr6  r0   r  r  r  r5  
int_schemar7  float_schemar   bool_schemacomplexcomplex_schemar7   r  r7  r   datetimedatedate_schemadatetime_schematimetime_schema	timedeltatimedelta_schemar
   decimal_schemar'   uuid_schemar/   
url_schemar   r  r+   multi_host_url_schemarW   NoneTypenone_schemar)   missing_sentinel_schemar   r  r   _tuple_schemar   r$  r   r   r.  r   r2  r   _sequence_schemar   _iterable_schemar   r*  r   r  r   r  MAPPING_TYPESr  COUNTER_TYPESis_typealiastype_type_alias_type_schemar   _type_schemais_callablecallable_schema
is_literalr5   _literal_schemar6   _typed_dict_schemais_namedtuple_namedtuple_schema
is_newtyper!  __supertype__r   _pattern_schemais_hashable_hashable_schemars  typingr#   _unsubstituted_typevar_schemais_finalvarr    rn  VALIDATE_CALL_SUPPORTED_TYPES_call_schemarZ  isclassr\  r   rd  r(   _zoneinfo_schemadataclassesis_dataclass_dataclass_schema_match_generic_typer  r  r  )r  r  r  s      r   r{  GenerateSchema.match_type  sY    #:))++E\++--CZ))++E\++--D[**,,G^--//""3''3&=))++HMM!**,,H%%%..00HMM!**,,H&&&//11G^--//D[**,,CZ))++H_((**L 4466[C=#9#99**,,'>6688H_??3''K%%c**J$$S))I##C(($$))#..N"((--N"((--J$$S#..J$$S#..K%%c**M!''S#66M!''S#66,,S11//44D[$$&&&&s++..00&&z#77'',,#**355((--**355&&s++''(9(9::M!'',,&&s++((**V^^,,55c::&&s++e|"--//''**3/  :;;$$S))__S!!jd&;&;$$S))H_((** ##C(())#t44C++C88  ..s33((--r   c                   [         R                  " U5      (       a  U R                  X5      $ [        R                  " U5      (       a  U R                  X5      $ U R                  X!5      nUb  U$ [        R                  " U5      (       a  U R                  U5      $ [        U5      (       a  U R                  U5      $ U[        ;   a  U R                  U5      $ U[        ;   a   U R                  U R!                  U5      5      $ U["        ;   a   U R%                  U R!                  U5      5      $ U[&        ;   a   U R)                  U R!                  U5      5      $ U[*        ;   a  U R,                  " U R/                  U5      6 $ U[0        ;   a   U R3                  X R!                  U5      5      $ U[4        ;   a   U R7                  U R!                  U5      5      $ U[8        ;   a"  U R:                  " U/U R/                  U5      Q76 $ U[<        ;   a%  U R;                  X R!                  U5      [>        5      $ [A        U5      (       a  U RC                  X5      $ U[D        ;   a  U RG                  U5      $ U[H        ;   a   U RK                  U R!                  U5      5      $ U[L        ;   a  U RO                  U5      $ U[P        ;   a  U RS                  U5      $ U RT                  (       a  U RW                  U5      $ U RY                  U5      $ r   )-r  r  r  rW   r  r  r   r7   r  r  r:   _union_schemar   r  r   r$  rn  r   r.  r   r2  r   r*  rr  r   r  r   r  r  r  r  r5  r6   r  r   _subclass_schemar   r  r   r  r   r  r  r  r  )r  r  r  r   s       r   r  "GenerateSchema._match_generic_type~  s   
 ##F++))#66&&v..**377==fJM**622//44V$$%%c**{"%%c**z!$$T%?%?%DEEy ##D$>$>s$CDD''))$*D*DS*IJJz!$$d&E&Ec&JKKz!$$V-G-G-LMM{"%%d&@&@&EFF}$''V1P1PQT1UVV}$''0J0J30OQTUU&!!**377z!((--~%(()C)CC)HII~%((--}$'',,  ..v66((--r   Tr  c          
         U R                  XU5      u  pV[        R                  " UUR                  5       (       d  SOUUR                  [        UR                  5      UR                  UR                  US9$ )zAPrepare a TypedDictField to represent a model or typeddict field.F)r  serialization_excluder   r   serialization_exclude_ifrK  )	r<  r0   typed_dict_fieldis_requiredr   _convert_to_aliasesr   r   
exclude_if)r  r  
field_infor   r  r   rK  s          r   _generate_td_field_schema(GenerateSchema._generate_td_field_schema  sn      44TzR++","8"8":":U","4"401L1LM * > >%/%:%:
 	
r   c           
         U R                  XU5      u  pE[        R                  " UUR                  [	        UR
                  5      UR                  UR                  UR                  US9$ )z0Prepare a ModelField to represent a model field.)r  r   r   r  r   rK  )	r<  r0   model_fieldr   r  r   r   r  r   r  r  r  r   r   rK  s         r   r@  (GenerateSchema._generate_md_field_schema  sd      44TzR&&","4"401L1LM * > >%/%:%:$$
 	
r   c                <   U R                  XU5      u  pE[        R                  " UUUR                  UR                  =(       d    SUR
                  (       a  SOSUR                  [        UR                  5      UR                  UR                  UR                  US9$ )zJPrepare a DataclassField to represent the parameter/field, of a dataclass.NF)	r   	init_onlyr   r  r   r   r  r   rK  )r<  r0   dataclass_fieldr   r   r   r   r  r   r   r  r   r  s         r   _generate_dc_field_schema(GenerateSchema._generate_dc_field_schema  s      44TzR** ))1T&..DE","4"401L1LM * > >%/%:%:$$
 	
r   c                  ^ ^ TR                   TR                  pTSUU 4S jjn[        UR                  R	                  5       U5       Vs/ s H/  n[
        UR                  R                     R                  U5      PM1     nnT R                  R                  U5         TR                  b  T R                  XEU-   US9n	OT R                  UXX-   5      n	S S S 5        [        UR                  R	                  5       U5      n
[        U
5      (       a  STl        U
 Vs/ s H  oR                  R                   SL d  M  UPM!     nnU
 Vs/ s H  oU;  d  M
  UPM     n
n[#        W	U5      n	[%        X5      n	TR'                  5       (       d  [)        TU	5      n	T R+                  U	[        UR,                  R	                  5       U5      5      n	[/        T5      u  p0 n[1        XUS9  X4$ s  snf ! , (       d  f       GN= fs  snf s  snf )Nc                @   > TR                  U TR                  5      n U $ r   )r  r  )r   r  r  s    r   set_discriminator>GenerateSchema._common_field_schema.<locals>.set_discriminator  s     77
@X@XYFMr   )transform_inner_schemaTpydantic_js_updatespydantic_js_extrar   r*   rV  r*   )
annotationrK  r   r2  rY  r   r   rt  _from_decoratorr   r,  r  _apply_annotationsr4  $_validators_require_validate_defaultr   	each_itemr   r   r  wrap_default_apply_field_serializersr3  r   r[   )r  r  r  r   source_typer   r  	decoratorvalidators_from_decoratorsr   this_field_validatorsr   r   r  r  core_metadatas   ` `             r   r<  #GenerateSchema._common_field_schema  s    $.#8#8*:M:M[	 	 B*B]B]BdBdBfhlm&
m	 y~~223CCINm 	# &

 ""''-''300/I!Ibs 1  00< . !EZEZEZEaEaEcei j/0EFF*.J'+@]+@aFFDTDTX\D\+@],A c,AqNbEb,A c+F4HI!&@
 %%''!*f5F..89U9U9\9\9^`de
 2[[e1f.(*Vg	
 $$[&

 .-$  ^ cs*   	6G"6G'G99G9	G>G>'
G6c                   U R                  USS9n/ nSnU H=  nUb  U[        R                  L a  SnM  UR                  U R	                  U5      5        M?     [        U5      S:X  a  US   nOx/ nU HZ  n[        [        UR                  S0 5      5      R                  S5      n	U	b  UR                  X45        MI  UR                  U5        M\     [        R                  " U5      nU(       a  [        R                  " U5      nU$ )zGenerate schema for a Union.Tr  FrR   r   rK  pydantic_internal_union_tag_key)r:  rW   r  r  r!  rq  r%   rZ   r   r0   r  nullable_schema)
r  
union_typerl  choicesr   argschoices_with_tagschoicetags
             r   r  GenerateSchema._union_schema&  s    44Z$4O$&C{c]%;%;;t33C89	  w<1
AKM!<J)CDHHIjk?%,,f];%,,V4 " (():;A++A.Ar   c                l   U R                   R                  U5       u  p#Ub  UsS S S 5        $ [        U5      =(       d    Un[        U5      nU R                  R                  U5          [        R                  " UR                  /U R                  Q76 n[        Xe5      nU R                  U5      nUS   S:w  d   eX(S'   S S S 5        U R                   R                  W5      sS S S 5        $ ! [         a  n[        R                  " U5      UeS nAff = f! , (       d  f       N[= f! , (       d  f       g = f)Nr   r  rJ  )r   r'  r5   rr   r   r,  rW   	eval_type	__value__r  r/  rE   r0  rs   r!  r*  )	r  r  rJ  rG  r  r  r  r  r   s	            r   r  &GenerateSchema._type_alias_type_schemaA  s   YY((-1D#'# .- %/sO$:sF4S9L""''/P!.!8!89I9I!bDLaLa!bJ +:D
--j9f~666 #u 0 99??G! .- ! P5EEaHaOP 0/ .-sL   D%:D%'D)+C++D?"D%+
D5DDD
D"	D%%
D3c                   [        [        USSS95      nU(       d
   SU 35       e[        R                  " U5      nU R                  R
                  (       a/  [        S U 5       5      (       a  [        R                  " S U5      nU$ )zGenerate schema for a Literal.Feager)
type_checkunpack_type_aliasesz(literal "expected" cannot be empty, obj=c              3  B   #    U  H  n[        U[        5      v   M     g 7fr   )rs  r   )rg  r   s     r   ri  1GenerateSchema._literal_schema.<locals>.<genexpr>Z  s     7^U]PQ
1d8K8KU]s   c                H    [        U [        5      (       a  U R                  $ U $ r   )rs  r   rL  )r   s    r   r;  0GenerateSchema._literal_schema.<locals>.<lambda>\  s    Z4%8%8!''?a?r   )rW  r9   r0   literal_schemar  r_  anyr`  )r  literal_typeexpectedr   s       r   r  GenerateSchema._literal_schemaT  sx    *<E_fghRCL>RRx++H5//C7^U]7^4^4^ AA?F r   c                
   [        5       nU R                  R                  U5         U R                  R	                  U5       u  nnUb  UsSSS5        sSSS5        $ [        U5      nUb  Un[        (       d#  [        U5      R                  S:X  a
  [        SSS9e [        US5      nU R                  R                  U5         U R                  R                  UR                  S9nUR                   n	0 n
["        R$                  " U5      nUR'                  U R                  5        U R                  R(                  (       a  [+        USS	9nOSn [,        R.                  " XR0                  S
9n/ nUR9                  5        H  u  nnUR:                  " U[<        R>                  S9n[A        URB                  U5      Ul!        UU	;   =(       d    SURD                  ;   =(       a    SURD                  ;  nSURD                  ;   a  URG                  U5        Ub  URH                  c  UU;   a
  UU   Ul$        [K        U R                  UU5        U RM                  UUUUS9U
U'   M     U(       ak  SRO                  S U 5       5      n[Q        U5      S:  n[R        RT                  " SU(       a  SOS SU SUR                  < SU(       a  SOS S3	[V        5        SnSn[Y        [[        USS5      5      n[[        US[\        R^                  5      nU(       a  SnSnO8[`        Rb                  " U5      (       d  S nU Re                  [A        UU5      5      nU R                  Rf                  =nS!;   a  U(       a/  US :X  a)  [R        RT                  " S"URh                  < S#3[j        S$9  OL[`        Rb                  " U5      (       d/  US:X  a)  [R        RT                  " S"URh                  < S%3[j        S$9  OUn[l        Rn                  " U
UURp                  Rs                  5        Vs/ s H  nU Ru                  UURv                  5      PM!     snUUUUS&9nU Ry                  UURz                  Rs                  5       5      n[}        UUR~                  Rs                  5       S'5      nU R                  R                  U5      sSSS5        sSSS5        sSSS5        $ ! [         a    Sn GN3f = f! [2         a  n[4        R6                  " U5      UeSnAff = fs  snf ! , (       d  f       O= f SSS5        O! , (       d  f       O= fSSS5        g! , (       d  f       g= f)(a  Generate a core schema for a `TypedDict` class.

To be able to build a `DecoratorInfos` instance for the `TypedDict` class (which will include
validators, serializers, etc.), we need to have access to the original bases of the class
(see https://docs.python.org/3/library/types.html#types.get_original_bases).
However, the `__orig_bases__` attribute was only added in 3.12 (https://github.com/python/cpython/pull/103698).

For this reason, we require Python 3.12 (or using the `typing_extensions` backport).
Nr  zXPlease use `typing_extensions.TypedDict` instead of `typing.TypedDict` on Python < 3.12.ztyped-dict-versionr   __pydantic_config__r
  T)use_inspectr  _sourcer  not_required	read_onlyr  , c              3  8   #    U  H  n[        U5      v   M     g 7fr   r   )rg  fs     r   ri  4GenerateSchema._typed_dict_schema.<locals>.<genexpr>  s     +M_DGG_   r;   Itemr  r    z on TypedDict class areiszk using the `ReadOnly` qualifier. Pydantic will not protect items from any mutation on dictionary instances.r  
__closed__F__extra_items__forbidr  )r  r  zTypedDict class zk is closed, but 'extra' configuration is set to `'allow'`. The 'extra' configuration value will be ignored.r  zu allows extra items, but 'extra' configuration is set to `'forbid'`. The 'extra' configuration value will be ignored.)r  r"  extra_behaviorr#  rJ  r!  all)Aru   r   r,  r   r'  rr   _SUPPORTS_TYPEDDICTr   r   rF   rg   AttributeErrorr   r  r-  r   __required_keys__r`   buildupdate_from_configuse_attribute_docstringsrk   rW   get_cls_type_hintsr   r/  rE   r0  r   from_annotationr8   
TYPED_DICTrs   r  _qualifiersr  r   rp   r  joinrq  r   r   r  r   r   typing_extensionsNoExtraItemsr7   is_noextraitemsr!  extrar   rP   r0   typed_dict_schemar"  rY  rA  r3  rC  rD  r=  r6  r*  )r  typed_dict_clsr  r   typed_dict_refrG  r  r!  r-  required_keysr   r   field_docstringsr   r  readonly_fields
field_namer  r  r  fields_reprpluralr  r#  	is_closedextra_itemsconfig_extrarL  	td_schemar   s                                 r   r  !GenerateSchema._typed_dict_schemaa  s    -.	 !!&&~6II''7 < '# 87 76 5^DL!!'&&4+?+J+Jh+V'n- 
 -E^Uj,k ++008"22>>^E\E\>]0>0P0P@B+11.A
--d.B.BC''@@'B>_c'd$'+$P"/"B"B>_p_p"qK .0.9.?.?.A*J
!*!:!::O_OjOj!kJ,9*:O:OQ],^J) #m3[zZE[E[7[ G(
0F0FF  #j&<&<<'..z: )4&22:&*::1A*1M
.,T-A-A:zZ)-)G)G"J
X *H *F:&% /B, #"&))+M_+M"MK 1Q6FMMfs"5Q{mCWXfXoXoWrrs$*55 6EE $	 =E37 !u!MN	%n6GIZIgIgh%-N$(M'77DD%,N$($8$8{T`9a$bM$($8$8$>$>>LCVV \W%< .~/J/J.M Nd d%@
 ,;;KHH\]eMe .~/J/J.M Ne e%@ *6'99& ",!;!;!B!B!D%!DA 33Az7S7ST!D% $2"/&&	 66y*B^B^BeBeBgh/
8S8S8Z8Z8\^cdyyCCFKE 983 87 76. " ( ! P5EEaHaOPJ%m 9883 877 766s   UT(
	U>T(S(T(BTS-J+T&T>A2T0	T(9	UST(ST(
T	)T 	 T	T
TT(	U(
T6	2U
Uc                
   U R                   R                  U5         U R                  R                  U5       u  nnUb  UsSSS5        sSSS5        $ [	        U5      nUb  Un [
        R                  " XR                  S9nU(       d$  [        R                  UR                  [        5      nU(       a.  UR                  5        VV	s0 s H  u  pU[!        X5      _M     nnn	["        R$                  " UR                  5        VV	s/ s HM  u  pU R'                  UU	[(        R*                  UR,                  R/                  U[0        R2                  5      S9PMO     sn	nSS0S9n
["        R4                  " XUS9nU R                  R7                  U5      sSSS5        sSSS5        $ ! [         a  n[        R                  " U5      UeSnAff = fs  sn	nf s  sn	nf ! , (       d  f       O= f SSS5        g! , (       d  f       g= f)z!Generate schema for a NamedTuple.Nr  )r  r   'pydantic_js_prefer_positional_argumentsTrU  )rJ  )r   r,  r   r'  rr   rW   r  r   r/  rE   r0  r   fromkeys_fieldsr   r   rs   r0   arguments_schema_generate_parameter_schemar8   NAMED_TUPLE_field_defaultsr   r   emptycall_schemar*  )r  namedtuple_clsr  namedtuple_refrG  r  r   r  r'  r  r3  r   s               r   r  !GenerateSchema._namedtuple_schema  s    !!&&~6II''7 < '# 87 76 5^DL!!'L+>>~[l[lm .2mmN<R<RTW.X 3>2C2C2E2E.
 j GG2E  
  +;; 3>2C2C2E 3F.
 33""/;; . > > B B:y _	 4  3F DTJ  !,,-=SabF99??GM 87 76  L1AA!D!KL5 877 766sl   G4G 	G4G$F$AGG
&GAG8G	G4$
G
.GG

G
G'	#G44
Hc                   [        5       nU[        R                  L a  UR                  " X#S9nOUR                  " X$US9nUR
                  c   S5       e[        U R                  X5        U R                  R                  U5         U R                  UR
                  U/SS9nSSS5        UR                  5       (       d  [        UW5      n[        R                  " UWU[        UR                   5      S9n	U	$ ! , (       d  f       N[= f)zGenerate the definition of a field in a namedtuple or a parameter in a function signature.

This definition is meant to be used for the `'arguments'` core schema, which will be replaced
in V3 by the `'arguments-v3`'.
r  Nz<field.annotation should not be None when generating a schemaF'check_unsupported_field_info_attributes)rt  r   )ru   r   r7  r  from_annotated_attributer  rp   r  r   r,  r  r  r  r0   arguments_parameterr  r   )
r  r  r  r  r   rt  r   r   r   parameter_schemas
             r   r4  )GenerateSchema._generate_parameter_schema  s     -.	ioo%--jIE66zTZ[E+k-kk+ !5!5tC""''-,,   9> - F .   ""!%0F&::%e&<&<=	
  ) .-s   C77
Dc                   [        5       nU[        R                  L a  UR                  " X#S9nOUR                  " X%US9n[        U R                  X5        U R                  R                  U5         U R                  UR                  U/SS9nSSS5        UR                  5       (       d  [        UW5      n[        R                  " UWU[        UR                   5      S9n	U	$ ! , (       d  f       N[= f)zGenerate the definition of a parameter in a function signature.

This definition is meant to be used for the `'arguments-v3'` core schema, which will replace
the `'arguments`' schema in V3.
r  Fr=  N)r  r   rt  r   )ru   r   r7  r  r?  rp   r  r   r,  r  r  r  r  r0   arguments_v3_parameterr  r   )
r  r  r  r  rt  r   r   r   r   rA  s
             r   _generate_parameter_v3_schema,GenerateSchema._generate_parameter_v3_schemaE  s    ( -.	ioo%--jIE66zTZ[E !5!5tC""''-,,   9> - F .   ""!%0F&==%e&<&<=	
  ) .-s   1C##
C1c                  ^ [        U5      mU R                  U5      nT(       a  U(       a  [        U4S jU 5       5      nU(       dI  U[        ;   a)  [        R
                  " [        R                  " 5       /SS9$ [        R
                  " / 5      $ US   [        L aB  [        U5      S:X  a(  [        R
                  " U R                  US   5      /SS9$ [        S5      e[        U5      S:X  a  US   S:X  a  [        R
                  " / 5      $ [        R
                  " U Vs/ s H  o0R                  U5      PM     sn5      $ s  snf )	zIGenerate schema for a Tuple, e.g. `tuple[int, str]` or `tuple[int, ...]`.c              3  <   >#    U  H  n[        UT5      v   M     g 7fr   )rs   )rg  paramr  s     r   ri  /GenerateSchema._tuple_schema.<locals>.<genexpr>~  s     R6%===6s   r   )r   r   r;   z&Variable tuples can only have one typerR   r   )rr   r:  r   r   r0   tuple_schemar   Ellipsisrq  r!  
ValueError)r  
tuple_typeparamsrI  r  s       @r   r  GenerateSchema._tuple_schemaw  s    1<66zBFR6RRF [("//1G1G1I0J`abb #//33BZ8#6{a"//1E1EfQi1P0Qghii !!IJJ[A&)r/ ++B//++V\,]V\U-A-A%-HV\,]^^,]s   !Ec                ^    [         R                  " [         R                  " [        5      SSS9$ )Nis_typezInput should be a typer  )r0   custom_error_schemara  r   r  s    r   r  GenerateSchema._type_schema  s)    ..**40'!9
 	
r   c                l    SSK Jn  SS /0n[        R                  " U[        R                  " 5       US9$ )z/Generate schema for a zone_info.ZoneInfo objectrR   )validate_str_is_valid_iana_tzrG  c                    SSS.$ )Nr~  zoneinfor  r   r  s     r   r;  1GenerateSchema._zoneinfo_schema.<locals>.<lambda>  s
    hZd=er   r   rK  )r  rV  r0   r  r  )r  rV  rK  s      r   r  GenerateSchema._zoneinfo_schema  s8    >+.e-fg;;)%::<
 	
r   c           	         U R                  USS9n[        R                  " U Vs/ s H  o R                  [        U   5      PM     sn5      $ s  snf )z*Generate schema for `type[Union[X, ...]]`.Tr  )r:  r0   r  r!  r   )r  r  rl  s      r   _union_is_subclass_schema(GenerateSchema._union_is_subclass_schema  sJ    44Z$4O''VZ([VZd)=)=d4j)IVZ([\\([s   !Ac           
     ,   U R                  U5      n[        R                  " U5      =(       d    Un[        R                  " U5      (       a  U R                  5       $ [        R                  " U5      (       a"  U R                  [        UR                     5      $ [        R                  " U5      (       a  UR                  (       a^  [        [        UR                  5      5      (       a  U R                  UR                  5      $ [        R                   " UR                  5      $ UR"                  (       aF  [        R$                  " UR"                   Vs/ s H  o0R                  [        U   5      PM     sn5      $ U R                  5       $ [        [        U5      5      (       a  U R                  U5      $ [        R&                  " U5      (       a  U R)                  U5      n[        R*                  " U5      (       a/  [-        SU< S[.        R0                  " [        U5      5       S3SS9e[2        R4                  " U5      (       d6  Uc$  [        R                   " [        R6                  5      $ [9        SU< 35      e[        R                   " U5      $ s  snf )z-Generate schema for a type, e.g. `type[int]`.z`Subscripting `type[]` with an already parametrized type is not supported. Instead of using type[z], use type[z].Nr   zExpected a class, got )rn  rW   annotated_typer7   r  r  r  r!  r   r  
is_typevar	__bound__r:   r5   r]  r0   is_subclass_schema__constraints__r  rv  rQ  is_generic_aliasrF   rV   display_as_typerZ  r  r  r   )r  type_
type_paramcs       r   r  GenerateSchema._subclass_schema  s   //6
 #11*=K
  ,,$$&&,,Z88''Z-A-A(BCC&&z22##":j.B.B#CDD99*:N:NOO"55j6J6JKK++"//XbXrXr0sXrST1E1Ed1g1NXr0stt((**Z
34411*==%%j11!44Z@
--j99'--7N,uG\G\]ghr]sGtFuuwy 
 ??:.. %&99-:P:PQQ"8 GHH11*==) 1ts   !Jc                   SSK Jn  U R                  U5      n[        R                  " U5      n[        U5      n[        R                  " [        R                  SS9n[        R                  " U5      (       d2  SSKJn  [        R                  " U[        R                  " Xt5      /5      n[        R                  " X#SS9n[        R                   " XVUS9$ )	z5Generate schema for a Sequence, e.g. `Sequence[int]`.rR   r  Sequencer  )sequence_validatorTr  )rA  ry  r   )r  r  r!  r0   r   r}   ra  r  rl  r7   r  r  rm  r  r  r  r  )	r  r#  r  r  r   rA  ry  rm  r   s	            r   r  GenerateSchema._sequence_schema  s    =//
;!--.>?$[1#66vQ[\$$Z007'44 K KL^ lmM $GG'4
 00#P]
 	
r   c                n    U R                  U5      n[        R                  " U R                  U5      5      $ )z$Generate a schema for an `Iterable`.)rn  r0   generator_schemar!  )r  rg  	item_types      r   r  GenerateSchema._iterable_schema  s.    ..u5	++D,@,@,KLLr   c                   SSK Jn  SS /0n[        R                  " [	        S5      S[        R
                  " 5       S9nU[        R                  L d  U[        R                  L a  [        R                  " UR                  XCS9$ U R                  US	S
9S   nU[        L a  [        R                  " UR                  XCS9$ U[        L a  [        R                  " UR                  XCS9$ [!        SU< S35      e)NrR   )r  rG  c                    SSS.$ )Nr~  regexr  r   r  s     r   r;  0GenerateSchema._pattern_schema.<locals>.<lambda>  s
    hZa=br   patternr   )r   return_schemarZ  Tr  r   r  r   )r   r  r0   r   r   r  r  Patternrer  pattern_either_validatorr:  r6  pattern_str_validatorr  pattern_bytes_validatorrD   )r  pattern_typer  rK  serrI  s         r   r  GenerateSchema._pattern_schema  s    !+.b-cd>>y!V;CYCYC[
 6>>)\RZZ-G??44C  55 6 
  C<??11  e^??333  02^_k^nno0pqqr   c           
     V   [         R                  " [         R                  " [         R                  " [         R                  " 5       [         R
                  " [        R                  R                  5      /5      [         R
                  " [        R                  R                  5      S9SSS9$ )Nrx  r  zInput should be hashable)r   r  r  )	r0   rS  r  r  r   ra  r  abcHashabler  s    r   r  GenerateSchema._hashable_schema  sy    ..44'44 ++-{/M/MkooNfNf/gh *<<[__=U=UV	 ,!;	
 		
r   c                
  ^ ^ T R                   R                  U5         T R                  R                  U5       u  nnUb  UsSSS5        sSSS5        $ UR                  R                  S5      nUb  [        U[        5      (       dw  US   S:X  a  T R                  R                  U5      n[        U5      nU(       a-  T R                  R                  U5      sSSS5        sSSS5        $ UsSSS5        sSSS5        $ [        U5      nUb  Un[        USS5      nSSKJn	  T R                  R                  U5         T R                   R                  U5         U	" U5      (       a  UR#                  5       (       at  UR$                  R'                  5        V
Vs0 s H  u  pU
[)        U5      _M     nn
nU(       a4  UR+                  5        H   nUR,                  " U/T R.                  Q76   M"     O@ [1        UT R2                  T R                  U=(       d    0 S9nO[;        UUT R2                  S	9nT R2                  R<                  S
:X  a6  UR'                  5        H"  u  pUR>                  SL d  M  [A        SU S3SS9e   UR                  R                  S5      mTc1  [B        RD                  " U5      mTRG                  T R2                  5        [I        UU 4S jUR'                  5        5       S S9n[K        US5      n[K        US5      n[L        RN                  " URP                  UTRR                  R+                  5        Vs/ s H  nT RU                  UTRV                  5      PM!     snUS9n[Y        UTRZ                  R+                  5       5      nTR\                  R+                  5       n[_        UUS5      nT R2                  Ra                  URP                  S9n[L        Rb                  " UUUUU[        Rd                  " U5       Vs/ s H  oRf                  PM     snUUT R                   Rh                  Rj                  S9	nT Rm                  UTRn                  R+                  5       5      n[_        UUS5      nT R                  R                  U5      sSSS5        sSSS5        sSSS5        sSSS5        $ s  snn
f ! [4         a  n[6        R8                  " U5      UeSnAff = fs  snf s  snf ! , (       d  f       O= fSSS5        O! , (       d  f       O= fSSS5        O! , (       d  f       O= fSSS5        g! , (       d  f       g= f)z Generate schema for a dataclass.Nr  r   r  r  r;   )is_pydantic_dataclassr  )r  r  r  FzField zd has `init=False` and dataclass has config setting `extra="allow"`. This combination is not allowed.z dataclass-init-false-extra-allowr   r1  c              3  L   >#    U  H  u  pTR                  XT5      v   M     g 7fr   )r  )rg  r   r   r   r  s      r   ri  3GenerateSchema._dataclass_schema.<locals>.<genexpr>j  s%     aR`$!T33A*EER`s   !$c                (    U R                  S5      SL$ )Nr   F)r   )rh  s    r   r;  2GenerateSchema._dataclass_schema.<locals>.<lambda>k  s    !%%	"2%"?r   )key__post_init__	__slots__)r"  collect_init_onlyr  r
  )r  r   rJ  r   slotsr!  r   r&  )8r   r,  r   r'  r(  r   rs  rv   r)  r\   r*  rr   r   r  r  r   r   r.  r  r   r	   rY  apply_typevars_mapr  rm   r  r/  rE   r0  rl   r   r   rF   r`   r  r  sortedhasattrr0   dataclass_args_schemar   r"  rA  r3  r   rB  r6  r=  r-  dataclass_schemar   r  r  r   rC  rD  )r  	dataclassr  dataclass_refrG  r   rJ  r  r!  r  f_namer  r   r   r  r'  rl  has_post_init	has_slotsrL  args_schemar   r6  r-  	dc_schemar   s   `                        @r   r   GenerateSchema._dataclass_schema  s   
 !!&&y1II''	2 7 '# 32 21 ''++,FGF!*V^*L*L&>]2!YY99&AFfo99GGO 32 21" "! 32 21& 5Y?L!"	
 Y(=tDF;""''	2D4N4N4S4STZ4[(33 ==?? PYOlOlOrOrOt"Ot9KFD$44Ot  " ()/ % 8 8 ^H]H] ^ *9X%= )/3/C/C,0,=,=-9-?R	&F 6!%1'+';';F ''--8-3\\^)
 ::."3"( 5C !D%G#  .< '//334MN
%!/!5!5i!@J11$2F2FG aRXR^R^R`a? !(	? C#I{;	)??&& ",!;!;!B!B!D%!DA 33Az7S7ST!D% '4  0Z=W=W=^=^=`a#-#>#>#E#E#G 5lDTV]^"22>>YEWEW>X'88 #)+%4?4F4Fy4QR4Q5JJ4QR#&  55::AA	 66y*B^B^BeBeBgh/8H'RyyCCFKk 5\4[22; 32 21J"  ) X"="M"Ma"PVWWXF%( SY 5\4[222; 322 211s   UT(	UBT(	U+T(,	U?>T(=TA S4	R;1?S4	1)SAS4	0CS4	&S*)B!S4	
S/A7S4		T	T((	U;S4	
S'S""S''S4	4
T>T	T(
TT(	U(
T6	2U
Uc                J   U R                  U5      nSnU R                  nUR                  (       a^  [        U5      nUR                  nXeR
                  La9  U R                  u  px[        R                  " XUS1S9n	U R                  U	S   5      n[        R                  " UUUS9$ )zcGenerate schema for a Callable.

TODO support functional validators once we support them in Config
NrV  )globalnslocalnsinclude_keys)rx  )_arguments_schemar  validate_returnr   return_annotationr7  r  rW   get_function_type_hintsr!  r0   r8  )
r  functionr3  rx  r  sigreturn_hintr  r  
type_hintss
             r   r  GenerateSchema._call_schema  s    
  11(;7;--))H%C//K))+$($9$9!*BBPXz
 !% 4 4Z5I J&&'
 	
r   c                .   [         R                  S[         R                  S[         R                  S0n[	        U5      nU R
                  u  pV[        R                  " XUS9n/ nSn	Sn
Sn[        UR                  R                  5       5       GHT  u  nu  pUR                  UR                  L a   [        R                  " [        [        5      nOX}   nUb  U" XU5      nUS:X  a  MZ  UR!                  UR"                  5      nUb?  U R%                  X[&        R(                  UR*                  U5      nUR-                  U5        M  UR"                  [         R.                  :X  a  U R1                  U5      n	M  UR"                  [         R2                  :X  d   UR"                  5       e[        R4                  " U5      nUGb  [7        U5      =(       d    Un[9        U5      (       d  [;        SU< 3SS	9eUR                  R                  5        VVs1 s H'  u  pUR"                  [         R                  :w  d  M%  UiM)     nnnUR=                  UR>                  5      nU(       aN  [;        S
UR@                  < S[C        U5      S:  a  SOS SSRE                  S [G        U5       5       5       3SS	9eSnU RI                  U[7        U5      5      n
GMA  SnU R1                  U5      n
GMW     [J        RL                  " UU	UU
U RN                  RP                  S9$ s  snnf )z Generate schema for a Signature.positional_onlypositional_or_keywordkeyword_onlyr  r  Nskip7Expected a `TypedDict` class inside `Unpack[...]`, got unpack-typed-dictr   Typed dictionary  overlaps with parameterr;   r  r   r
  r  c              3  8   #    U  H  n[        U5      v   M     g 7fr   r  rg  ps     r   ri  3GenerateSchema._arguments_schema.<locals>.<genexpr>       (U:TQa:Tr  overlapping-unpack-typed-dictzunpacked-typed-dictuniform)var_args_schemavar_kwargs_modevar_kwargs_schemavalidate_by_name))r   POSITIONAL_ONLYPOSITIONAL_OR_KEYWORDKEYWORD_ONLYr   r  rW   r  	enumerate
parametersr   r  r7  r  r%   r   r   kindr4  r8   FUNCTIONr   r  VAR_POSITIONALr!  VAR_KEYWORDunpack_typer5   r6   rF   intersectionr  r   rq  r  r  r  r0   r3  r  r  )r  r  parameters_callbackmode_lookupr  r  r  r  arguments_listr  r  r  ir  r  r  resultparameter_mode
arg_schemar  r  non_pos_only_param_namesoverlapping_paramss                          r   r   GenerateSchema._arguments_schema  s   
 %%'8++-D""Nr
 ! 11"::8`gh
?A9=;?<@%cnn&:&:&<=LAy||syy(#[[c2
'-
".,QjAV#(__QVV4N)!<<&6&?&?N
 %%j19333"&"6"6z"Bvv!6!66>>6+77
C*'4CF'///UVaUde!4 
 -0NN,@,@,B0,BaffPYPiPiFi,B - 0 *B)N)NvOeOe)f&)///BBZ&)*<&=&BsK1#yy(U&AS:T(UUVX "A	  '<O(,(?(?ZXcMd(e%&/O(,(<(<Z(H%] >` ++++/!11BB
 	
%0s   $L4Lc                   [         R                  S[         R                  S[         R                  S[         R                  S0n[        U5      nU R                  u  pV[        R                  " XUS9n/ n[        UR                  R                  5       5       GH   u  n	u  pUb  U" XUR                  5      nUS:X  a  M'  UR                  [         R                  L a   [        R                  " [         [         5      nOXz   nUR#                  UR$                  5      nUGc?  UR$                  [         R&                  :X  d   UR$                  5       e[        R(                  " U5      nUb  [+        U5      =(       d    Un[-        U5      (       d  [/        SU< 3SS	9eUR                  R                  5        V
Vs1 s H'  u  pUR$                  [         R                  :w  d  M%  U
iM)     nn
nUR1                  UR2                  5      nU(       aN  [/        S
UR4                  < S[7        U5      S:  a  SOS SSR9                  S [;        U5       5       5       3SS	9eSnUnOSnUR=                  U R?                  W
U[@        RB                  UWRD                  S95        GM     [F        RH                  " UU RJ                  RL                  S9$ s  snn
f )Nr  r  var_argsr  r  r  r  r  r   r  r  r;   r  r   r
  r  c              3  8   #    U  H  n[        U5      v   M     g 7fr   r  r  s     r   ri  6GenerateSchema._arguments_v3_schema.<locals>.<genexpr>'  r  r  r  var_kwargs_unpacked_typed_dictvar_kwargs_uniform)r   )r  )'r   r  r  r  r  r   r  rW   r  r  r  r   r  r7  r  r%   r   r   r  r  r  r5   r6   rF   r  r  r   rq  r  r  r  rE  r8   r  r   r0   arguments_v3_schemar  r  )r  r  r  r  r  r  r  r  parameters_listr  r  r  r  r  r  r  r  r  r  s                      r   _arguments_v3_schema#GenerateSchema._arguments_v3_schema  s    %%'8++-D$$j""N	
 	 ! 11"::8`gh
BD%cnn&:&:&<=LAy".,QallCV#||y.#[[c2
'-
(__QVV4N%vv!6!66>>6+77
C*'4CF'///UVaUde!4 
 -0NN,@,@,B0,BaffPYPiPiFi,B - 0 *B)N)NvOeOe)f&)///BBZ&)*<&=&BsK1#yy(U&AS:T(UUVX "A	  &FN!,J%9N""22*&6&?&?YZYbYb 3 O >Z ..!11BB
 	
-0s   4$KKc                    UR                  5       nU(       a  U R                  UR                  5      $  UR                  =n(       a"  U R                  [        R                  U   5      $ UR                  =n(       a,  U R                  U5      n[        R                  " S5      US'   U$ [        R                  " 5       $ ! [         a     Nf = f)Nr  r   )has_defaultr!  __default__r  rd  r  r  r$   rb  r0   r]  r   )r  typevarr  constraintsr   r   s         r   r  ,GenerateSchema._unsubstituted_typevar_schema:  s    	A!--/K
 ++G,?,?@@  "111;1%%fll;&?@@%%%5%))%0F&1&C&CE&JF?#M%%''  		s   B> >
C
Cc                   UR                   R                  [        La  UR                   R                  nO4 [        R                  " UR
                  U R                  R                  S9nU[        L a
  [        SSS9e[        X0R                  5      n[        R                  " UR                   US9Ul         U R!                  U5      nU R#                  U[%        UR'                  5       UR(                  5      5      n[+        UR                   5      u  pg0 n[-        USS0U(       a  UO0 EUS9  [.        R0                  " UR(                  XQR                   R2                  US	9$ ! [         a  n[        R                  " U5      UeS nAff = f)
Nr  zComputed 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-annotationr   )return_typereadOnlyTr  )rx  r   rK  )r   r  r.   rS   get_callable_return_typefuncr  localsr/  rE   r0  rF   rs   r   r  replacer!  r  r   rY  r   r   r[   r0   computed_fieldr   )	r  rL  r3  r  r  return_type_schemar  r  r  s	            r   rA  %GenerateSchema._computed_field_schemaN  sk   
 66%66&&,,KL *BB166SWShShSoSop ++#f5  $K1C1CD $$QVVE!11+>!::01B1I1I1KQ^^\

 2[[\[a[a1b.(*!+T jM`6Ifh j/	

 ))NN*<FFLL[h
 	
7  L1AA!D!KLs   3E 
F)F  Fc                    [        5       nU R                  USS9tp4U R                  X45      nU H   n[        Xb5      (       d  M  [	        Xe5      nM"     U$ )zdGenerate schema for an Annotated type, e.g. `Annotated[int, Field(...)]` or `Annotated[int, Gt(0)]`.Tr  )ru   r:  r  rs  r  )r  r`  r   r  r   r   r  s          r   rx   GenerateSchema._annotated_schemaz  sc    ,.	$($I$I %J %
! ((B &J*00%j9 & r   c                    U $ r   r   r9  s    r   r;  GenerateSchema.<lambda>  s    qr   c                L  ^ ^^ [        [        R                  " U5      5      n/ nSU UU4S jjn[        UT 5      nU H  nUc  M  T R	                  UUUUS9nM     U" T5      n	U(       a  U	R                  S0 5      n
[        XS9  [        T R                  R                  TU	5      $ )ad  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                   > TR                  U T5      nUc  TR                  U 5      n[        U 5      nUb*  [        UTR                  5      nUb  TR                  X25        T" U5      $ r   )r   r  r  r  r   r  )r  r   r  r  r  r  r  s       r   inner_handler8GenerateSchema._apply_annotations.<locals>.inner_handler  sj    AA#{SF~44S9#DS#I #/"9&$))"L".))/P)&11r   r=  rK  ) pydantic_js_annotation_functionsr  r   rV  r*   )
rW  rU   expand_grouped_metadatar{   _get_wrapped_inner_schemar  r[   r   r  r   )r  r  r   r  r>  r  r  get_inner_schemar  r   r  s   `` `       r   r  !GenerateSchema._apply_annotations  s     4LL[YZHJ(	2 	2 8tL%J!#== 08_	  >   & "+.+"--j"=M r;D<P<P<^<^`kmsttr   c           
        [        5       n[        X$5      (       a  U(       a  [        U5      UL a  U R                  U5      =n H+  u  pg[        R
                  " SU< SU< SU< S3[        S9  M-     UR                  (       a:  U R                  R                  5       c  SU;  a  [        R
                  " S[        S9  UR                   H  nU R                  X5      nM     UR                  b  U R                  XR                  5      nU$ US   S	:X  aC  UR                  S
[        R                  " 5       5      n	U R                  X5      n	U	(       a  XS
'   U$ Un
UR                  S5      nUbF  UR!                  5       nUS[#        U5       3-   nU R$                  R'                  U5      =nb  U$ XS'   OqUS   S:X  ah  US   nU R$                  R'                  U5      =nbE  UR!                  5       nUS[#        U5       3-   nU R$                  R'                  U5      =nb  U$ XS'   [(        R*                  " X!5      nUb  U$ U
$ )NzThe z attribute with value zY was provided to the `Field()` function, which has no effect in the context it was used. a   is field-specific metadata, and can only be attached to a model field using `Annotated` metadata or by assignment. This may have happened because an `Annotated` type alias using the `type` statement was used, or if the `Field()` function was attached to a single member of a union type.r  defaut_factoryzA 'default_factory' taking validated data as an argument was provided to the `Field()` function, but no validated data is available in the context it was used.r   r   r   rJ  rO  definition-refru  )ru   rs  r   &_get_unsupported_field_info_attributesr   r   rQ   $default_factory_takes_validated_datar   r   rK  _apply_single_annotationr  r  r0   r   r	   r   r   get_schema_from_refrU   apply_known_metadata)r  r   rK  r>  r   unsupported_attributesattrrL  field_metadatar  rB  rJ  new_refexistingreferenced_schemamaybe_updated_schemas                   r   r  'GenerateSchema._apply_single_annotation  sO    -.	h**7 Ni/>B>i>ijr>s$s$:$sKDMMth&<UI FKKO( Snn
 "B %t AA--113;(0FFMMY!A #+"3"366vN #4 %%1;;FDZDZ[M&>Z'JJx)?)?)ABE11%BE#(x M jj?[[]FaX/00G II99'BBO#5MF^//&C%)YY%B%B3%GG!T*//1!DN#3 44 $		 = =g FFHS#O 'u8MMh_+''r   c                    [        5       n[        X#5      (       aM  UR                   H  nU R                  X5      nM     [	        U5      u  pVUR                  S0 5      n[        XuUS9  U$ )NrK  r  )ru   rs  rK  $_apply_single_annotation_json_schemar   r  r[   )r  r   rK  r   r  r  r  r  s           r   r  3GenerateSchema._apply_single_annotation_json_schema	  sp     -.	h**"*"3"3BB6Z #4 6__g5h2"--j"=M Zk r   c                    / n[          Hc  u  p4[        X5      =oTLd  M  US;  d  U R                  R                  5       c  M9  US;  d  SUR                  ;  d  MQ  UR                  X545        Me     U$ )zoGet the list of unsupported `FieldInfo` attributes when not directly used in `Annotated` for field annotations.)r   r   )r   r   r   )r   r   r   r   _attributes_setr  )r  r  unused_metadataunused_metadata_nameunset_valueunused_metadata_values         r   r   5GenerateSchema._get_unsupported_field_info_attributes	  s|    131\- *1**SS&g )0NN,,002> )0[[j&@&@@  &&(<'TU 2]" r   c                Z   ^ ^^^^^ [        TSS 5      mSUUUUUU 4S jjn[        UT 5      $ )NrT  c                   > Tb
  T" U T5      nO+T" U 5      nTR                  UTTS9nTR                  UT5      n[        T5      nUb  TR                  U5        U$ )Nr=  )r  r  r  r  )	r  r   r  r  annotation_get_schemar>  r  r  r  s	      r   new_handler=GenerateSchema._get_wrapped_inner_schema.<locals>.new_handler2	  sw    $0.v7GH)&166<c 7 
 BB6:V#DZ#P #/0778LMMr   )r  r   rV  core_schema.CoreSchema)r   r{   )r  r  r  r  r>  r  r  s   ````` @r   r  (GenerateSchema._get_wrapped_inner_schema)	  s0     ?FjRprv>w	 	" ,K>>r   c                   U(       Ga  [        U5      nUS   S:X  a  US   nU R                  X25      US'   U$ SU;   a  U R                  R                  U5      nUS   n[	        UR
                  UR                  R                  5      u  pVUR                  R                  [        La  UR                  R                  nO4 [        R                  " UR
                  U R                  R                  S9nU[        L a  Sn	OU R#                  U5      n	UR                  R                  S:X  a;  [$        R&                  " UR
                  UUU	UR                  R(                  S	9US
'   U$ UR                  R                  S:X  d   e[$        R*                  " UR
                  UUU	UR                  R(                  S	9US
'   U$ ! [         a  n[        R                   " U5      UeSnAff = f)z$Apply field serializers to a schema.r   r  r   rJ  r   r  Nr   )is_field_serializerr|  rx  r   r   r   )r	   r  r   r*  rh   r  r   rt  r  r.   rS   r  r  r  r/  rE   r0  r!  r0   r  r   r   )
r  r   serializersr   
serializerr  r|  r  r  rx  s
             r   r  'GenerateSchema._apply_field_serializersE	  s    &\Ff~.%h/#'#@#@#[x &EEfM %RJ,DZ__V`VeVeVjVj,k)**2CC(oo99P #."F"F"1F1F1M1M#K // $ $ 4 4[ A##v-*5*Y*YOO(;%"/(oo77+'   "++w666*5*Z*ZOO(;%"/(oo77+' 3 ! P5EEaHaOPs   ?3F; ;
G!GG!c                .   UR                  SS5      nU(       GaF  [        U5      S   n[        UR                  UR                  R
                  5      nUR                  R                  [        La  UR                  R                  nO4 [        R                  " UR                  U R                  R                  S9nU[        L a  SnOU R                  U5      nUR                  R
                  S:X  a6  [         R"                  " UR                  UUUR                  R$                  S9n	O5[         R&                  " UR                  UUUR                  R$                  S9n	XS'   U(       a  X1S'   U$ ! [         a  n[        R                  " U5      UeSnAff = f)z$Apply model serializers to a schema.rJ  Nr   r  r   )r|  rx  r   r   )poprW  ri   r  r   rt  r  r.   rS   r  r  r  r/  rE   r0  r!  r0   r  r   r   )
r  r   r   rJ  r!  r|  r  r  rx  
ser_schemas
             r   rC  'GenerateSchema._apply_model_serializers}	  sW    !**UD1k*2.J/
AUAUVH**2CC(oo99P #."F"F"1F1F1M1M#K // $ $ 4 4[ A##v-4?4c4cOO%"/(oo77	5
 )MMOO%"/(oo77	
 '1?#5M5 ! P5EEaHaOPs   3E. .
F8FF)r   r   r   r   r   r   )NN)r  rX   r  zNsResolver | Noner  zMapping[TypeVar, Any] | NonerV  NonerV  r'  )rV  rX   )rV  rw   )rV  r   )r#  r   rV  r*   )r(  r   r)  r   rV  r*   )rR  z
type[Enum]rV  r*   )r   r   rV  r*   )r   r   r  r   rV  r*   )r   r   r(  r   r)  r   rV  r*   )rV  r*   r  )r   r*   r  zstr | Discriminator | NonerV  r*   r  )r  r*   r  zCallable[..., Any]rV  r'  )r  r   rV  r  )r  ztype[BaseModel]rV  r  )r  r   rV  r   )r  r   r  r   rV  zcore_schema.CoreSchema | None)r  r   r  zLiteral[True]rV  ztuple[Any, ...])r  r   rV  tuple[Any, ...] | None)F)r  r   r  r   rV  r)  )r  r   rV  ztuple[Any, Any])r  r   r  r   rV  r*   )
r  r6  r  r   r   r`   r  r   rV  zcore_schema.TypedDictField)r  r6  r  r   r   r`   rV  zcore_schema.ModelField)r  r6  r  r   r   r`   rV  zcore_schema.DataclassField)r  r6  r  r   r   r`   rV  z!tuple[CoreSchema, dict[str, Any]])r  r   rV  r  )r  r3   rV  r*   )r  r   rV  r*   )r"  r   r  r   rV  r  )r9  r   r  r   rV  r  )r  r6  r  z	type[Any]r  r8   r   r   rt  zJLiteral['positional_only', 'positional_or_keyword', 'keyword_only'] | NonerV  zcore_schema.ArgumentsParameter)r  r6  r  r   r  r8   rt  zLiteral['positional_only', 'positional_or_keyword', 'keyword_only', 'var_args', 'var_kwargs_uniform', 'var_kwargs_unpacked_typed_dict']r   r   rV  z core_schema.ArgumentsV3Parameter)rN  r   rV  r  )rV  r  )rg  r   rV  r  )r#  r   rV  r  )rg  r   rV  zcore_schema.GeneratorSchema)r~  r   rV  r  )r  ztype[StandardDataclass]r  ztype[StandardDataclass] | NonerV  r  )r  ValidateCallSupportedTypesrV  zcore_schema.CallSchemar   )r  r*  r  ParametersCallback | NonerV  zcore_schema.ArgumentsSchema)r  r*  r  r+  rV  zcore_schema.ArgumentsV3Schema)r  ztyping.TypeVarrV  r  )rL  zDecorator[ComputedFieldInfo]r3  z2dict[str, Decorator[FieldSerializerDecoratorInfo]]rV  zcore_schema.ComputedField)r`  r   rV  r  )
r  r   r   z	list[Any]r  z"Callable[[CoreSchema], CoreSchema]r>  r   rV  r*   )T)r   r  rK  r   r>  r   rV  r  )r   r  rK  r   rV  r  )r  r   rV  r   )
r  r>   r  r   r  zlist[GetJsonSchemaFunction]r>  r   rV  r{   )r   r  r   z-list[Decorator[FieldSerializerDecoratorInfo]]rV  r  )r   r  r   z1Iterable[Decorator[ModelSerializerDecoratorInfo]]rV  r  )Mr   r   r   r   r   r  r	  r  propertyr  r  r  r$  r*  r.  r2  rd  r  r  r  r  r  r  r  r  r  r  r!  rN  rQ  r   r`  r&   r:  rn  rr  r  r{  r  r  r@  r  r<  r  r  r  r  r  r   r7  r4  rE  r  r  r  r]  r  r  r  r  r  r  r  r  r  r  rA  rx  r  r  r  r   r  r  rC  r   __classcell__)r   s   @r   r   r   O  s   fI *.59	#%# '# 3	#
 
#
 / / 1 1 < <
IkHNFP
B8t
2,\
"
2	
 1K	&1	/%% 
 %NLL\9wv, i iW W	 $8v.p1.r 

 
 #	
 
 
$
(

 
 #	

 
 
$

 
 #	

 
$
,7%7%%.7%<J7%	*7%r6H&ILV*Hb ![_+ +  +  !	+ 
 +  Y+  
(+ t !0 0  0  !	0 

0  0  
*0 d_<
	
]
%>N
.Mr8

xL0xL:XxL	xLt
4 fjI
2I
IbI
	$I
X fjB
2B
IbB
	&B
H((*
'*
 N*
 
#	*
X& FQ8<.u.u .u !C	.u
 26.u 
.uh 9=	H&H H 26	H
 
 HT,8;	 6 9>?.? ? +F	?
 26? 
&?86&6 C6 
 	6p-,-;l-	- -r   r   c                .    [         R                  " X5      $ r   )r0   !no_info_before_validator_functionr  r   s     r   r;  r;  	      [-Z-Z[\-er   c                .    [         R                  " X5      $ r   )r0   r`  r0  s     r   r;  r;  	  s    K,X,XYZ,cr   c                .    [         R                  " U 5      $ r   )r0   r  r  rO  s     r   r;  r;  	  s    {'S'STU'Vr   c                .    [         R                  " X5      $ r   )r0   r  r0  s     r   r;  r;  	  s    ;+V+VWX+ar   c                .    [         R                  " X5      $ r   )r0   #with_info_before_validator_functionr0  s     r   r;  r;  	  s    {/^/^_`/ir   c                .    [         R                  " X5      $ r   )r0   "with_info_after_validator_functionr0  s     r   r;  r;  	  s    k.\.\]^.gr   c                .    [         R                  " U 5      $ r   )r0   rY  r4  s     r   r;  r;  	  s    )W)WXY)Zr   c                .    [         R                  " X5      $ r   )r0   !with_info_wrap_validator_functionr0  s     r   r;  r;  	  r1  r   ))r   no-info)r   r=  )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], core_schema.CoreSchema]]_VALIDATOR_F_MATCHc                    U Hg  n[        UR                  UR                  R                  SS9nU(       a  SOSn[        UR                  R                  U4   " UR                  U 5      n Mi     U $ )zApply 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   rt  r   r>  r=  )rj   r  r   rt  r?  )r   r4  	validatorr|  val_types        r   r   r   	  sb       	 %Y^^)..:M:MT[\"*;	#Y^^%8%8($CDY^^U[\   Mr   c                P    U  H   nUR                   R                  (       d  M     g   g)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)r   rz  )r4  rB  s     r   r  r  	  s&      	>>      r   c                \    [        U [        [        45      (       a  U R                  5       $ U $ r   )rs  r<   r=   convert_to_aliases)r   s    r   r  r  	  s*     %,	233''))r   c                   U R                  SS5      nU GH  nUS:X  a  UR                  R                  S:w  a  M&  US:X  a  UR                  R                  S:X  a  MH  [        UR                  UR                  R                  SS9nUR                  R                  S:X  aI  U(       a!  [
        R                  " UR                  U S	9n M  [
        R                  " UR                  U S	9n M  UR                  R                  S:X  aK  U(       a"  [
        R                  " UR                  U S	9n GM  [
        R                  " UR                  U S	9n GM9  UR                  R                  S
:X  d   eU(       a"  [
        R                  " UR                  U S	9n GM~  [
        R                  " UR                  U S	9n GM     U(       a  X0S'   U $ )ak  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.
rJ  Nr  r   r&  modelrA  r   )r  r   r   )r$  r   rt  rj   r  r0   r<  r  r7  r/  r9  r`  )r   r4  rt  rJ  rB  r|  s         r   r=  r=  	  s]   & jj-C	7?y~~22h>7?y~~22h>$Y^^)..:M:MT[\>>&($FFPYP^P^gmn$DDinnekl^^  H,$HHR[R`R`iop$FFPYP^P^gmn>>&&'111$GGQZQ_Q_hno$EEy~~flm+  , uMr   c                   U R                   (       a>  [        R                  " UU R                   [        U R                   5      U R                  S9$ U R
                  [        La)  [        R                  " XR
                  U R                  S9$ U$ )zWrap 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`.
)r   default_factory_takes_datar   )r   r   )r   r0   with_default_schemaro   r   r   r.   )r  r   s     r   r  r   
  s     !!..&66'DZE_E_'`'88	
 	
 
		#4	4....A\A\
 	
 r   c                P   [        U SS5      n[        U S5      (       aj  [        5       nUSL=(       a&    UR                  R                  U[        USS5      4;  nU(       d(  [        U SS5      n[        SU(       a  SU S3OS	 S
3SS9e[        U 5      =nb  [        U5      $ Uc  gU$ )z`Extract `__get_pydantic_json_schema__` from a type, handling the deprecated `__modify_schema__`.__get_pydantic_json_schema__N__modify_schema__rF  r   zjThe `__modify_schema__` method is not supported in Pydantic v2. Use `__get_pydantic_json_schema__` insteadz in class ``r   r   zcustom-json-schemar   )r   r  rt   rM  rF  rF   r5   r  )r   js_modify_functionr   has_custom_v2_modify_js_funccls_namer  s         r   r  r  9
  s     %CTJr&'',.	 d* W66??&0BJPT(UVW 	% ,r:t4H#=Zb{8*TU=Vhj<kkln)  R. - 188!r   r  c                \    U S   S:X  a  UR                  U S   5      $ U S   S:X  a  U S   $ U $ )Nr   r  ru  r  r   )r  r   r  s     r   r  r  Y
  sA    f~))..vl/CDD	=	(hr   c                p    SU ;   a  gU R                  S5      nU(       d  g[        U5      S:X  a  SU;   a  gg)a  Determine the inlining behavior of the `'definition-ref'` schema.

- If no `'serialization'` schema and no metadata is attached, the schema can safely be inlined.
- If it has metadata but only related to the deferred discriminator application, it can be inlined
  provided that such metadata is kept.
- Otherwise, the schema should not be inlined. Doing so would remove the `'serialization'` schema or metadata.
r   keeprK  inlinerR   %pydantic_internal_union_discriminatorpreserve_metadata)r   rq  )def_refrK  s     r   _inlining_behaviorr[  b
  s=     '!{{:&H
8}EQ"r   c                      \ rS rSr% SrS\S'    S\S'    SS jr\SS j5       rSS	 jr	SS
 jr
SS jrSS jrSS jrSrg)r  iv
  z*Keeps track of references and definitions.zset[str]_recursively_seenz!dict[str, core_schema.CoreSchema]r  c                0    [        5       U l        0 U l        g r   )r   r]  r  r  s    r   r	  _Definitions.__init__
  s    !$r   c             #  N  #    [        U5      nX R                  ;   d  X R                  ;   a  U[        R                  " U5      4v   gU R                  R                  U5         US4v   U R                  R                  U5        g! U R                  R                  U5        f = f7f)aT  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:

- Pydantic model
- Pydantic and stdlib dataclasses
- Typed dictionaries
- Named tuples
- `TypeAliasType` instances
- Enums
N)r]   r]  r  r0   ry  adddiscard)r  r   rJ  s      r   r'  _Definitions.get_schema_or_ref
  s     , 2(((C3D3D,D??DEE""&&s+4Dk!&&..s3&&..s3s   A B%#B )B%B""B%c                8    U R                   R                  U5      $ )z,Resolve the schema from the given reference.)r  r   )r  rJ  s     r   r   _Definitions.get_schema_from_ref
  s      $$S))r   c                T    US   nXR                   U'   [        R                  " U5      $ )zStore the schema as a definition and return a `'definition-reference'` schema pointing to it.

The schema must have a reference attached to it.
rJ  )r  r0   ry  )r  r   rJ  s      r   r*  /_Definitions.create_definition_reference_schema
  s,    
 Um!'#66s;;r   c                F    US    H  nX R                   US   '   M     US   $ )zZStore the definitions of the `'definitions'` core schema and return the inner core schema.r  rJ  r   )r  )r  r   
def_schemas      r   r)  _Definitions.unpack_definitions
  s/     /J3=j/0 0hr   c                .   U R                   n [        UUS9n0 nUS   R	                  5        H  u  pgUb  [        U5      =nS:w  a  US:X  a2  UR                  5         UR                  U R                  Xb5      5        MQ  US:X  aG  UR                  S5      n	UR                  5         UR                  U R                  Xb5      5        XS'   M  M  U R                  Xb5      XV'   M     US    Hc  n
U
S   R                  S	S5      nUc  M  [        R                  " U
R                  5       X5      nU
R                  5         U
R                  U5        Me     U(       a%  [        R                  " U/ UR                  5       QS
9nU$ ! [         a  n[        UeSnAff = f)zFinalize the core schema.

This traverses the core schema and referenced definitions, replaces `'definition-ref'` schemas
by the referenced definition if possible, and applies deferred discriminators.
)r  Ncollected_referencesrV  rW  rY  rK  deferred_discriminator_schemasrX  rT  )r  rz   ry   r   r   r[  clearr?  _resolve_definitionr$  rT   r  r	   r0   definitions_schemarY  )r  r   r  gather_resultr  remaining_defsrJ  inlinable_def_refinlining_behaviormetacsr  applieds                r   r  _Definitions.finalize_schema
  s    ''	,7'M 13 '44J&K&Q&Q&S"C ,GYZkGl2l2Cqw1w$0
 &++-%,,T-E-Ec-WX&*== -00<D%++-%,,T-E-Ec-WX48j1 > '+&>&>s&P#+ 'T.   @AB(*:(:(:;bdh(iM$ *>>rwwy-hGHHJIIg B  336OiQ_QfQfQhOijFY & 	,$!+	,s   
E> >
FFFc                    X!   nUS   S:w  a  U$ [        5       nUS   S:X  aU  [        U5      S:X  aF  US   nXT;   a  [        U S3SS9eUR                  U5        X%   nUS   S:X  a  [        U5      S:X  a  MF  0 UESU0E$ )	Nr   r  rW  ru  z) contains a circular reference to itself.zcircular-reference-schemar   rJ  )r   r[  rF   ra  )r  rJ  r  
definitionvisitedru  s         r   ro   _Definitions._resolve_definition
  s     %
f!11  E $449KJ9W[c9c#L1J$'eDELg  KK
#$0J  $449KJ9W[c9c **)eS))r   )r  r]  Nr(  )r   r   rV  zCGenerator[tuple[str, core_schema.DefinitionReferenceSchema | None]])rJ  r6  rV  CoreSchema | None)r   r*   rV  %core_schema.DefinitionReferenceSchema)r   zcore_schema.DefinitionsSchemarV  r*   r  )rJ  r6  r  zdict[str, CoreSchema]rV  r*   )r   r   r   r   r   r  r	  r   r'  r  r*  r)  r  ro  r   r   r   r   r  r  v
  sQ    4 43 4 4@*< 8t*r   c                  @    \ rS rSrSrSS jr\SS j5       rS	S jrSr	g)
r  i  _stackc                    / U l         g r   r  r  s    r   r	  _FieldNameStack.__init__  s	    !#r   c              #  ~   #    U R                   R                  U5        S v   U R                   R                  5         g 7fr   r  r  r$  )r  r'  s     r   r,  _FieldNameStack.push  s(     :&   ;=c                D    U R                   (       a  U R                   S   $ g Nr   r  r  s    r   r   _FieldNameStack.get      ;;;;r?"r   Nr(  )r'  r6  rV  Iterator[None])rV  z
str | None
r   r   r   r   r  r	  r   r,  r   r   r   r   r   r  r    s%    I$  
r   r  c                  @    \ rS rSrSrSS jr\SS j5       rS	S jrSr	g)
r  i#  r  c                    / U l         g r   r  r  s    r   r	  _ModelTypeStack.__init__&  s	    "$r   c              #  ~   #    U R                   R                  U5        S v   U R                   R                  5         g 7fr   r  )r  type_objs     r   r,  _ModelTypeStack.push)  s(     8$r  c                D    U R                   (       a  U R                   S   $ g r  r  r  s    r   r   _ModelTypeStack.get/  r  r   Nr(  )r  r   rV  r  )rV  ztype | Noner  r   r   r   r  r  #  s%    I%  
r   r  )r   FieldDecoratorInfor   r6  rV  r   )r   zIterable[AnyFieldDecorator]r   zIterable[str]rV  r'  )r   z+Iterable[Decorator[FieldDecoratorInfoType]]r   r6  rV  z'list[Decorator[FieldDecoratorInfoType]])r   r  r   z'list[Decorator[ValidatorDecoratorInfo]]rV  r  )r   zFieldInfo | ComputedFieldInforV  zAtuple[JsonDict | None, JsonDict | JsonSchemaExtraCallable | None])r   zJsonEncoders | Noner   r   r   r*   rV  r*   )r   r  r4  zIterable[Decorator[RootValidatorDecoratorInfo]] | Iterable[Decorator[ValidatorDecoratorInfo]] | Iterable[Decorator[FieldValidatorDecoratorInfo]]rV  r  )r4  z+Iterable[Decorator[ValidatorDecoratorInfo]]rV  r   )r   z%str | AliasChoices | AliasPath | NonerV  z4str | list[str | int] | list[list[str | int]] | None)r   r  r4  z0Iterable[Decorator[ModelValidatorDecoratorInfo]]rt  z Literal['inner', 'outer', 'all']rV  r  )r  r   r   r  rV  r  )r   r   rV  zGetJsonSchemaFunction | None)r   r*   r  r  rV  r}  )rZ  r~  rV  z.Literal['inline', 'keep', 'preserve_metadata'](  r   
__future__r   _annotationscollections.abcr  r  r  rZ  r  r  rz  sysr  r   r   r   r   r   
contextlibr   r	   decimalr
   enumr   	fractionsr   	functoolsr   r   r   r   	ipaddressr   r   r   r   r   r   	itertoolsr   operatorr   typesr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   uuidr'   rX  r(   r  pydantic_corer)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   typing_inspectionr7   typing_inspection.introspectionr8   r9   r:   aliasesr<   r=   annotated_handlersr>   r?   r!  r@   rA   rB   rC   errorsrD   rE   rF   functional_validatorsrG   rH   rI   rJ   rK   rA  rL   versionrM   rN   rO   rP   rQ   r   rS   rT   rU   rV   rW   _configrX   rY   _core_metadatarZ   r[   _core_utilsr\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   _docs_extractionrk   r2  rl   rm   rn   ro   rp   _forward_refrq   	_genericsrr   rs   _import_utilsrt   ru   _mock_val_serrv   _namespace_utilsrw   rx   _schema_gatherry   rz   _schema_generation_sharedr{   _utilsr|   r}   r   r~   r   mainr   r   _dataclassesr   r   version_infor  r  r   AnyFieldDecoratorr   r  r   r   Tupler   r   ListrW  r  MutableSequencer   Setr   
MutableSetr   	FrozenSet	frozensetr   Dictr   r   r   rl  r   r   Typer   r   ry  r   r  Pathr  	PosixPathPurePosixPathPureWindowsPathr   MutableMappingOrderedDictDefaultDictr  r  Counterr  r  r  r   r*  r  r   r   r   r   r   r   r   JsonEncodersr   	Exceptionr   r   r?  r   r  r  r=  r  r  r  r[  r  r  r  r   r   r   <module>r     s   3 2     	  	 
   B B %      8 8 f f   D D     
 
 
 [ Z , a a - K O O b b w w ) #  a ` 6 > 
    :  / ? M ) 9 O C 65 %/@&&'1 13NPllm  !9AST $%)**+-  *> Y =#+S2M,NP[PfPf,f#g y g S I S!<</Z / ++t[__-L-LM
J MS+//*D*DE	: E & 0 0)[__=P=PQ * Q ++t,
J ,#]Km]hi* i$oo{/G/GH
 H$oo{/G/GIYIY[f[j[j[t[tu
 u ++t,
J ,#^^RZZ8z 8KKLL
J  NN
OOOO""!!
	 $$fnn5&,,fll;Z ; #  !))C D ! !"F +-B " O .Zgh   i
,
,, 
,"6nDnMPn,n " A   F
A
'
AF
A DI{*+&,/9CD& &[! [!DC fcVaigZe	   ""7
 4 09,",@, +, 	,^2@23(W* W*t & r   