
    bMh
             	      .	   U d Z ddlmZ ddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlZddlmZmZmZmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZm Z  ddl!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0 ddlm1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl;m<Z< ddlm=Z= ddl>m?Z? ddl@Z@ddlAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZI ddl@mJZJmKZKmLZLmMZMmNZNmOZO ddlPmQZQ ddlRmSZSmTZTmUZU ddlVmWZWmXZXmYZY ddlZm[Z[m\Z\ ddl]m^Z^m_Z_m`Z`maZa ddlbmcZcmdZdmeZe ddlfmgZgmhZhmiZimjZjmkZk ddllmmZm ddlnmoZo dd lmpZp d!d"lqmrZrmsZsmtZtmuZumvZv d!d#lwmxZxmyZy d!d$lzm{Z{m|Z| d!d%l}m~Z~mZmZmZ d!d&lrmZmZmZmZmZmZmZmZmZmZmZmZ d!d'lmZ d!d(lmZmZmZmZ d!d)lmZ d!d*lmZmZ d!d+lmZmZ d!d,lmZ d!d-lmZmZ d!d.lmZmZ d!d/lmZ d!d0lmZmZ e1r dd1lmZmZ dd2lmZ dd3l,mZ d!d4lmZ d!d5lmZ ej        d6k    Ze8eeef         Z e7d7e8          Ze8ee         ee         ee         f         Ze[Zd9ed:<   e3e2egeHjB        f         Zd9ed;<   d<Zd9ed=<   ej        egZd>ed?<   ej        eej        j        gZd>ed@<   ej        eej        j        gZd>edA<   ej        eej        j        gZd>edB<   ej        egZd>edC<   e"e#e$e%e&e'gZd>edD<   ej        ej        j        gZd>edE<   ej        ej        j        ej        ej        j        gZd>edF<   ej        egZd>edG<   ej        ej        gZd>edH<   e	j        e
j        e
j        e
j        e
j        e
j        gZd>edI<   ej        ej        ej        j        ej        j        ej        e@j        ej        ej        gZej        ej        gZej        ej        gZd>edJ<   e8e/e-e0ef         Z eMe          ZehegejekdKZdLedM<   ddTZddZZdd^ZddeZddhZeee2         e`f         ZddnZddqZ G dr dse          Z G dt du          Zdv dw dx dy dz d{ d| d} d~Zded<   ddZddZddZddZddZ G d deL          ZddddddddZddZddZ G d d          Z  G d d          Z G d d          ZdS )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)warn)ZoneInfo)
CoreSchemaMultiHostUrlPydanticCustomError$PydanticSerializationUnexpectedValuePydanticUndefinedUrlcore_schemato_jsonable_python)	TypeAliasTypeAliasType	TypedDictget_args
get_originis_typeddict)typing_objects)AnnotationSourceget_literal_valuesis_union_origin   )AliasChoicesAliasGenerator	AliasPath)GetCoreSchemaHandlerGetJsonSchemaHandler)
ConfigDictJsonDictJsonEncoderJsonSchemaExtraCallable)PydanticSchemaGenerationErrorPydanticUndefinedAnnotationPydanticUserError)AfterValidatorBeforeValidatorFieldValidatorModesPlainValidatorWrapValidator)JsonSchemaValue)version_short)PydanticDeprecatedSince20   )_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validate_core_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)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)boundr3   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)beforeafterplainwrapzbdict[FieldValidatorModes, type[BeforeValidator | AfterValidator | PlainValidator | WrapValidator]]_mode_to_validatorinfoFieldDecoratorInfofieldstrreturnboolc                     | j         }d|v p||v S )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)r   r   r   s      c/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pydantic/_internal/_generate_schema.py)check_validator_fields_against_field_namer      s     [F&=+EVO+    
decoratorsIterable[AnyFieldDecorator]r   Iterable[str]Nonec           	         t          |          }| D ]U}d|j        j        v r|j        j        du r |j        j        D ](}||vr"t	          d|j         d|j         dd          )VdS )	av  Check if the defined fields in decorators exist in `fields` param.

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

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

    Raises:
        PydanticUserError: If one of the field names does not exist in `fields` param.
    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_fieldsrI   cls_refcls_var_name)r   r   decr   s       r   check_decorator_fields_existr      s     [[F  #(/!!8 E))X_ 	 	EF""'f f fsO_ f f f2    #	 r   validator_functions+Iterable[Decorator[FieldDecoratorInfoType]]'list[Decorator[FieldDecoratorInfoType]]c                     fd| D             S )Nc                >    g | ]}t          |j                  |S  )r   r   ).0r   r   s     r   
<listcomp>z8filter_field_decorator_info_by_field.<locals>.<listcomp>   s.    mmmC2[\_\dfk2l2lmCmmmr   r   )r   r   s    `r   $filter_field_decorator_info_by_fieldr      s!     nmmm.mmmmr   schemacore_schema.CoreSchemaeach_item_validators'list[Decorator[ValidatorDecoratorInfo]]
field_name
str | Nonec                H   |s| S | d         dk    rt          | d         ||          | d<   | S | d         dk    r>|                     d          x}&t          | d         |         ||          | d         |<   nt          |           r<|                     dt	          j                              }t          |||          | d<   n`| d         dk    r<|                     dt	          j                              }t          |||          | d<   nt          d	| d                    | S )
Ntypenullabler   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^   r1   
any_schema	TypeError)r   r   r   r   inner_schemas        r   r   r      sU      
 f~##5fX6FH\^hiix	7	"	"#)::.C#D#DDQ:J~&':;$; ;F>"#67
 
/v	6	6 	
zz.+2H2J2JKK!1,@TV`!a!a~	6	!	!zz/;3I3K3KLL"2<AUWa"b"bn^dek^lnn
 
 	
 Mr   FieldInfo | ComputedFieldInfoAtuple[JsonDict | None, JsonDict | JsonSchemaExtraCallable | None]c                    | j         | j        t          | j                  p| j        dk    pd t	          | j                  d}d |                                D             }|pd | j        fS )N )titledescription
deprecatedexamplesc                    i | ]
\  }}|||S Nr   r   kvs      r   
<dictcomp>z=_extract_json_schema_info_from_field_info.<locals>.<dictcomp>  s    YYYDAq1=1a===r   )r   r   r   r   r2   r   itemsjson_schema_extra)r   json_schema_updatess     r   )_extract_json_schema_info_from_field_infor     s~     '4?++Lt"/DL&t}55	  ZY,?,E,E,G,GYYY'4)?@@r   json_encodersJsonEncoders | Nonetpr   r+   c                *   | s|S d|v r|S |gt          |d|j        j                  dd         R D ]`}|                     |          }|t	          j        dt                       dt                     t          j	        |d          |d<   |c S |S )	a  Iterate over the json_encoders and add the first matching encoder to the schema.

    Args:
        json_encoders: A dictionary of types and their encoder functions.
        tp: The type to check for a matching encoder.
        schema: The schema to add the encoder to.
    serialization__mro__Nz=`json_encoders` is deprecated. See https://docs.pydantic.dev/z</concepts/serialization/#custom-serializers for alternativesjson	when_used)
getattr	__class__r   r   warningsr)   rP   rQ   r1   $plain_serializer_function_ser_schema)r   r   r   baseencoders        r   ,_add_custom_serialization_from_json_encodersr     s      &   Hgb)R\-ABB3B3GHH  ##D))? ZMOO  Z  Z  Z%	
 	
 	
 #."RSZfl"m"m"mMr   abc                    | | n|S )aB  Return the first argument if it is not None, otherwise return the second argument.

    Use case: serialization_alias (argument a) and alias (argument b) are both defined, and serialization_alias is ''.
    This function will return serialization_alias, which is the first argument, even though it is an empty string.
    r   )r   r   s     r   _get_first_non_nullr   6  s     111$r   c                      e Zd ZdZdS )InvalidSchemaErrorzThe core schema is invalid.N)__name__
__module____qualname____doc__r   r   r   r   r   ?  s        %%%%r   r   c                      e Zd ZdZdZ	 	 dddZd fdZedd            Zedd            Z	edd            Z
ddZddZddZddZddZdd Zdd"Zdd#Zdd$Zdd%Zdd&Zdd(Zdd,Zdd-Zdd1Zdd3Zdd6Zdd7Zdd:Zdd;Zedd?            Z eddA            Z dddCZ ddDZ!ddFZ"ddGZ#ddHZ$ddJZ%dKdLddTZ&ddVZ'ddXZ(e)dd\            Z*e)dd`            Z+e)ddb            Z,dddZ-ddfZ.ddhZ/ddjZ0ddlZ1ddnZ2e3j4        dfddvZ5e3j4        fddyZ6dd{Z7dd|Z8dd}Z9dd~Z:ddZ;ddZ<ddZ=ddZ>ddZ?ddZ@ddZA	 dddZB	 dddZCddZDddZEddZFd fddZGddZHddZIddZJddZKddZL xZMS )GenerateSchemaz\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defsNconfig_wrapperrX   ns_resolverNsResolver | Nonetypevars_mapMapping[TypeVar, Any] | Noner   r   c                    t          |          | _        |pt                      | _        || _        t                      | _        t                      | _        t                      | _
        d S r   )rY   r  rx   r  r  _FieldNameStackr  _ModelTypeStackr  _Definitionsr  )selfr	  r
  r  s       r   __init__zGenerateSchema.__init__O  sX     &8%G%G"'7:<<) / 1 1 / 1 1 NN			r   c                    t                                                       t          j        dt          d           d S )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  z GenerateSchema.__init_subclass__]  sE    !!###s	
 	
 	
 	
 	
 	
r   c                    | j         j        S r   )r  tailr  s    r   _config_wrapperzGenerateSchema._config_wrappere  s    )..r   rw   c                    | j         j        S r   )r  types_namespacer  s    r   _types_namespacezGenerateSchema._types_namespacei  s     00r   r   c                    | j         j        S r   )r  arbitrary_types_allowedr  s    r   _arbitrary_typeszGenerateSchema._arbitrary_typesm  s    #;;r   
items_typer   r+   c                P    t          j        |                     |                    S r   )r1   list_schemagenerate_schemar  r$  s     r   _list_schemazGenerateSchema._list_schemas  s!    &t';';J'G'GHHHr   	keys_typevalues_typec                x    t          j        |                     |          |                     |                    S r   )r1   dict_schemar'  )r  r*  r+  s      r   _dict_schemazGenerateSchema._dict_schemav  s2    &t';';I'F'FH\H\]hHiHijjjr   c                P    t          j        |                     |                    S r   )r1   
set_schemar'  r(  s     r   _set_schemazGenerateSchema._set_schemay  s!    %d&:&::&F&FGGGr   c                P    t          j        |                     |                    S r   )r1   frozenset_schemar'  r(  s     r   _frozenset_schemaz GenerateSchema._frozenset_schema|  s!    +D,@,@,L,LMMMr   	enum_type
type[Enum]c           	       	
 t          j                                                  t                    	j        sd nt          j        j                  }|dk    rd }j        |d
d 
                                D             
d t          t                    rdt          j        d          }nmt          t                    rdt          j        d          }nAt          t                    rdt          j        d          }nt          j        d           }rd
fd}t!          j        dd           t$          j        j        u }t          j        |rd nj        	d|gi          }| j        j        r$t          j        t1          d          ||          }|S d	
fd}t          j        d|gi          S )NzAn enumeration.)r   r   c                    i | ]
\  }}|||S r   r   r   s      r   r   z/GenerateSchema._enum_schema.<locals>.<dictcomp>  s    KKKtq!Q]a]]]r   intr   floatc                    | S r   r   xs    r   <lambda>z-GenerateSchema._enum_schema.<locals>.<lambda>  s    XY r   r   r+   handlerrB   r   rO   c                r     ||           }|                     |          }|                               |S r   )resolve_ref_schemaupdate)r   r?  json_schemaoriginal_schema
js_updatess       r   get_json_schemaz4GenerateSchema._enum_schema.<locals>.get_json_schema  s=    %gfoo")"<"<["I"I&&z222""r   __func__pydantic_js_functions)sub_typemissingrefmetadatavalue)r   c                     |t          j                            }|                    |          }|                               |S )N)rI  rK  )r1   enum_schemarA  rB  )	_r?  rC  rD  casesenum_refr5  rE  rI  s	       r   get_json_schema_no_casesz=GenerateSchema._enum_schema.<locals>.get_json_schema_no_cases  sU    %gk&=iYago&p&p&pqq")"<"<["I"I&&z222""r   rL  )r   r+   r?  rB   r   rO   )r?  rB   r   rO   )list__members__valuesr]   r   inspectcleandocr   r   
issubclassr9  r1   simple_ser_schemar   r:  r   r   	_missing_r   rG  rO  r  use_enum_values no_info_after_validator_functionr   is_instance_schema)r  r5  r   value_ser_typerF  default_missingrO  rS  rQ  rR  rE  rI  s    `      @@@@r   _enum_schemazGenerateSchema._enum_schema  sG   	 5 < < > >??	**"+"3\dd9I)J[9\9\,,,K(1+NN
KKz'7'7'9'9KKK
:>i%% 	[H4?4QRW4X4XNN	3'' 		[H(:5AANN	5)) 	[H(:7CCNN )MkkZZN +	# # # # # # &i&9:tLLPTP^PggO%1! /HY5H1O3DE  K #3 )Jw''N   # # # # # # # # # # 114L3MN   r   r   c                   ddl m}m} t          dt          dt
          dt          dt          dt          didfd}t          j
        t          j        |                   t          j        t          j        t          j                              t          j                            t          j        |dd          dfdgi          S )NrR   )IP_VALIDATOR_LOOKUPIpTypeipv4ipv4networkipv4interfaceipv6ipv6networkipv6interfaceipr   r   core_schema.SerializationInfor   str | IpTypec           	         t          | t          f          s&t          d dt          |            d|  d          |j        dk    r| S t          |           S Nz
Expected `z` but got `z` with value `'z-'` - serialized value may not be as expected.python
isinstancer   r.   r   mode)rl  r   r   s     r   ser_ipz)GenerateSchema._ip_schema.<locals>.ser_ip  sn    b2s),, :zzzRzzzzz   yH$$	r77Nr   rC  python_schemaTalwaysinfo_argr   rH  c                    d         dS )Nstringr   formatr   )_1_2ip_type_json_schema_formatr   s     r   r>  z+GenerateSchema._ip_schema.<locals>.<lambda>  s    (VpqsVt9u9u r   
lax_schemastrict_schemar   rL  )rl  r   r   rm  r   rn  )_validatorsrd  re  r   r   r   r   r   r   r1   lax_or_strict_schema no_info_plain_validator_functionjson_or_python_schemar^  
str_schemar_  r   )r  r   rd  re  ru  r  s    `   @r   
_ip_schemazGenerateSchema._ip_schema  s   <<<<<<<< ???
"	 	 	 	 	 	 /"CDWXZD[\\%;'H[McMeMeff)<R@@   &J6\`ltuuu'*u*u*u*u*u)v

 

 

 
	
r   	path_typec           	       	 t           j        u r5t          t          hvr%t	          j                  st          dd          t           j        u rt          j        n	t          u rt          j
        d          nt          j        d          }t          u rt          j
                    nt          j                    }d	fd
}dfd}t          j        t          j        ||          t          j                            }t          j        t          j        |t          j        ||          gdd           |t          j        |dd          dd gi          }|S )Nz;`os.PathLike` can only be used with `str`, `bytes` or `Any`zschema-for-unknown-typer   Tstrictinput_valuestr | bytesr   os.PathLike[Any]c                z   	 t           u r^t          | t                     r9	 |                                 } nX# t          $ r}t	          dd          |d }~ww xY wt	          dd          t          | t
                    st	          dd           |           S # t          $ r}t	          dd          |d }~ww xY w)N
bytes_typezInput must be valid byteszInput must be bytesr  zInput is not a valid path)bytesrs  decodeUnicodeDecodeErrorr-   r   r   )r  epath_constructorr  s     r   path_validatorz3GenerateSchema._path_schema.<locals>.path_validator  s    [%%!+u55 Wh*5*<*<*>*>KK1 h h h"5lD_"`"`fggh 2,@UVVV#K55 X-k;VWWW''444 [ [ [)+7RSSYZZ[s8   B 7 B 
AAAAB 
B:$B55B:pathr   r   rm  str | os.PathLike[Any]c           	         t          | t          f          s&t          d dt          |            d|  d          |j        dk    r| S t          |           S rp  rr  )r  r   r   s     r   ser_pathz-GenerateSchema._path_schema.<locals>.ser_path  so    dRI.. :~~~T

~~4~~~   yH$$t99r   rv  r  zInput is not a valid path for custom_error_typecustom_error_messagerx  ry  rH  c                $    i  ||           ddiS )Nr~  r  r   )sourcer?  s     r   r>  z-GenerateSchema._path_schema.<locals>.<lambda>  s!    Hm77SY??Hm\dflHmHm r   r  )r  r  r   r  )r  r   r   rm  r   r  )osPathLiker   r  r9   is_anyrI   pathlibPurePathr1   bytes_schemar  r  r^  r_  r  union_schemar   )
r  r   r  strict_inner_schemalax_inner_schemar  r  instance_schemar   r  s
    ``      @r   _path_schemazGenerateSchema._path_schema  s   )C<"?"?H]^gHhHh"?#MTm    02R[/@/@7++b6?56H6HK$D1111{OemqOrOrOr 	 ;Du:L:L;3555S^SiSkSk	[ 	[ 	[ 	[ 	[ 	[ 	["	 	 	 	 	 	 &;#D^Ueff%8<<
 
 

 1"/#@Qdee #.%Jb%J%J   *%J8^bnvwww-0m0m/no
 
 
 r   c           	        ddl m} ddlm} |                     |          }t          j        |d          }t          j        |t          j        t          j
        d                    }t          j        ||          }t          j        |t          j        ||g          t          j        ||d	
                    S )NrR   serialize_sequence_via_list)deque_validatorFr  Dequecls_reprrv  Tr   rz  r  r  r   )_serializersr  r  r  r'  r1   r&  r  r_  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_schemazGenerateSchema._deque_schema"  s    ======000000//
;; "-.>uMMM$:#%89JU\]]]
 
 

 !@R]^^
/!%2NJ3OPP%I+4Dt  
 
 
 	
r   c           	     j   ddl m}m}m} ||         }|                     |          }|                     |          }	t          j        ||	d          }
|t          u r|
}nt          j        |
t          j	        |                    }|t          j        u r5 ||          }t          t
          j        t          ||                    }nt          t
          j        |          } ||
          }t          j        ||g          }t          j        ||t          j        d |
d          	          }|S )
NrR   )MAPPING_ORIGIN_MAPdefaultdict_validator'get_defaultdict_default_default_factoryFr  rv  )default_default_factoryc                     ||           S r   r   )r   hs     r   r>  z0GenerateSchema._mapping_schema.<locals>.<lambda>[  s    1 r   r  r  )r  r  r  r  r'  r1   r-  r   r  r_  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_schemazGenerateSchema._mapping_schema;  sm   ssssssssss*2.**955,,[99!-k=QVWWWD   FF(>')<]KK  N
 [,,,*Q*QR]*^*^''.?1Kbccc( ($$
 (/{/[]j'k'k$--k::J'4nj5QRRM 5%+)M%%kE    F r   c           	     
   ddl m} t          j        t          j        |          t          j        t          j        |          t          j        t                              t          j        d          dd gi          S )	z7Support for [`fractions.Fraction`][fractions.Fraction].rR   )fraction_validatorrv  rx  r   rH  c                    dddS )Nr|  fractionr}  r   r  r  s     r   r>  z1GenerateSchema._fraction_schema.<locals>.<lambda>o  s    \f?g?g r   r  )	r  r  r1   r  r  r  r_  r   to_string_ser_schema)r  r  s     r   _fraction_schemazGenerateSchema._fraction_schemaa  s    333333 /"CDVWW%;'HI[\\)<XFF  
 &:XNNN-0g0g/hi	
 	
 	
 		
r   c                    t          |t                    s+t          |dt                     t	          j                    S t	          j        |          S )Na   is not a Python type (it may be an instance of an object), Pydantic will allow any object with no validation since we cannot even enforce that the input is an instance of the given type. To get rid of this error wrap the type with `pydantic.SkipValidation`.)rs  r   r)   r  r1   r   r_  )r  r   s     r   _arbitrary_type_schemaz%GenerateSchema._arbitrary_type_schemar  sb    "d## 	, Z Z Z    )+++-b111r   objc                (    t          d|d          )N,Unable to generate pydantic-core schema for a  . Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.

If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.)rG   r  r  s     r   _unknown_type_schemaz#GenerateSchema._unknown_type_schema~  s.    +f3 f f f
 
 	
r   r   discriminatorstr | Discriminator | Nonec                    ||S 	 t          j        ||| j        j                  S # t           j        $ r t          j        ||           |cY S w xY wr   )rT   apply_discriminatorr  _definitionsMissingDefinitionForUnionRefset_discriminator_in_metadata)r  r   r  s      r   _apply_discriminator_to_unionz,GenerateSchema._apply_discriminator_to_union  s}      M	';	&  
 $@ 	 	 	 >   MMM	s   & &AAc                X    | j                             |          }t          |          }|S r   )r  finalize_schemar_   )r  r   s     r   clean_schemazGenerateSchema.clean_schema  s)    **622%f--r   metadata_schemajs_functionCallable[..., Any]c                    |                     di           }|                    dg           }||vr|                    |           ||d<   d S )NrL  rH  )r   
setdefaultappend)r  r  r  rL  rH  s        r   _add_js_functionzGenerateSchema._add_js_function  s`    "&&z266 ( 3 34KR P P
 333!((555&.
###r   r   c                   |                      ||          }||                     |          }t          |          }|-t          || j                  }|r|                     ||           t          | j        j        ||          }|S )aX  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'  zGenerateSchema.generate_schema  s    0 ==c3GG>0055F@EE+5fdiHHO M%%o7KLLL=d>R>`begmnnr   r  type[BaseModel]c                    t                      } j                            |          5 \  }}||cddd           S |j                            d          }|t          |t                    sk|d         dk    r j                            |          }t          |          }|r& j        	                    |          cddd           S |cddd           S t          |j        d          } j                            |          5   j                            |          5   j                            |j                  }|j        s||u rt'          |di           }	nvt)          |d          st+          |j        d	|j        d
          	 t-          | j         j        pi           }	n'# t0          $ r}
t+          j        |
          |
d}
~
ww xY w|j        j        }t9          t;          j                                        j                                         j!                                                  h |	"                                |"                                           j#                                        }d}d}|                    d          dk    r/|j$        d         |u sJ |j$        d         tJ          u sJ |j$        dd         D ]}t'          |di                               dd          }|t          |tL                    r,tO          j(        tO          j)        |dd          g j*        R  }tW          |          }|tX          vrt[          d           .                    |d          \  }}|tL          ur /                    |          }ta          j1        |          s /                    |          }|| nt'          |di                               d          }|j2        rq 3                    d|	d                   }|d         }ti          ||d          }tk          j6        |||t'          |dd          dt'          |dd          ||          }ntk          j7         fd|	8                                D              fd |                                D             |||j        !          }ts          |j:                                        d          }ti          ||d          }tk          j6        |||t'          |dd          dt'          |dd          ||          } ;                    |j<                                                  }ti          ||d"          } j        	                    |          cddd           cddd           cddd           S # 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )#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  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rootr   inner__pydantic_custom_init____pydantic_post_init__)generic_origincustom_init
root_model	post_initconfigrK  c                F    i | ]\  }}|                     ||          S r   )_generate_md_field_schemar   r   r   r   r  s      r   r   z0GenerateSchema._model_schema.<locals>.<dictcomp>E  s4    hhhQUQRTUD::1aLLhhhr   c                F    g | ]}                     |j                  S r   _computed_field_schemafield_serializersr   dr   r  s     r   r   z0GenerateSchema._model_schema.<locals>.<listcomp>F  s<     ) ) ) ! !77:;WXX) ) )r   )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   hasattrrH   ro   r  	NameErrorfrom_name_error__pydantic_decorators__r  r   r   field_validatorsrW  r  
validatorskeysmodel_validatorsr   objectr   rW   eval_type_backport_make_forward_refr   r7   r   rG    _get_args_resolving_forward_refsr'  r9   r  __pydantic_root_model___common_field_schemaapply_model_validatorsr1   model_schemamodel_fields_schemar   r   root_validators_apply_model_serializersmodel_serializers)r  r  
BaseModel_	model_refmaybe_schemar   rK  r	  r"  r   r  r  r+  r  r  candidate_clsextras_annotationr   extra_keys_typeextra_items_typer	  
root_fieldr   r3  fields_schemar   s   `                        @r   _model_schemazGenerateSchema._model_schema  s   -//
Y((-- G	L1J)\'#G	L G	L G	L G	L G	L G	L G	L G	L \%%&@AAF!*V^*L*L!&>]22!Y99&AAFfoo "9GGOOG	L G	L G	L G	L G	L G	L G	L G	L "G	L G	L G	L G	L G	L G	L G	L G	L +3+;5IIIN+00@@ wL wL$BSBXBXY\B]B] wL wL"2>>S\>RR3 Tsj7H7H$S*?DDFF"3(=>>  :!$$LS\$L$L$L   T!5(,(9)-);)Ar" " "
 % T T T9I!LLRSST !8
","<,"3::<<"4;;=="-4466 
 >fkkmm=o&:&:&<&<=   $.#>#E#E#G#G  $%)"??#:;;wFF;q>S0000;r?f4444),SbS)9 & &,3MCTVX,Y,Y,],]0$- -) -8)*;SAA "4A4T$1$C(9uW[%& %& %&5" &*%:	5" 5" 5" 1 ",,=!>!>B!33&C$k'" '" !" AE@e@e 1)- Af A A=O-=  /c99595I5I/5Z5Z 2#1#89I#J#J W040D0DEU0V0V1=AZ %9@Fegi9j9j9n9now9x9x. %!%!:!:66&>S]!^!^J#-h#7L#9,HXZa#b#bL#.#;$'5$+C1KT$R$R#'")#/G"N"N*%	$ 	$ 	$LL =H<[hhhhhY_YeYeYgYghhh) ) ) ) )%4%;%;%=%=) ) ) '4+=#&<	= 	= 	=M $4M:C]CdCdCfCfhl#m#mL#9,HXZa#b#bL#.#;$'5$+C1KT$R$R#(")#/G"N"N*%	$ 	$ 	$L 66|ZEaEhEhEjEjkk/8H'RRyCCFKKowL wL wL wL wL wL wL wL wL wL wL wL wL wL!G	L G	L G	L G	L G	L G	L G	L G	L wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL wL!G	L G	L G	L G	L G	L G	L G	L G	L G	L G	L G	L G	L G	L G	L G	L G	L G	L G	Ls   W0BW0W00W0W&A-WF32W3
G	=G	G	OWW(W0WWW	WW0W	W0W	 W00W47W4c                ^    | j                                         }|t          dd          |S )Nz(`typing.Self` is invalid in this contextzinvalid-self-typer   )r  r   rI   r  s     r   _resolve_self_typez!GenerateSchema._resolve_self_type`  s5    #''));#$NUhiiii
r   r  core_schema.CoreSchema | Nonec                   t                      }t          |dd           }t          |dd           |j        j        u }||s| j                            |          5 \  }}||cd d d            S 	 d d d            n# 1 swxY w Y   ||u rd}nd} ||t          | j        | |                    }	|	d         dk    r| j                            |	          }	t          |	          }
|
r| j        
                    |	          S |	S |t          |dd           x}rd	d
lm} t          ||          rt          d|j         dt                      nt          dt"                     t%          j        d  |            D                       S d S d S )N__get_pydantic_core_schema__rG  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.c                6    g | ]}t          j        |          S r   r1   "with_info_plain_validator_functionr   r   s     r   r   zJGenerateSchema._generate_schema_from_get_schema_method.<locals>.<listcomp>  s%    ,u,u,ucd[-[\]-^-^,u,u,ur   )rt   r   rF  rG  r  r  r{   r  r  r\   r  pydantic.v1r   rZ  r)   r   r  rQ   r1   r  )r  r  r  r8  
get_schemais_base_model_get_schemarP  r:  rH  r   rK  r)  BaseModelV1s                r   r  z6GenerateSchema._generate_schema_from_get_schema_methodf  s^   -//
S"@$GG
J
D11Z5\5ee 	!
 " - # ,,S11 (5Fa+'( ( ( ( ( ( ( (+( ( ( ( ( ( ( ( ( ( ( ( ( ( ( f}}##Z4T5PRVaijjj F f~..55f==&//C LyCCFKKK M>RTX1Y1Y#Y:"f<<<<<<#{++ 	 S|  }I  S  S  S   
 y-   +,u,uhrhrhtht,u,u,uvvv "f"fs   A<<B B c                   	 t          j        |g| j        R  }n'# t          $ r}t	          j        |          |d }~ww xY wt          |t                    rt	          |j        d|           | j	        rt          || j	                  }|S )Nz%Unable to evaluate forward reference )rW   r-  r   r%  rH   r&  rs  r"   __forward_arg__r  rs   )r  r  r  s      r   _resolve_forward_refz#GenerateSchema._resolve_forward_ref  s    	H23O9NOOOCC 	H 	H 	H-=a@@aG	H c:&& 	r-c.ACpknCpCpqqq 	9T%788C
s    
>9>r  Literal[True]tuple[Any, ...]c                    d S r   r   )r  r  r  s      r   r/  z/GenerateSchema._get_args_resolving_forward_refs  s    fifir   tuple[Any, ...] | Nonec                    d S r   r   r  s     r   r/  z/GenerateSchema._get_args_resolving_forward_refs  s    TWTWr   Fc                     t          |          }|r=t          |t                    rd |D             }t           fd|D                       }n|rt	          d| d          |S )Nc              3  l   K   | ]/}t          |t                    rt          j        |          n|V  0d S r   )rs  r   rW   r.  )r   r   s     r   	<genexpr>zBGenerateSchema._get_args_resolving_forward_refs.<locals>.<genexpr>  sC      ff\]jC>P>PW7:::VWffffffr   c              3  p   K   | ]0}t          |t                    r                    |          n|V  1d S r   )rs  r"   rT  )r   r   r  s     r   r\  zBGenerateSchema._get_args_resolving_forward_refs.<locals>.<genexpr>  sG      hh^_Az9R9RY221555XYhhhhhhr   z	Expected z+ to have generic parameters but it had none)r6   rs  r   r   r   )r  r  r  argss   `   r   r/  z/GenerateSchema._get_args_resolving_forward_refs  s    }} 	Z#|,, gffaefffhhhhcghhhhhDD 	ZXXXXYYYr   c                N    |                      |          }|st          S |d         S )Nr   )r/  r   )r  r  r^  s      r   _get_first_arg_or_anyz$GenerateSchema._get_first_arg_or_any  s+    44S99 	JAwr   tuple[Any, Any]c                    |                      |          }|st          t          fS t          |          dk     r"t          |          }t	          d| d          |d         |d         fS )Nr=   z Expected two type arguments for z, got 1r   rR   )r/  r   lenr7   r   )r  r  r^  r  s       r   _get_first_two_args_or_anyz)GenerateSchema._get_first_two_args_or_any  sn    44S99 	:t99q==__FNvNNNOOOAwQr   c                   t          j        |          r|                     |          }t          j        t	          |                    r|                     |          S t          |t                    r|S t          |t                    rt          |          }t          |t                    r(| 
                    |                     |                    S t                      }t          ||          rG| j                            |          5  |                     |          cd d d            S # 1 swxY w Y   t          |t"                    rt%          j        |j                  S |                     |          S )N)
schema_ref)r9   is_selfrC  is_annotatedr7   _annotated_schemars  r   r   r"   r'  rT  rt   r|   r  r!  rA  rq   r1   definition_reference_schematype_ref
match_type)r  r  r   s      r   r  z%GenerateSchema._generate_schema_inner  s   !#&& 	/))#..C&z#77 	/))#...c4   	Jc3 	"S//Cc:&& 	H''(A(A#(F(FGGG,..	c9-- 	/&++C00 / /))#../ / / / / / / / / / / / / / / / c/00 	T:clSSSSs###s   D22D69D6c                V   |t           u rt          j                    S |t          u rt          j                    S |t
          u rt          j                    S |t          u rt          j                    S |t          u rt          j
                    S |t          u rt          j                    S t          j        |          s	|t          u rt          j                    S |t"          j        u rt          j                    S |t"          j        u rt          j                    S |t"          j        u rt          j                    S |t"          j        u rt          j                    S |t2          u rt          j                    S |t6          u rt          j                    S |t:          u rt          j                    S |t>          u r|                                  S |tB          u rt          j"                    S ||tF          j$        u rt          j%                    S |tL          v r| '                    |          S |tP          v r| )                    |          S |tT          v r| +                    tX                    S |tZ          v r| .                    tX                    S |t^          v r| 0                    tX                    S |tb          v r| 2                    tX                    S |tf          v r| 4                    |          S |tj          v r | 6                    tX          tX                    S |tn          v r| 8                    |tX                    S |tr          v r| :                    tX                    S |tv          v r!| <                    |tX          tX                    S |tz          v r!| <                    |tX          t
                    S t          j>        |          r| ?                    |          S |t          u r| A                                S tG          jB        |          rt          jC                    S t          jD        t          |                    r| F                    |          S t          |          r| H                    |d          S tG          jI        |          r| J                    |d          S t          jK        |          r| L                    |jM                  S |t          v r| O                    |          S tG          jP        |          r| Q                                S t          |t          jT                  r| U                    |          S tG          jV        |          rD|t          u rt          j                    S | L                    | X                    |                    S t          |t                    r| Z                    |          S t          j\        |          r*t          |t                    r| _                    |          S |t          u r| a                                S t          jc        |          r| d                    |d          S t          |          }|| e                    ||          S | jf        r| g                    |          S | h                    |          S )a  Main mapping of types to schemas.

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

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

        The idea is that we'll evolve this into adding more and more user facing methods over time
        as they get requested and we figure out what the right API for them is.
        N)ir   r1   r  r  r  r9  
int_schemar:  float_schemar   bool_schemacomplexcomplex_schemar9   r  r,  r   datetimedatedate_schemadatetime_schematimetime_schema	timedeltatimedelta_schemar   decimal_schemar(   uuid_schemar0   
url_schemar   r  r,   multi_host_url_schemarW   NoneTypenone_schemar   r  r   _tuple_schemar   r)  r   r   r1  r   r4  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_literalr7   _literal_schemar8   _typed_dict_schemais_namedtuple_namedtuple_schema
is_newtyper'  __supertype__r   _pattern_schemais_hashable_hashable_schemars  typingr$   _unsubstituted_typevar_schemais_finalvarr!   r`  VALIDATE_CALL_SUPPORTED_TYPES_call_schemarX  isclassrZ  r   rb  r*   _zoneinfo_schemadataclassesis_dataclass_dataclass_schema_match_generic_typer#  r  r  )r  r  r  s      r   rl  zGenerateSchema.match_type  s    #::)+++E\\+---CZZ)+++E\\+---D[[*,,,G^^-///"3'' N	+3&==)+++HM!!*,,,H%%%.000HM!!*,,,H&&&/111G^^-///D[[*,,,CZZ)+++H__((***L  4666[C=#999*,,,H__??3'''K%%c***J$$S)))I##C((($$$))#...N""((---N""((---J$$S#...J$$S#...K%%c***M!!''S#666M!!''S#666,S11  	+//444D[[$$&&&&s++ 	+.000&z#77 	+'',,,# 	+**3555(-- 	+**3555&s++ 	+''(9:::M!!'',,,&s++ 	+((***V^,, 	+55c:::&s++ 	+e||"-///''**3//   :;; 	+$$S)))_S!! 	+jd&;&; 	+$$S)))H__((*** #C(( 	5))#t444C++C888  	4..s333((---r   r  c                r   t          j        |          r|                     ||          S t          j        |          r|                     ||          S |                     ||          }||S t          j        |          r| 	                    |          S t          |          r|                     |          S |t          v r|                     |          S |t          v r(|                     |                     |                    S |t"          v r(|                     |                     |                    S |t&          v r(|                     |                     |                    S |t*          v r | j        |                     |           S |t0          v r)|                     ||                     |                    S |t4          v r(|                     |                     |                    S |t8          v r! | j        |g|                     |          R  S |t<          v r/|                     ||                     |          t>                    S tA          |          r| !                    ||          S |tD          v r| #                    |          S |tH          v r(| %                    |                     |                    S |tL          v r| '                    |          S |tP          v r| )                    |          S | j*        r| +                    |          S | ,                    |          S r   )-r  r  r  rW   r  r  r  r9   r  r  r<   _union_schemar   r  r   r)  r`  r   r1  r   r4  r   r.  rd  r   r  r   r  r  r  r  r9  r8   r  r   _subclass_schemar   r  r   r  r   r  r#  r  r  )r  r  r  r   s       r   r  z"GenerateSchema._match_generic_typei  s7   
 #F++ 	7))#v666&v.. 	8**3777==fcJJM*622 	-//444V$$ 	-%%c***{""%%c***z!!$$T%?%?%D%DEEEy  ##D$>$>s$C$CDDD'''))$*D*DS*I*IJJJz!!$4$d&E&Ec&J&JKKz!!$$VT-G-G-L-LMMM{""%%d&@&@&E&EFFF}$$'4'V1P1PQT1U1UVVVV}$$''0J0J30O0OQTUUU&!! 		-**3777z!!((---~%%(()C)CC)H)HIII~%%((---}$$'',,,  	7..v666((---r   Tr  r  r   
field_infor   r   ra   core_schema.TypedDictFieldc          	         |                      |||          }t          j        |d         |                                sdn||d         |d         |d         |d                   S )zAPrepare a TypedDictField to represent a model or typeddict field.r   Fserialization_excludevalidation_aliasserialization_aliasrL  )r  r  r  r  rL  )r1  r1   typed_dict_fieldis_required)r  r  r  r   r  common_fields         r   _generate_td_field_schemaz(GenerateSchema._generate_td_field_schema  sx     00z:NN+"","8"8":":HUU"./F"G)*<= ,-B C!*-
 
 
 	
r   core_schema.ModelFieldc           	         |                      |||          }t          j        |d         |d         |d         |d         |d         |d                   S )z0Prepare a ModelField to represent a model field.r   r  r  r  frozenrL  r  r  r  r  rL  )r1  r1   model_fieldr  r  r  r   r  s        r   r  z(GenerateSchema._generate_md_field_schema  sh     00z:NN&""./F"G)*<= ,-B C)!*-
 
 
 	
r   core_schema.DataclassFieldc                    |                      |||          }t          j        ||d         |j        |j        pd|j        rdnd|d         |d         |d         |d         |d         	
  
        S )
zJPrepare a DataclassField to represent the parameter/field, of a dataclass.r   NFr  r  r  r  rL  )init	init_onlykw_onlyr  r  r  r  rL  )r1  r1   dataclass_fieldr  init_varr  r  s        r   _generate_dc_field_schemaz(GenerateSchema._generate_dc_field_schema  s     00z:NN*" )1T&.9DDE"./F"G)*<= ,-B C)!*-
 
 
 	
r   alias_generator%Callable[[str], str] | AliasGeneratorr   c                   |j         !|j         dk    s|j        |j        |j        !d\  }}}t	          | t
                    r|                     |          \  }}}nOt	          | t                    r: | |          }t	          |t                    st          d|  d|j
                   |j         |j         dk    rd|_         |j         dk    r1t          ||          |_        t          ||          |_        ||_        |j        ||_        |j        t          ||          |_        |j        t          ||          |_        dS dS dS )a  Apply an alias_generator to aliases on a FieldInfo instance if appropriate.

        Args:
            alias_generator: A callable that takes a string and returns a string, or an AliasGenerator instance.
            field_info: The FieldInfo instance to which the alias_generator is (maybe) applied.
            field_name: The name of the field from which to generate the alias.
        NrR   NNNalias_generator  must return str, not )alias_priorityaliasr  r  rs  r?   generate_aliasesr    r   r   r   r   )r  r  r   r  r  r  s         r   $_apply_alias_generator_to_field_infoz3GenerateSchema._apply_alias_generator_to_field_info  s    %-(A--'*2-5;K8E#%8/>:: q?N?_?_`j?k?k<')<)<OX66 q'
33!%-- q#$o$o$o^c^m$o$oppp
 (0J4MQR4R4R,-
) (A--1DEXZ_1`1`
..ABRTY.Z.Z
+#(
  '#(
 -51DEXZ_1`1`
.*2.ABRTY.Z.Z
+++; 658 32r   computed_field_infor~   computed_field_namec                   |j         |j         dk    s|j        d\  }}}t          | t                    r|                     |          \  }}}nOt          | t
                    r: | |          }t          |t                    st          d|  d|j                   |j         |j         dk    rd|_         |j         dk    rt          ||          |_        dS dS dS )a  Apply an alias_generator to alias on a ComputedFieldInfo instance if appropriate.

        Args:
            alias_generator: A callable that takes a string and returns a string, or an AliasGenerator instance.
            computed_field_info: The ComputedFieldInfo instance to which the alias_generator is (maybe) applied.
            computed_field_name: The name of the computed field from which to generate the alias.
        NrR   r  r  r  )
r  r  rs  r?   r  r    r   r   r   r   )r  r  r  r  r  r  s         r   -_apply_alias_generator_to_computed_field_infoz<GenerateSchema._apply_alias_generator_to_computed_field_info  s   $  .6"1Q66"(0;K8E#%8/>:: q?N?_?_`s?t?t<')<)<OX66 q'(;<<!%-- q#$o$o$o^c^m$o$oppp
 #19=P=_cd=d=d56#2
 #1Q66,?@SUZ,[,[#)))+ 10( 76r   r   c                    |j         p| j         }|dS |j        D |||          }t          |t                    st	          d| d|j                   ||_        dS dS )ae  Apply a field_title_generator on a FieldInfo or ComputedFieldInfo instance if appropriate
        Args:
            config_wrapper: The config of the model
            field_info: The FieldInfo or ComputedField instance to which the title_generator is (maybe) applied.
            field_name: The name of the field from which to generate the title.
        Nzfield_title_generator r  )field_title_generatorr   rs  r   r   r   )r	  r  r   r  r   s        r   *_apply_field_title_generator_to_field_infoz9GenerateSchema._apply_field_title_generator_to_field_info2  s     !+ @ hNDh (F#))*jAAEeS)) y w9N w wfkfu w wxxx$J $#r   _CommonFieldc                2    j         j        }}d fd}g }t          |j                                        |          D ]?}|                    t          |j        j                 	                    |                     @ j
                            |          5  j                             |||z   |          }	n                     |||z             }	d d d            n# 1 swxY w Y   t          |j                                        |          }
t          |
          rd_        d |
D             fd|
D             }
t#          |	|          }	t%          |	|
|          }	                                st)          |	          }	                     |	t          |j                                        |                    }	                      j        |           t3                    \  }}i }t5          |||	            j        j        }|                     ||           t;          j        t>          t@          f          rj        !                                }nj        }tE          |	j#        rdnd |j$        j%        |
          S )Nr   r+   r   c                >                         | j                  } | S r   )r  r  )r   r  r  s    r   set_discriminatorz>GenerateSchema._common_field_schema.<locals>.set_discriminatorM  s     77
@XYYFMr   )transform_inner_schemaTc                .    g | ]}|j         j        d u |S )T)r   	each_itemrM  s     r   r   z7GenerateSchema._common_field_schema.<locals>.<listcomp>h  s(    ]]]aAFDTX\D\D\D\D\D\r   c                    g | ]}|v|	S r   r   )r   r   r   s     r   r   z7GenerateSchema._common_field_schema.<locals>.<listcomp>i  s$     c c cqQNbEbEbEbEbEbr   pydantic_js_updatespydantic_js_extrar  r   r+   r   r+   )&
annotationrL  r   r(  rW  r  r   r   rt  _from_decoratorr  r!  r  _apply_annotationsr)  $_validators_require_validate_defaultvalidate_defaultr   r   r  wrap_default_apply_field_serializersr  r  r  r   r[   r  r  rs  r  r>   r@   convert_to_aliases_common_fieldexcluder  r  )r  r  r  r   source_typer   r  validators_from_decorators	decoratorr   this_field_validatorsr  r  core_metadatar  r  r   s   ` `             @r   r1  z#GenerateSchema._common_field_schemaH  sC    $.#8*:M[	 	 	 	 	 	 	
 &("=j>Y>`>`>b>bdhii 	r 	rI&--.@AT.U.e.efo.p.pqqqq"''-- 		 		'300/I!Ibs 1   00"<< 		 		 		 		 		 		 		 		 		 		 		 		 		 		 		 !EZEZEaEaEcEcei j j/0EFF 	/*.J']]+@]]] c c c c,A c c c+F4H$OO!&*?FF
 %%'' 	6!*f55F..89U9\9\9^9^`dee
 
 	778LjZ^___1Z[e1f1f..(*/BVg	
 	
 	
 	
 .>&55ozSWXXXj1L)3LMM 	;):MMOO):*4*<"F$$$- * >$"
 
 
 	
s   =C%%C),C)
union_typec                ,   |                      |d          }g }d}|D ]=}||t          j        u rd}|                    |                     |                     >t          |          dk    r	|d         }ng }|D ]m}t          t          |                    di                                         d          }	|	|                    ||	f           X|                    |           nt          j
        |          }|rt          j        |          }|S )	zGenerate schema for a Union.Tr  FNrR   r   rL  pydantic_internal_union_tag_key)r/  rW   r  r  r'  rc  r&   rZ   r   r1   r  nullable_schema)
r  r  r^  choicesr   argschoices_with_tagschoicetags
             r   r  zGenerateSchema._union_schema  s1   44Z$4OO$& 	: 	:C{c]%;;;t33C889999w<<1
AAKM! 5 5<J)C)CDDHHIjkk?%,,fc];;;;%,,V4444():;;A 	/+A..Ar   r4   c                b   | j                             |          5 \  }}||cd d d            S t          |          p|}t          |          }| j                            |          5  	 t          j        |j        g| j	        R  }n'# t          $ r}t          j        |          |d }~ww xY wt          ||          }|                     |          }|d         dk    sJ ||d<   d d d            n# 1 swxY w Y   | j                             |          cd d d            S # 1 swxY w Y   d S )Nr   r  rK  )r  r  r7   rr   r  r!  rW   	eval_type	__value__r   r%  rH   r&  rs   r'  r  )	r  r  rK  r:  r  r  r  r  r   s	            r   r  z&GenerateSchema._type_alias_type_schema  s   Y((-- 	H1D#|'#	H 	H 	H 	H 	H 	H 	H 	H %/sOO$:sF4S99L"''// $ $P!.!89I!bDLa!b!b!bJJ  P P P5EaHHaOP*:|DD
--j99f~6666 #u$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ 9??GG!	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	Hs^   D$:D$)C3+BC3
B,B''B,,;C3'D$3C7	7D$:C7	;D$$D(+D(literal_typec                    t          t          |dd                    }|sJ d|             t          j        |          }| j        j        r/t          d |D                       rt          j        d |          }|S )zGenerate schema for a Literal.Feager)
type_checkunpack_type_aliasesz(literal "expected" cannot be empty, obj=c              3  @   K   | ]}t          |t                    V  d S r   )rs  r   rM  s     r   r\  z1GenerateSchema._literal_schema.<locals>.<genexpr>  s-      7^7^PQ
1d8K8K7^7^7^7^7^7^r   c                >    t          | t                    r| j        n| S r   )rs  r   rM  )r   s    r   r>  z0GenerateSchema._literal_schema.<locals>.<lambda>  s    Z4%8%8?!''a r   )rU  r;   r1   literal_schemar  r]  anyr^  )r  r  expectedr   s       r   r  zGenerateSchema._literal_schema  s    *<E_fggghhRRRLRRRRR+H55/ 	C7^7^U]7^7^7^4^4^ 	 A?? F r   typed_dict_clsc                    t                      } j                            |          5   j                            |          5 \  }}||cddd           cddd           S t          |          }||}t          s)t          |          j        dk    rt          dd          	 t          |d          }n# t          $ r d}Y nw xY w j                            |          5   j                            |j                  }|j        }	i }
t#          j        |           j        j        rt)          |d	          }nd}	 t+          j        | j        
          }n'# t0          $ r}t3          j        |          |d}~ww xY wg }|                                D ]\  }} |j        |t:          j                  }t?          |j         |          |_         ||	v pd|j!        v od|j!        v}d|j!        v r|"                    |           ||j#        ||v r||         |_#         $                     j        ||            %                    |||          |
|<   |rfd&                    d |D                       }tO          |          dk    }tQ          j)        d|rdnd d| d|j        d|rdnd d	tT                     tW          j,        |
| fdj-        .                                D             ||          } /                    |j0        .                                          }tc          |j2        .                                d          } j        3                    |          cddd           cddd           cddd           S # 1 swxY w Y   	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )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  4   K   | ]}t          |          V  d S r   repr)r   fs     r   r\  z4GenerateSchema._typed_dict_schema.<locals>.<genexpr>  s(      +M+MDGG+M+M+M+M+M+Mr   r=   Itemr  r    z on TypedDict class areiszk using the `ReadOnly` qualifier. Pydantic will not protect items from any mutation on dictionary instances.c                F    g | ]}                     |j                  S r   r  r  s     r   r   z5GenerateSchema._typed_dict_schema.<locals>.<listcomp>*  <     % % % 33Az7STT% % %r   )r  r  rK  r  all)4ru   r  r!  r  r  rr   _SUPPORTS_TYPEDDICTr   r   rI   rh   AttributeErrorr  r  r"  r   __required_keys__ra   builduse_attribute_docstringsrl   rW   get_cls_type_hintsr  r%  rH   r&  r   from_annotationr:   
TYPED_DICTrs   r  _qualifiersr  r   r  r  joinrc  r   r)   r  r1   typed_dict_schemar  rW  r6  r7  r2  r+  r  )r  r  r  r   typed_dict_refr:  r  r  r"  required_keysr   field_docstringsr   r  readonly_fieldsr   r  r  r  fields_reprplural	td_schemar   r   s   `                      @r   r  z!GenerateSchema._typed_dict_schema  s    -..	 !&&~66\	L \	LI''77\	L< '#\	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L 5^DDL!!'& 4+?+?+Jh+V+V'n-   
 -E^Uj,k,k!    +0088 AL AL"2>>^E\>]]0>0P@B+1.AA
'@ ,'B>_c'd'd'd$$'+$P"/"B>_c_p"q"q"qKK  P P P5EaHHaOP .0.9.?.?.A.A  *J
!:!::O_Oj!k!k!kJ,9*:OQ],^,^J) #m3[zZE[7[ G(
0FF  #j&<<<'..z::: )4&2:&*:::1A*1M
.CCDDXZdfpqqq)-)G)G"J
X *H * *F:&& # "&))+M+M_+M+M+M"M"MK 11Q6FMEf4ss" E E{ E EXfXo E E$*455E E E $	   (9&% % % % %!+!;!B!B!D!D% % % '&	 	 		 66y*B^BeBeBgBghh/
8S8Z8Z8\8\^cddyCCFKKCAL AL AL AL AL AL AL7\	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L6AL AL AL AL AL AL AL AL AL7\	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	L \	Ls   O	N1O	&AN1*B;:N1;C
N1	C

N1'ANE"!N"
F	,F	F	G.N4N1 O	NN1 N!N1%O	1N5	5O	8N5	9O		OOnamedtuple_clsc                   	  j                                       5   j                                      5 \  }}||cddd           cddd           S t	                    	||	 t          j         j                  }n'# t          $ r}t          j
        |          |d}~ww xY w|sd j        D             }	r 	fd|                                D             }t          j         fd|                                D             ddi          }t          j        ||	          } j                            |          cddd           cddd           S # 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )
z!Generate schema for a NamedTuple.Nr  c                    i | ]
}|t           S r   )r   )r   r   s     r   r   z5GenerateSchema._namedtuple_schema.<locals>.<dictcomp>K  s    .V.V.V!q#.V.V.Vr   c                8    i | ]\  }}|t          |          S r   rs   )r   r   r  r  s      r   r   z5GenerateSchema._namedtuple_schema.<locals>.<dictcomp>N  s9       .
J j, G G  r   c                    g | ]K\  }}                     ||t          j        j                            |t
          j                             LS ))r  default)_generate_parameter_schemar:   NAMED_TUPLE_field_defaultsr   r   empty)r   r   r  r%  r  s      r   r   z5GenerateSchema._namedtuple_schema.<locals>.<listcomp>T  sh        /
J 33""/; . > B B:y _ _	 4    r   'pydantic_js_prefer_positional_argumentsTrT  )rK  )r  r!  r  r  rr   rW   r  r  r%  rH   r&  _fieldsr   r1   arguments_schemacall_schemar  )
r  r%  r  namedtuple_refr:  r   r  r2  r   r  s
   ``       @r   r  z!GenerateSchema._namedtuple_schema6  s    !&&~66(	H (	HI''77(	H< '#(	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H 5^DDL!!'L+>~[_[lmmm L L L1A!DD!KL W.V.V~?U.V.V.V    2=2C2C2E2E  
  +;     3>2C2C2E2E   DTJ      !,-=~SabbbF9??GGQ(	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	H (	Hse   E=E% E=E%-B	E%	
B-B((B--BE%E=%E)	)E=,E)	-E==FFr  	type[Any]r:   r+  rt  JLiteral['positional_only', 'positional_or_keyword', 'keyword_only'] | Nonecore_schema.ArgumentsParameterc                   t                      }|t          j        u r |j        ||          }n |j        |||          }|j        
J d            | j                            |          5  |                     |j        |g          }ddd           n# 1 swxY w Y   |	                                st          ||          }t          j        ||          }	|||	d<   |j        |j        |	d<   n^| j        j        }
t!          |
t"                    r |
j        |
                    |          |	d<   nt%          |
          r |
|          |	d<   |	S )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 schemart  r  )ru   r   r/  r  from_annotated_attributer  r  r!  r  r  r  r1   arguments_parameterr  r  r  rs  r?   callable)r  r  r  r  r+  rt  r   r   r   parameter_schemar  s              r   r,  z)GenerateSchema._generate_parameter_schemab  s    -..	io%%-I-j&IIIEE6I6z7TZ[[[E++-k+++"''-- 	H 	H,,U-=wGGF	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H   "" 	1!%00F&:4HH'+V$;"(-W%%"2BO/>:: B?T?`,;,A,A$,G,G ))/** B,;OD,A,A )s   .BBBLiteral['positional_only', 'positional_or_keyword', 'keyword_only', 'var_args', 'var_kwargs_uniform', 'var_kwargs_unpacked_typed_dict'] core_schema.ArgumentsV3Parameterc                |   t                      }|t          j        u r |j        ||          }n |j        |||          }| j                            |          5  |                     |j        |g          }ddd           n# 1 swxY w Y   |	                                st          ||          }t          j        |||          }	|j        |j        |	d<   n^| j        j        }
t!          |
t"                    r |
j        |
                    |          |	d<   nt%          |
          r |
|          |	d<   |	S )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  N)r  r   rt  r  )ru   r   r/  r  r9  r  r!  r  r  r  r  r1   arguments_v3_parameterr  r  r  rs  r?   r;  )r  r  r  r  rt  r+  r   r   r   r<  r  s              r   _generate_parameter_v3_schemaz,GenerateSchema._generate_parameter_v3_schema  s   ( -..	io%%-I-j&IIIEE6I6z7TZ[[[E"''-- 	H 	H,,U-=wGGF	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H 	H   "" 	1!%00F&=
 
 

 ;"(-W%%"2BO/>:: B?T?`,;,A,A$,G,G ))/** B,;OD,A,A )s   BB
B

tuple_typec                    t          |                               |          }r|rt          fd|D                       }|sE|t          v r(t	          j        t	          j                    gd          S t	          j        g           S |d         t          u rRt          |          dk    r0t	          j         	                    |d                   gd          S t          d          t          |          dk    r |d         dk    rt	          j        g           S t	          j         fd	|D                       S )
zIGenerate schema for a Tuple, e.g. `tuple[int, str]` or `tuple[int, ...]`.c              3  8   K   | ]}t          |          V  d S r   r)  )r   paramr  s     r   r\  z/GenerateSchema._tuple_schema.<locals>.<genexpr>  s-      RR%===RRRRRRr   r   )r   r   r=   z&Variable tuples can only have one typerR   r   c                :    g | ]}                     |          S r   )r'  )r   rE  r  s     r   r   z0GenerateSchema._tuple_schema.<locals>.<listcomp>  s'    ,],],]UT-A-A%-H-H,],],]r   )rr   r/  r   r   r1   tuple_schemar   Ellipsisrc  r'  
ValueError)r  rB  paramsr  s   `  @r   r  zGenerateSchema._tuple_schema  sY    1<<66zBB 	SF 	SRRRR6RRRRRF  	_[(("/1G1I1I0J`abbbb #/333BZ8##6{{a"/1E1EfQi1P1P0Qghiiii !!IJJJ[[A&)r// +B///+,],],],]V\,],],]^^^r   c                ^    t          j        t          j        t                    dd          S )Nis_typezInput should be a typer  )r1   custom_error_schemar_  r   r  s    r   r  zGenerateSchema._type_schema  s0    .*400'!9
 
 
 	
r   c                j    ddl m} dd gi}t          j        |t          j                    |          S )z/Generate schema for a zone_info.ZoneInfo objectrR   )validate_str_is_valid_iana_tzrH  c                    dddS )Nr|  zoneinfor}  r   r  s     r   r>  z1GenerateSchema._zoneinfo_schema.<locals>.<lambda>  s    hZd=e=e r   r   rL  )r  rO  r1   r  r  )r  rO  rL  s      r   r  zGenerateSchema._zoneinfo_schema  sQ    >>>>>>+.e.e-fg;)%:<<
 
 
 	
r   c                r                           |d          }t          j         fd|D                       S )z*Generate schema for `type[Union[X, ...]]`.Tr  c                P    g | ]"}                     t          |                   #S r   r'  r   )r   r^  r  s     r   r   z<GenerateSchema._union_is_subclass_schema.<locals>.<listcomp>  s+    ([([([d)=)=d4j)I)I([([([r   )r/  r1   r  )r  r  r^  s   `  r   _union_is_subclass_schemaz(GenerateSchema._union_is_subclass_schema  sB    44Z$4OO'([([([([VZ([([([\\\r   type_c           
     x                          |          }t          j        |          p|}t          j        |          r                                 S t          j        |          r%                     t          |j	                           S t          j
        |          r|j        rTt          t          |j                            r                     |j                  S t          j        |j                  S |j        r%t          j         fd|j        D                       S                                  S t          t          |                    r                     |          S t          j        |          r                     |          }t          j        |          r7t-          d|dt/          j        t          |                     dd          t3          j        |          s2|t          j        t          j                  S t9          d|          t          j        |          S )z-Generate schema for a type, e.g. `type[int]`.c                P    g | ]"}                     t          |                   #S r   rU  )r   cr  s     r   r   z3GenerateSchema._subclass_schema.<locals>.<listcomp>   s,    0s0s0sST1E1Ed1g1N1N0s0s0sr   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 )r`  rW   annotated_typer9   r  r  r  r'  r   r  
is_typevar	__bound__r<   r7   rV  r1   is_subclass_schema__constraints__r  rg  rC  is_generic_aliasrI   rV   display_as_typerX  r  r  r   )r  rW  
type_params   `  r   r  zGenerateSchema._subclass_schema  sE   //66
 #1*==K
 ,, 	>$$&&&,Z88 	>''Z-A(BCCC&z22 	># +":j.B#C#CDD P99*:NOOO"5j6JKKK+ +"/0s0s0s0sXbXr0s0s0sttt((***Z
3344 	>11*===%j11 A!44Z@@
-j99 'y-7y yGLG\]ghr]s]sGtGty y y   
 ?:.. I %&9-:PQQQ G G GHHH1*===r   c                   ddl m} |                     |          }t          j        |          }t          |          }t          j        t          j        d          }t          j
        |          s/ddlm} t          j        |t          j        ||          g          }t          j        ||d          }t          j        |||          S )	z5Generate schema for a Sequence, e.g. `Sequence[int]`.rR   r  Sequencer  )sequence_validatorTr  )rC  rw  r   )r  r  r'  r1   r&  r}   r_  r  rd  r9   r  r  re  r  r  r  r  )	r  r$  r  r  r&  rC  rw  re  r   s	            r   r  zGenerateSchema._sequence_schema  s    ======//
;;!-.>??$[11#6vQ[\\\$Z00 	777777'4 KL^`k l lm M $G'0@4
 
 
 0#=P]
 
 
 	
r   core_schema.GeneratorSchemac                z    |                      |          }t          j        |                     |                    S )z$Generate a schema for an `Iterable`.)r`  r1   generator_schemar'  )r  rW  	item_types      r   r  zGenerateSchema._iterable_schema-  s4    ..u55	+D,@,@,K,KLLLr   pattern_typec                   ddl m} dd gi}t          j        t	          d          dt          j                              }|t          j        u s|t          j        u rt          j	        |j
        ||          S |                     |d	
          d         }|t          u rt          j	        |j        ||          S |t          u rt          j	        |j        ||          S t!          d|d          )NrR   )r  rH  c                    dddS )Nr|  regexr}  r   r  s     r   r>  z0GenerateSchema._pattern_schema.<locals>.<lambda>6  s    hZa=b=b r   patternr   )r   return_schemarR  Tr  r   r  r   )r   r  r1   r   r   r  r  Patternrer  pattern_either_validatorr/  r   pattern_str_validatorr  pattern_bytes_validatorrG   )r  rj  r  rL  serrE  s         r   r  zGenerateSchema._pattern_schema3  s<   !!!!!!+.b.b-cd>y!!V;CYC[C[
 
 
 6>))\RZ-G-G?4CRZ    55 6 
 
  C<<?1x    e^^?33QY    00p_k0p0p0pqqqr   c           
     &   t          j        t          j        t          j        t          j                    t          j        t          j        j                  g          t          j        t          j        j                            dd          S )Nrv  r  zInput should be hashable)r   r  r  )	r1   rM  r  r  r   r_  r  abcHashabler  s    r   r  zGenerateSchema._hashable_schemaO  s    .4'4 +--{/MkoNf/g/gh  *<[_=UVV	   ,!;	
 	
 	
 		
r   	dataclasstype[StandardDataclass]type[StandardDataclass] | Nonec                	     j                             |          5   j                            |          5 \  }}||cddd           cddd           S |j                            d          }|t          |t                    s|d         dk    r j                            |          }t          |          }|r2 j        
                    |          cddd           cddd           S |cddd           cddd           S t          |          }||}t          |dd          }ddlm}	  j                            |          5   j                            |          5   |	|          r|                                rPd |j                                        D             }
|r*|
                                D ]} |j        |g j        R   n_	 t/          | j         j        |pi 	          }
n># t2          $ r}t5          j        |          |d}~ww xY wt9          || j        
          }
 j        j        dk    r8|
                                D ]#\  }}|j        du rt?          d| dd          $|j                            d          ptA          j!        |          tE           fd|
                                D             d           }tG          |d          }tG          |d          }tI          j%        |j&        | fdj'                                        D             |          }tQ          |j)                                        d          }j*                                        }tW          ||d          } j        ,                    |j&                  }tI          j-        |||||d t          j.        |          D             || j        j/        j0        	  	        } 1                    |j2                                                  }tW          ||d          } j        
                    |          cddd           cddd           cddd           cddd           S # 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z Generate schema for a dataclass.Nr  r   r  r   r=   )is_pydantic_dataclassc                4    i | ]\  }}|t          |          S r   r	   )r   f_namer  s      r   r   z4GenerateSchema._dataclass_schema.<locals>.<dictcomp>  s3     " " "9KFD$4$4" " "r   )r	  r
  r  )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   r'  c              3  L   K   | ]\  }}                     ||          V  d S r   )r  r  s      r   r\  z3GenerateSchema._dataclass_schema.<locals>.<genexpr>  s9      aa$!QT33Aq*EEaaaaaar   c                0    |                      d          duS )Nr  F)r   )r   s    r   r>  z2GenerateSchema._dataclass_schema.<locals>.<lambda>  s    !%%	"2"2%"? r   )key__post_init__	__slots__c                F    g | ]}                     |j                  S r   r  r  s     r   r   z4GenerateSchema._dataclass_schema.<locals>.<listcomp>  r  r   )r  collect_init_onlyr  r  c                    g | ]	}|j         
S r   )r  )r   r   s     r   r   z4GenerateSchema._dataclass_schema.<locals>.<listcomp>  s    RRR5EJRRRr   )r	  r  rK  r   slotsr  r  r  )3r  r!  r  r  r  r   rs  rv   r  r\   r  rr   r   r  r}  r  r  r#  r  r   rW  apply_typevars_mapr   rn   r  r%  rH   r&  rm   extrar  rI   ra   r  sortedr$  r1   dataclass_args_schemar   r  r   r5  r+  r2  r"  dataclass_schemar   r  r  r6  r7  )r  ry  r  dataclass_refr:  r   rK  r  r  r}  r   r   r  r   r^  has_post_init	has_slotsargs_schemar   r+  r"  	dc_schemar   s   `                     @r   r  z GenerateSchema._dataclass_schema[  s   
 !&&y11q	L q	LI''	22q	L7 '#q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L '++,FGGF!*V^*L*L!&>]22!Y99&AAFfoo "9GGOO!q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L$ "%q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L( 5Y??L!"	
 Y(=tDDF;;;;;;"''	22 RL RLD4N4S4STZ4[4[ RL RL((33  ==?? X
" "OXOlOrOrOtOt" " " ( _)/ _ _ 8 8 ^H] ^ ^ ^ ^ ^X%= )/3/C,0,=-9-?R	& & &FF  ) X X X"="Ma"P"PVWWX 6!%1'+';  F '-88-3\\^^  )
E :.."3!D !D !D !D%G# # #  / '/334MNNqR`RfgpRqRq
 aaaaaRXR^R^R`R`aaa??   !(	? C C#I{;;	)?&% % % % %!+!;!B!B!D!D% % % '4    0Z=W=^=^=`=`bfgg#-#>#E#E#G#G 5lDTV]^^"2>>YEW>XX'8 #)+%RRK4Fy4Q4QRRR#&  5:A  	 66y*B^BeBeBgBghh/8H'RRyCCFKKeRL RL RL RL RL RL RL RL RL RL RL RL RL RL?q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L>RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL RL?q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	L q	Ls   S
R2S
BR2S
2R23S
AR2R+A0R	G<;R	<
H HH  H3R	RR2+S
RRRRR2RR2"R#R2&S
2R6	6S
9R6	:S

SSfunctionValidateCallSupportedTypescore_schema.CallSchemac                4   |                      |          }d}| j        }|j        r]t          |          }|j        }||j        ur>| j        \  }}t          j        |||dh          }	| 	                    |	d                   }t          j        |||          S )zsGenerate schema for a Callable.

        TODO support functional validators once we support them in Config
        Nr   )globalnslocalnsinclude_keys)ro  )_arguments_schemar  validate_returnr   return_annotationr/  r   rW   get_function_type_hintsr'  r1   r3  )
r  r  r2  ro  r	  sigreturn_hintr  r  
type_hintss
             r   r  zGenerateSchema._call_schema  s    
  11(;;7;-) 	KH%%C/K#)++$($9!'*BxPXz  
 !% 4 4Z5I J J&'
 
 
 	
r   parameters_callbackParametersCallback | Nonecore_schema.ArgumentsSchemac                   t           j        dt           j        dt           j        di}t	          |          }| j        \  }}t          j        |||          }g }d}	d}
d}t          |j	        
                                          D ]#\  }\  }}|j        |j        u r t          j        t          t                    }n||         }| ||||          }|dk    rU|                    |j                  }|>|                     ||t&          j        |j        |          }|                    |           |j        t           j        k    r|                     |          }	|j        t           j        k    sJ |j                    t          j        |          }|t7          |          p|}t9          |          st;          d|d	          d
 |j	        
                                D             }|                    |j                  }|r^t;          d|j         dtC          |          dk    rdnd dd"                    d tG          |          D                        d	          d}| $                    |t7          |                    }
d}|                     |          }
%tK          j&        ||	||
| j'        j(                  S )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   c                B    h | ]\  }}|j         t          j        k    |S r   kindr   POSITIONAL_ONLYr   r  ps      r   	<setcomp>z3GenerateSchema._arguments_schema.<locals>.<setcomp>  3     0 0 0!(qafPYPiFiFiFiFiFir   Typed dictionary  overlaps with parameterr=   r  r   r  r  c              3  4   K   | ]}t          |          V  d S r   r	  r   r  s     r   r\  z3GenerateSchema._arguments_schema.<locals>.<genexpr>$  (      (U(UQa(U(U(U(U(U(Ur   overlapping-unpack-typed-dictzunpacked-typed-dictuniform)var_args_schemavar_kwargs_modevar_kwargs_schemavalidate_by_name))r   r  POSITIONAL_OR_KEYWORDKEYWORD_ONLYr   r   rW   r  	enumerate
parametersr   r  r/  r  r&   r   r   r  r,  r:   FUNCTIONr+  r  VAR_POSITIONALr'  VAR_KEYWORDunpack_typer7   r8   rI   intersectionr  r   rc  r  r  r  r1   r2  r  r  )r  r  r  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  z GenerateSchema._arguments_schema  s<   
 %'8+-D"Nr
 !! 1'":8h`ghhh
?A9=;?<@%cn&:&:&<&<== .	I .	ILAya|sy((#[c22

'-
".,,QjAAV##(__QV44N)!<<*&6&?N 
 %%j11119333"&"6"6z"B"Bv!6666666+7
CC*'44CF'// /eVaee!4   0 0,/N,@,@,B,B0 0 0, *B)N)NvOe)f)f&) /X X X&)*<&=&=&B&BssX X#yy(U(U&AS:T:T(U(U(UUUX X "A	    '<O(,(?(?ZXcMdMd(e(e%%&/O(,(<(<Z(H(H%%+++/!1B
 
 
 	
r   core_schema.ArgumentsV3Schemac                   t           j        dt           j        dt           j        dt           j        di}t          |          }| j        \  }}t          j        |||          }g }t          |j
                                                  D ]\  }	\  }
}| ||	|
|j                  }|dk    r$|j        t           j        u r t          j        t           t                     }n||
         }|                    |j                  }||j        t           j        k    sJ |j                    t          j        |          }|t+          |          p|}t-          |          st/          d|d	          d
 |j
                                        D             }|                    |j                  }|r^t/          d|j        dt7          |          dk    rdnd dd                    d t;          |          D                        d	          d}|}nd}|                    |                     |
|t@          j!        ||j"                             tG          j$        || j%        j&                  S )Nr  r  var_argsr  r  r  r  r  r   c                B    h | ]\  }}|j         t          j        k    |S r   r  r  s      r   r  z6GenerateSchema._arguments_v3_schema.<locals>.<setcomp>_  r  r   r  r  r=   r  r   r  r  c              3  4   K   | ]}t          |          V  d S r   r	  r  s     r   r\  z6GenerateSchema._arguments_v3_schema.<locals>.<genexpr>g  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  r/  r  r&   r   r   r  r  r  r7   r8   rI   r  r  r   rc  r  r  r  rA  r:   r  r+  r1   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_schemaz#GenerateSchema._arguments_v3_schema6  s    %'8+-D$j"N	
 	 !! 1'":8h`ghhh
BD%cn&:&:&<&<== +	 +	LAya".,,QalCCV##|y..#[c22

'-
(__QV44N%v!6666666+7
CC*'44CF'// /eVaee!4   0 0,/N,@,@,B,B0 0 0, *B)N)NvOe)f)f&) /X X X&)*<&=&=&B&BssX X#yy(U(U&AS:T:T(U(U(UUUX X "A	    &FN!,JJ%9N""22*&6&?YZYb 3      .!1B
 
 
 	
r   typevartyping.TypeVarc                   	 |                                 }|r|                     |j                  S n# t          $ r Y nw xY w|j        x}r%|                     t          j        |                   S |j        x}rB|                     |          }t          j
        d t          j                              |d<   |S t          j                    S )Nc                     ||           S r   r   )r=  r  s     r   r>  z>GenerateSchema._unsubstituted_typevar_schema.<locals>.<lambda>  s    QQqTT r   )r   r   )has_defaultr'  __default__r  r_  r  r  r%   r]  r1   r  r   )r  r  r  constraintsr   r   s         r   r  z,GenerateSchema._unsubstituted_typevar_schemaz  s    	A!--//K
  A++G,?@@@A	  	 	 	D	 "11; 	A%%fl;&?@@@%%5 	))%00F&1&U!!"-//' ' 'F?# M%'''s   3 
A A r  Decorator[ComputedFieldInfo]r  2dict[str, Decorator[FieldSerializerDecoratorInfo]]core_schema.ComputedFieldc                |   |j         j        t          ur|j         j        }nN	 t          j        |j        | j        j                  }n'# t          $ r}t          j
        |          |d }~ww xY w|t          u rt          dd          t          || j                  }t          j        |j         |          |_         |                     |          }|                     |t%          |                                |j                            }| j        j        }|"|                     ||j         |j                   |                     | j        |j         |j                   t3          |j                   \  }}i }	t5          |	ddi|r|ni |	           t7          j        |j        ||j         j        |	
          S )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)r  r  r  readOnlyTr  )ro  r  rL  )r   r  r/   rS   get_callable_return_typefuncr   localsr%  rH   r&  rI   rs   r  r  replacer'  r  r   rW  r   r  r  r  r  r   r[   r1   computed_fieldr  )
r  r  r  r  r  return_type_schemar  r  r  r  s
             r   r  z%GenerateSchema._computed_field_schema  s   
 6%666&,KKL *B16SWShSoppp L L L1A!DD!KL+++#f5    $K1CDD $QVEEE!11+>>!::01B1I1I1K1KQ^\\
 

 .>&>> /QVabao ?    	778LafVWVdeee1Z[\[a1b1b..(*!+T jM`6h6I6Ifh j/	
 	
 	
 	

 )N*<AFL[h
 
 
 	
s   %A 
A,A''A,r[  c                    t                      }|                     |d          ^}}|                     ||          }|D ]"}t          ||          rt	          ||          }#|S )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   ri  z GenerateSchema._annotated_schema  s    ,..	$($I$I %J %
 %
!k ((kBB & 	: 	:J*i00 :%j&99r   c                    | S r   r   r<  s    r   r>  zGenerateSchema.<lambda>  s    q r   r  r   	list[Any]r  "Callable[[CoreSchema], CoreSchema]c                Z    t          t          j        |                    }g }d	 fd}t          |           }|D ]}|                     |||          } |          }|r'|                    di           }	t          |	|           t           j        j	        |          S )
a  Apply arguments from `Annotated` or from `FieldInfo` to a schema.

        This gets called by `GenerateSchema._annotated_schema` but differs from it in that it does
        not expect `source_type` to be an `Annotated` object, it expects it to be  the first argument of that
        (in other words, `GenerateSchema._annotated_schema` just unpacks `Annotated`, this process it).
        r  r   r   r+   c                                         |           }|                    |           }t          |           }|-t          |j                  }|                    ||            |          S r   )r  r  r  r  r  r  )r  r   r  r  r  r  r  s       r   inner_handlerz8GenerateSchema._apply_annotations.<locals>.inner_handler  s    AA#{SSF~44S99#DS#I#I #/"9&$)"L"L".))/;OPPP))&111r   NrL  ) pydantic_js_annotation_functionsr  r   r   r+   )
rU  rU   expand_grouped_metadatar{   _get_wrapped_inner_schemar  r[   r   r  r   )
r  r  r   r  r  r  get_inner_schemar  r   r  s
   `` `      r   r  z!GenerateSchema._apply_annotations  s     4L[YYZZHJ(	2 	2 	2 	2 	2 	2 	2 	2 8tLL% 	 	J!#== *.N    "!+..+ 	s"--j"==M Qqrrrr;D<P<^`kmstttr   rL  c                d   t                      }t          ||          rD|j        D ]}|                     ||          }|j        |                     ||j                  }|S |d         dk    rF|                    dt          j                              }|                     ||          }|r||d<   |S |}|                    d          }|M|	                                }|dt          |           z   }| j                            |          x}	|	S ||d<   n||d         dk    rp|d         }| j                            |          x}
L|
	                                }|dt          |           z   }| j                            |          x}	|	S ||d<   t          j        ||          }||S |S )Nr   r   r   rK  rP  definition-refrf  )ru   rs  rL  _apply_single_annotationr  r  r   r1   r   r
   r
  r  get_schema_from_refrU   apply_known_metadata)r  r   rL  r   field_metadatar  rD  rK  new_refexistingreferenced_schemamaybe_updated_schemas               r   r  z'GenerateSchema._apply_single_annotation  s   ,..	h	** 	"*"3 O O66v~NN%1;;FHDZ[[M&>Z''JJx)?)A)ABBE11%BBE )#(x M jj?[[]]F0X000G I99'BBBO#F5MMF^///&C%)Y%B%B3%G%GG!T*//11 4DNN 4 44 $	 = =g F FFHS#O 'u8MhX^__+''r   c                    t                      }t          ||          rZ|j        D ]}|                     ||          }t	          |          \  }}|                    di           }t          |||           |S )NrL  r  )ru   rs  rL  $_apply_single_annotation_json_schemar   r  r[   )r  r   rL  r   r  r  r  r  s           r   r  z3GenerateSchema._apply_single_annotation_json_schema)	  s     -..	h	** 	"*"3 [ [BB6>ZZ5^_g5h5h2!2"--j"==M 3FZk    r   r  rA   r  list[GetJsonSchemaFunction]r{   c                b     t          dd           d fd}t          |           S )NrF  r  r   r   r   c                     |           }n7 |           }                     |          }                    |          }t                    }|                    |           |S r   )r  r  r  r  )r  r   r  r  annotation_get_schemar  r  r  s      r   new_handlerz=GenerateSchema._get_wrapped_inner_schema.<locals>.new_handlerA	  s    $0..v7GHH))&1166vzJJBB6:VV#DZ#P#P #/0778LMMMMr   )r  r   r   r   )r   r{   )r  r  r  r  r
  r	  s   ```` @r   r  z(GenerateSchema._get_wrapped_inner_schema9	  sb     ?FjRprv>w>w	 	 	 	 	 	 	 	 	 	 ,K>>>r   serializers-list[Decorator[FieldSerializerDecoratorInfo]]c                (   |rt          |          }|d         dk    r#|d         }|                     ||          |d<   |S d|v r| j                            |          }|d         }t	          |j        |j        j                  \  }}|j        j        t          ur|j        j        }nN	 t          j        |j        | j        j                  }n'# t          $ r}t          j        |          |d}~ww xY w|t          u rd}	n|                     |          }	|j        j        dk    r,t%          j        |j        |||	|j        j        	          |d
<   n=|j        j        dk    sJ t%          j        |j        |||	|j        j        	          |d
<   |S )z$Apply field serializers to a schema.r   r  r   rK  r   r  Nr   )is_field_serializerrz  ro  r   r   r   )r
   r  r  r  ri   r  r   rt  r  r/   rS   r  r   r  r%  rH   r&  r'  r1   r  r   r   )
r  r   r  r   
serializerr  rz  r  r  ro  s
             r   r  z'GenerateSchema._apply_field_serializersP	  s     /	&\\Ff~..%h/#'#@#@{#[#[x &EEfMM %RJ,DZ_V`VeVj,k,k)*2CCC(o9P #."F"1F1M# # #KK ! P P P5EaHHaOP /// $ $ 4 4[ A A#v--*5*YO(;%"/(o7+ + +'' "+w6666*5*ZO(;%"/(o7+ + +' s   +%C 
C5C00C51Iterable[Decorator[ModelSerializerDecoratorInfo]]c                   |                     dd          }|r't          |          d         }t          |j        |j        j                  }|j        j        t          ur|j        j        }nN	 t          j	        |j        | j
        j                  }n'# t          $ r}t          j        |          |d}~ww xY w|t          u rd}n|                     |          }|j        j        dk    r(t!          j        |j        |||j        j                  }	n't!          j        |j        |||j        j                  }	|	|d<   |r||d<   |S )z$Apply model serializers to a schema.rK  Nr   r  r   )rz  ro  r   r   )poprU  rj   r  r   rt  r  r/   rS   r  r   r  r%  rH   r&  r'  r1   r  r   r   )
r  r   r  rK  r  rz  r  r  ro  
ser_schemas
             r   r6  z'GenerateSchema._apply_model_serializers	  s|    !**UD11 %	1k**2.J/
AUVVH*2CCC(o9P #."F"1F1M# # #KK ! P P P5EaHHaOP /// $ $ 4 4[ A A#v--4?4cO%"/(o7	5 5 5

 )MO%"/(o7	  
 '1F?# 	 F5Ms   /%B 
B9B44B9)NN)r	  rX   r
  r  r  r  r   r   r   r   )r   rX   )r   rw   )r   r   )r$  r   r   r+   )r*  r   r+  r   r   r+   )r5  r6  r   r+   )r   r   r   r+   )r   r   r  r   r   r+   )r   r   r*  r   r+  r   r   r+   )r   r+   r  )r   r+   r  r  r   r+   r  )r  r+   r  r  r   r   )r  r   r   r   )r  r  r   r   )r  r   r   r   )r  r   r  r   r   rD  )r  r   r  rU  r   rV  )r  r   r   rX  )F)r  r   r  r   r   rX  )r  r   r   ra  )r  r   r  r   r   r+   )
r  r   r  r   r   ra   r  r   r   r  )r  r   r  r   r   ra   r   r  )r  r   r  r   r   ra   r   r  )r  r  r  r   r   r   r   r   )r  r  r  r~   r  r   )r	  rX   r  r   r   r   r   r   )r  r   r  r   r   ra   r   r  )r  r   r   r   )r  r4   r   r+   )r  r   r   r+   )r  r   r  r   r   r   )r%  r   r  r   r   r   )r  r   r  r5  r  r:   r+  r   rt  r6  r   r7  )r  r   r  r   r  r:   rt  r=  r+  r   r   r>  )rB  r   r   r   )r   r   )rW  r   r   r   )r$  r   r   r   )rW  r   r   rf  )rj  r   r   r   )ry  rz  r  r{  r   r   )r  r  r   r  r   )r  r  r  r  r   r  )r  r  r  r  r   r  )r  r  r   r   )r  r  r  r  r   r  )r[  r   r   r   )r  r   r   r  r  r  r   r+   )r   r   rL  r   r   r   )r  rA   r  r   r  r  r   r{   )r   r   r  r  r   r   )r   r   r  r  r   r   )Nr   r   r   r   r  r  r  propertyr  r   r#  r)  r.  r1  r4  rb  r  r  r  r  r  r  r  r  r  r  r'  rA  rC  r  rT  r'   r/  r`  rd  r  rl  r  r  r  r  staticmethodr  r  r  r1  r  r  r  r  r  r   r/  r,  rA  r  r  r  rV  r  r  r  r  r  r  r  r  r  r  r  ri  r  r  r  r  r  r6  __classcell__)r   s   @r   r  r  C  s       ffI *.59	# # # # #
 
 
 
 
 
 / / / X/ 1 1 1 X1 < < < X<
I I I Ik k k kH H H HN N N NF F F FP
 
 
 
B8 8 8 8t
 
 
 
2$ $ $ $L
 
 
 
"
2 
2 
2 
2	
 	
 	
 	
   &   
	/ 	/ 	/ 	/% % % %NKL KL KL KLZ   9w 9w 9w 9wv   , iii XiWWW XW	 	 	 	 	          $ $ $ $8t. t. t. t.l1. 1. 1. 1.r 
 
 
 
 
 
&
 
 
 
"
 
 
 
* /[ /[ /[ \/[b (\ (\ (\ \(\T % % % \%*G
 G
 G
 G
R   6H H H H&   hL hL hL hLT*H *H *H *Hb ![_%  %  %  %  % h !/  /  /  /  / b_ _ _ _<
 
 
 
	
 	
 	
 	
] ] ] ]
%> %> %> %>N
 
 
 
.M M M Mr r r r8

 

 

 

uL uL uL uLn
 
 
 
4 fjI
 I
 I
 I
 I
X fjB
 B
 B
 B
 B
H( ( ( (.1
 1
 1
 1
f   & FQ[	*u *u *u *u *uX( ( ( (T    ? ? ? ?.6 6 6 6p- - - - - - - -r   r  c                ,    t          j        | |          S r   )r1   !no_info_before_validator_functionr  r   rP  s      r   r>  r>  	  s    0]^_ag0h0h r   c                ,    t          j        | |          S r   )r1   r^  r  s      r   r>  r>  	  s    {/[\]_e/f/f r   c                *    t          j        |           S r   )r1   r  )r  r  r  s      r   r>  r>  	  s    K,XYZ,[,[ r   c                ,    t          j        | |          S r   )r1   r  r  s      r   r>  r>  	  s    k.YZ[]c.d.d r   c                0    t          j        | ||          S N)r   )r1   #with_info_before_validator_functionr  r   r   s      r   r>  r>  	  s    ;;j	6j< < < r   c                0    t          j        | ||          S r  )r1   "with_info_after_validator_functionr!  s      r   r>  r>  	  s    +:h	6j; ; ; r   c                .    t          j        | |          S r  rK  )r  rP  r   s      r   r>  r>  	  s    [5c	j6 6 6 r   c                0    t          j        | ||          S r  )r1   !with_info_wrap_validator_functionr!  s      r   r>  r>  	  s    9f	6j: : : 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, str | None], core_schema.CoreSchema]]_VALIDATOR_F_MATCHr)  Iterable[Decorator[RootValidatorDecoratorInfo]] | Iterable[Decorator[ValidatorDecoratorInfo]] | Iterable[Decorator[FieldValidatorDecoratorInfo]]c                    |D ]O}t          |j        |j        j                  }|rdnd}t	          |j        j        |f         |j        | |          } P| S )a  Apply validators to a schema.

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

    Returns:
        The updated schema.
    r(  r'  )rk   r  r   rt  r)  )r   r)  r   	validatorrz  val_types         r   r   r   	  sd    "   i i	$Y^Y^5HII"*9;;	#Y^%8($CDY^U[]ghhMr   +Iterable[Decorator[ValidatorDecoratorInfo]]c                .    | D ]}|j         j        r dS dS )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   rx  )r)  r,  s     r   r  r  	  s1        	>  	44	5r   0Iterable[Decorator[ModelValidatorDecoratorInfo]]rt   Literal['inner', 'outer', 'all']c                   |                      dd          }|D ]0}|dk    r|j        j        dk    r|dk    r|j        j        dk    r1t          |j        |j        j                  }|j        j        dk    r:|rt          j        |j        |           } ~t          j        |j        |           } |j        j        dk    r:|rt          j        |j        |           } t          j	        |j        |           } |j        j        dk    sJ |rt          j
        |j        |           } t          j        |j        |           } 2|r|| d<   | S )	a  Apply model validators to a schema.

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

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

    Returns:
        The updated schema.
    rK  Nr  r   r  r   )r  r   r   )r  r   rt  rk   r  r1   r&  r  r   r  r#  r^  )r   r)  rt  rK  r,  rz  s         r   r2  r2  	  s   & jj--C n n	7??y~2h>>7??y~2h>>$Y^Y^5HII>&(( m$FPYP^gmnnn$Dineklll^ H,, o$HR[R`ioppp$FPYP^gmnnn>&'1111 n$GQZQ_hnooo$Ey~flmmm
 uMr   r  r   c                    | j         r4t          j        || j         t          | j                   | j                  S | j        t          ur!t          j        || j        | j                  S |S )a  Wrap schema with default schema if default value or `default_factory` are available.

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

    Returns:
        Updated schema by default value or `default_factory`.
    )default_factorydefault_factory_takes_datar  )r+  r  )r4  r1   with_default_schemarp   r  r+  r/   )r  r   s     r   r  r  )
  s     ! .&6'DZE_'`'`'8	
 
 
 	
 
	#4	4	4.J.A\
 
 
 	
 r   GetJsonSchemaFunction | Nonec                R   t          | dd          }t          | d          rat                      }|duo|j        j        |t          |dd          fv}|s.t          | dd          }t          d|rd| dnd	 d
d          t          |           x}t          |          S |dS |S )z`Extract `__get_pydantic_json_schema__` from a type, handling the deprecated `__modify_schema__`.__get_pydantic_json_schema__N__modify_schema__rG  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   r9  rG  rI   r7   r  )r   js_modify_functionr   has_custom_v2_modify_js_funccls_namer  s         r   r  r  B
  s    %CTJJr&'' ,..	 d* W6?&0BJPT(U(UVW 	% , 	r:t44H#nZb=j=V8=V=V=V=Vhjn n n)    R.. - 1888!tr   c                  L    e Zd ZU ded<   ded<   ded<   ded<   ded	<   d
ed<   dS )r  r   r   4str | list[str | int] | list[list[str | int]] | Noner  r   r  bool | Noner  r  zdict[str, Any]rL  N)r   r   r   r  r   r   r   r  r  b
  sZ         """"JJJJ####&&&&r   r  )r  r  r  r  rL  r  r@  r  r  rA  r  rL  c                   | |||||dS )Nr   r  r  r  r  rL  r   rC  s         r   r  r  k
  s%     ,2!6  r   r  r  CoreSchema | Nonec                |    | d         dk    r|                     | d                   S | d         dk    r| d         S | S )Nr   r  rf  r  r   )r  r   r  s     r   r  r  ~
  sJ    f~)))..vl/CDDD	=	(	(hr   def_ref%core_schema.DefinitionReferenceSchema.Literal['inline', 'keep', 'preserve_metadata']c                v    d| v rdS |                      d          }|sdS t          |          dk    rd|v rdS dS )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   keeprL  inlinerR   %pydantic_internal_union_discriminatorpreserve_metadata)r   rc  )rG  rL  s     r   _inlining_behaviorrO  
  sY     '!!v{{:&&H x
8}}EQQ""6r   c                  t    e Zd ZU dZded<   	 ded<   	 ddZedd            ZddZddZ	d dZ
d!dZd"dZdS )#r  z*Keeps track of references and definitions.zset[str]_recursively_seenz!dict[str, core_schema.CoreSchema]r  r   r   c                :    t                      | _        i | _        d S r   )r   rQ  r  r  s    r   r  z_Definitions.__init__
  s    !$r   r   r   CGenerator[tuple[str, core_schema.DefinitionReferenceSchema | None]]c             #  4  K   t          |          }|| j        v s	|| j        v r|t          j        |          fV  dS | j                            |           	 |dfV  | j                            |           dS # | j                            |           w xY w)a  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]   rQ  r  r1   rj  adddiscard)r  r   rK  s      r   r  z_Definitions.get_schema_or_ref
  s      , 2$(((C43D,D,D?DDEEEEEE"&&s+++4Dk!!!&..s33333&..s3333s   A; ;BrK  r   rD  c                6    | j                             |          S )z,Resolve the schema from the given reference.)r  r   )r  rK  s     r   r  z _Definitions.get_schema_from_ref
  s     $$S)))r   r   r+   rH  c                N    |d         }|| j         |<   t          j        |          S )zStore the schema as a definition and return a `'definition-reference'` schema pointing to it.

        The schema must have a reference attached to it.
        rK  )r  r1   rj  )r  r   rK  s      r   r  z/_Definitions.create_definition_reference_schema
  s+    
 Um!'#6s;;;r   core_schema.DefinitionsSchemac                H    |d         D ]}|| j         |d         <   |d         S )zZStore the definitions of the `'definitions'` core schema and return the inner core schema.r  rK  r   )r  )r  r   
def_schemas      r   r  z_Definitions.unpack_definitions
  s6     / 	> 	>J3=Dj/00hr   c                   | j         }	 t          ||          }n# t          $ r}t          |d}~ww xY wi }|d                                         D ]\  }}|t          |          x}dk    r|dk    r>|                                 |                    |                     ||                     `|dk    rW|	                    d          }	|                                 |                    |                     ||                     |	|d<   |                     ||          ||<   |d         D ]r}
|
d         	                    d	d          }|!t          j        |
                                ||          }|
                                 |
                    |           s|r*t          j        |g |                                
          }|S )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_referencesrK  rL  rN  rL  deferred_discriminator_schemasrM  rF  )r  rz   ry   r   r   rO  clearrB  _resolve_definitionr  rT   r  r
   r1   definitions_schemarW  )r  r   r  gather_resultr  remaining_defsrK  inlinable_def_refinlining_behaviormetacsr  applieds                r   r  z_Definitions.finalize_schema
  s!    '	,7'  MM & 	, 	, 	,$!+	, 13 '44J&K&Q&Q&S&S 	Q 	Q"C" ,GYZkGlGl2l2Cqw1w1w$00
 &++---%,,T-E-Ec;-W-WXXXX&*=== -00<<D%++---%,,T-E-Ec;-W-WXXX48%j1
 '+&>&>sK&P&Ps## @A 
	 
	B(*:(:(:;bdh(i(iM$ *>rwwyy-YghhGHHJJJIIg 	k 36OiQ_QfQfQhQhOijjjFs    
2-2r  dict[str, CoreSchema]c                P   ||         }|d         dk    r|S t                      }|d         dk    rot          |          dk    r\|d         }||v rt          | dd          |                    |           ||         }|d         dk    rt          |          dk    \i |d|iS )	Nr   r  rL  rf  z) contains a circular reference to itself.zcircular-reference-schemar   rK  )r   rO  rI   rU  )r  rK  r  
definitionvisitedrf  s         r   r`  z _Definitions._resolve_definition"  s     %
f!111  EE $4449KJ9W9W[c9c9c#L1JW$$'EEELg    KK
###$Z0J  $4449KJ9W9W[c9c9c **)eS)))r   Nr  )r   r   r   rS  )rK  r   r   rD  )r   r+   r   rH  )r   rY  r   r+   r  )rK  r   r  ri  r   r+   )r   r   r   r   r  r  r   r  r  r  r  r  r`  r   r   r   r  r  
  s         44 4333    4 4 4 ^4@* * * *< < < <       8 8 8 8t* * * * * *r   c                  :    e Zd ZdZddZedd            Zdd
ZdS )r  _stackr   r   c                    g | _         d S r   rn  r  s    r   r  z_FieldNameStack.__init__8  s    !#r   r   r   Iterator[None]c              #  x   K   | j                             |           d V  | j                                          d S r   ro  r  r  )r  r   s     r   r!  z_FieldNameStack.push;  s=      :&&&r   r   c                .    | j         r| j         d         S d S Nr   rn  r  s    r   r   z_FieldNameStack.getA      ; 	;r?"4r   Nr  )r   r   r   rq  )r   r   r   r   r   r  r  r   r!  r   r   r   r   r  r  5  sa        I$ $ $ $    ^
     r   r  c                  :    e Zd ZdZddZedd            Zdd
ZdS )r  rn  r   r   c                    g | _         d S r   rn  r  s    r   r  z_ModelTypeStack.__init__K  s    "$r   type_objr   rq  c              #  x   K   | j                             |           d V  | j                                          d S r   rs  )r  rz  s     r   r!  z_ModelTypeStack.pushN  s=      8$$$r   type | Nonec                .    | j         r| j         d         S d S ru  rn  r  s    r   r   z_ModelTypeStack.getT  rv  r   Nr  )rz  r   r   rq  )r   r|  rw  r   r   r   r  r  H  sa        I% % % %    ^
     r   r  )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r+   r   r+   )r   r   r   r   r   r   )r   r   r)  r*  r   r   r   r   )r)  r.  r   r   )r   r   r)  r0  rt  r1  r   r   )r  r   r   r   r   r   )r   r   r   r7  )r   r   r  r@  r  r   r  rA  r  rA  rL  r   r   r  )r   r+   r  r  r   rD  )rG  rH  r   rI  (  r   
__future__r   _annotationscollections.abcr  r  rs  rX  r  r  rq  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(   r)   rQ  r*   typing_extensionspydantic_corer+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   typing_inspectionr9   typing_inspection.introspectionr:   r;   r<   aliasesr>   r?   r@   annotated_handlersrA   rB   r  rC   rD   rE   rF   errorsrG   rH   rI   functional_validatorsrJ   rK   rL   rM   rN   rC  rO   versionrP   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   rk   _docs_extractionrl   r1  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   ListrU  rw  MutableSequencer   Setr   
MutableSetr   	FrozenSet	frozensetr   Dictr   r   r   rd  r   r   Typer   r   rp  r   r  Pathr  	PosixPathPurePosixPathPureWindowsPathr   MutableMappingOrderedDictDefaultDictr  r  Counterr  r  r  r   r  r  r   r   r   r   r   r   JsonEncodersr   r   	Exceptionr   r  r)  r   r  r2  r  r  r  r  r  rO  r  r  r  r   r   r   <module>r     sK   3 3 3 2 2 2 2 2 2           				  				 



   B B B B B B B B B B B B % % % % % %                               8 8 8 8 8 8 8 8 8 8 f f f f f f f f f f f f f f f f             D D D D D D D D D D D D                                             	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 f e e e e e e e e e e e e e e e , , , , , , a a a a a a a a a a = = = = = = = = = = K K K K K K K K O O O O O O O O O O O O b b b b b b b b b b w w w w w w w w w w w w w w ) ) ) ) ) ) # # # # # # 0 0 0 0 0 0 ` ` ` ` ` ` ` ` ` ` ` ` ` ` 6 6 6 6 6 6 6 6 > > > > > > > >                                       : 9 9 9 9 9            / . . . . . ? ? ? ? ? ? ? ? M M M M M M M M ) ) ) ) ) ) 9 9 9 9 9 9 9 9 O O O O O O O O C C C C C C 6 6 6 6 6 6 6 6 A55555555      %%%%%%//////@@@@@@&'1 13NPllm  !9ASTTT $%)**+-  *>  = = = =#+S2M,NP[Pf,f#g  g g g g S  S S S S!</ / / / / +t[_-LM
 M M M MS+/*DE	 E E E E & 0)[_=PQ  Q Q Q Q +t,
 , , , ,#]Km]hi i i i i$o{/GH H H H H$o{/GIY[f[j[tu u u u u +t,
 , , , ,#^RZ8 8 8 8 8KL
     N
OO"!
	 $fn5&,fl; ; ; ; ; #  !))C D D  .Zghh  i i i i
, , , ,"   6n n n n" " " "J
A 
A 
A 
A DI{*+   D% % % %& & & & & & & &r! r! r! r! r! r! r! r!rC ihff[[dd          2   2    , , , ,^   2   @    9    NR&*)-     &      (W* W* W* W* W* W* W* W*t       &         r   