o
    ɝi9                    @  s"  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?Z?ddl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZI ddl?mJZJmKZKmLZLmMZMmNZN ddlOmPZP ddlQmRZRmSZSmTZT ddlUmVZVmWZW ddlXmYZYmZZZ ddl[m\Z\m]Z]m^Z^m_Z_ ddl`maZambZbmcZc ddldmeZemfZfmgZgmhZhmiZi ddljmkZk ddllmmZm ddlmnZnmoZompZpmqZq d d!lrmsZsmtZtmuZumvZvmwZw d d"lxmyZymzZz d d#l{m|Z|m}Z} d d$l~mZmZmZ d d%lsmZmZmZmZmZmZmZmZmZmZmZmZ d d&lmZ d d'lmZmZmZmZmZ d d(lmZ d d)lmZmZ d d*lmZmZ d d+lmZ d d,lmZmZ d d-lmZmZ d d.lmZ d d/lmZmZ e1rdd0lmZmZ dd1lmZ dd2l,mZ d d3lmZ d d4lmZ ejd5kZe8eeef Ze7d6ed7Ze8ee ee ee f ZeYZd8ed9< e3e2egeHjBf Zd8ed:< d;Zd8ed<< ejegZd=ed>< ejeejjgZd=ed?< ejeejjgZd=ed@< ejeejjgZd=edA< ejegZd=edB< e"e#e$e%e&e'gZd=edC< ejejjgZd=edD< ejejjejejjgZd=edE< ejegZd=edF< ejejgZd=edG< e	je
je
je
je
je
jgZd=edH< ejejejjejjeje?jejejgZejejgZejejgZd=edI< e8e/e-e0ef ZeLeZdJdKdLdMeFfdNdOdPdQdRdSdTdUdVgZdWedX< 	 efeeeheidYZdZed[< ddbdcZddidjZddndoZddtduZddxdyZeee2 e^f ZdddZG dd deZG dd dZdd dd dd dd dd dd dd dd dZded< dddZdddZdddZdddZdddZdddZdddZdddZG dd dZ G dd dZG dd 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)ZoneInfo)	MISSING
CoreSchemaMultiHostUrlPydanticCustomError$PydanticSerializationUnexpectedValuePydanticUndefinedUrlcore_schemato_jsonable_python)	TypeAliasTypeAliasTypeget_args
get_originis_typeddict)typing_objects)AnnotationSourceget_literal_valuesis_union_origin   )AliasChoices	AliasPath)GetCoreSchemaHandlerGetJsonSchemaHandler)
ConfigDictJsonDictJsonEncoderJsonSchemaExtraCallable)PydanticSchemaGenerationErrorPydanticUndefinedAnnotationPydanticUserError)AfterValidatorBeforeValidatorFieldValidatorModesPlainValidatorWrapValidator)JsonSchemaValue)version_short)ArbitraryTypeWarningPydanticDeprecatedSince20TypedDictExtraConfigWarning UnsupportedFieldAttributeWarning   )_decorators_discriminated_union_known_annotated_metadata_repr_typing_extra)ConfigWrapperConfigWrapperStack)CoreMetadataupdate_core_metadata)get_refget_type_ref%is_list_like_schema_with_items_schema)	DecoratorDecoratorInfosFieldSerializerDecoratorInfoFieldValidatorDecoratorInfoModelSerializerDecoratorInfoModelValidatorDecoratorInfoRootValidatorDecoratorInfoValidatorDecoratorInfoget_attribute_from_basesinspect_field_serializerinspect_model_serializerinspect_validator)extract_docstrings_from_cls)collect_dataclass_fieldsrebuild_dataclass_fieldsrebuild_model_fieldstakes_validated_data_argumentupdate_field_from_config)PydanticRecursiveRef)get_standard_typevars_mapreplace_types)import_cached_base_modelimport_cached_field_info)MockCoreSchema)NamespacesTuple
NsResolver)MissingDefinitionErrorgather_schemas_for_cleaning)CallbackGetCoreSchemaHandler)lenient_issubclasssmart_deepcopy)ComputedFieldInfo	FieldInfo	BaseModel)Discriminator)StandardDataclass)GetJsonSchemaFunction)      FieldDecoratorInfoType)boundr2   ModifyCoreSchemaWrapHandlerGetCoreSchemaFunctionz1Callable[[int, str, Any], Literal['skip'] | None]ParametersCallbackz
list[type]TUPLE_TYPES
LIST_TYPES	SET_TYPESFROZEN_SET_TYPES
DICT_TYPESIP_TYPESSEQUENCE_TYPESITERABLE_TYPES
TYPE_TYPESPATTERN_TYPES
PATH_TYPESDEQUE_TYPES)aliasN)validation_aliasN)serialization_aliasNdefault)default_factoryN)excludeN)
deprecatedN)reprT)validate_defaultN)frozenN)initN)init_varN)kw_onlyNlist[tuple[str, Any]]+UNSUPPORTED_STANDALONE_FIELDINFO_ATTRIBUTES)beforeafterplainwrapzbdict[FieldValidatorModes, type[BeforeValidator | AfterValidator | PlainValidator | WrapValidator]]_mode_to_validatorinfoFieldDecoratorInfofieldstrreturnboolc                 C  s   | 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    r   _/var/www/html/ocr-read/venv/lib/python3.10/site-packages/pydantic/_internal/_generate_schema.py)check_validator_fields_against_field_name   s   r   
decoratorsIterable[AnyFieldDecorator]r   Iterable[str]Nonec                 C  sf   t |}| D ]*}d|jjv rq|jjdu rq|jjD ]}||vr/td|j d|j dddqqd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_fieldsrF   cls_refcls_var_name)r   r   decr   r   r   r   check_decorator_fields_exist   s   r   validator_functions+Iterable[Decorator[FieldDecoratorInfoType]]'list[Decorator[FieldDecoratorInfoType]]c                   s    fdd| D S )Nc                   s   g | ]
}t |j r|qS r   )r   r   ).0r   r   r   r   
<listcomp>       z8filter_field_decorator_info_by_field.<locals>.<listcomp>r   )r   r   r   r   r   $filter_field_decorator_info_by_field   s   r   schemacore_schema.CoreSchemaeach_item_validators'list[Decorator[ValidatorDecoratorInfo]]c                 C  s   |s| S | d dkrt | d || d< | S | d dkr3| d }d ur1t| d | || d |< | S t| rH| dt }t||| d< | S | d dkr_| dt }t||| d< | S td	| d  )
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^   r0   
any_schema	TypeError)r   r   r   inner_schemar   r   r   r      s.   
r   FieldInfo | ComputedFieldInfoAtuple[JsonDict | None, JsonDict | JsonSchemaExtraCallable | None]c                 C  sL   | j | jt| jp| jdkpd t| jd}dd | D }|p"d | jfS )N )titledescriptionr   examplesc                 S     i | ]\}}|d ur||qS Nr   r   kvr   r   r   
<dictcomp>"      z=_extract_json_schema_info_from_field_info.<locals>.<dictcomp>)r   r   r   r   r1   r   itemsjson_schema_extra)r   json_schema_updatesr   r   r   )_extract_json_schema_info_from_field_info  s   r   json_encodersJsonEncoders | Nonetpr   r*   c                 C  s   | s|S d|v r
|S |gt |d|jjdd R D ]#}| |}|du r&qtdt  dt tj	|dd|d< |  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   warningswarnrM   rO   r0   $plain_serializer_function_ser_schema)r   r   r   baseencoderr   r   r   ,_add_custom_serialization_from_json_encoders)  s   
$
r   c                   @  s   e Zd ZdZdS )InvalidSchemaErrorzThe core schema is invalid.N)__name__
__module____qualname____doc__r   r   r   r   r   K  s    r   c                      sn  e Zd ZdZdZ		ddddZd fddZedddZedddZ	edddZ
dddZddd Zdd!d"Zdd#d$Zdd'd(Zdd*d+Zdd-d.Zdd/d0Zdd1d2Zdd3d4Zdd5d6Zdd8d9Zdd=d>Zdd?d@Zd dDdEZddGdHZddKdLZddMdNZddQdRZddSdTZeddXdYZ edd[dYZ ddd]dYZ dd^d_Z!d	dadbZ"ddcddZ#ddedfZ$d
dhdiZ%djdkddsdtZ&ddvdwZ'ddydzZ(dd|d}Z)dddZ*dddZ+dddZ,dddZ-dddZ.e/j0dfdddZ1e/j0fdddZ2dddZ3dddZ4dddZ5dddZ6dddZ7dddZ8dddZ9dddZ:dddZ;dddZ<dddZ=	ddddZ>	dd ddZ?d!ddńZ@d"dd̄ZAd#ddτZBddф djfd$ddلZC	jd%d&dd܄ZDd'ddބZEd(ddZF	\dd)ddZGd*ddZHd+ddZI  ZJS (,  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                 C  s8   t || _|p	t | _|| _t | _t | _t	 | _
d S r   )rY   r  rx   r  r  _FieldNameStackr  _ModelTypeStackr	  _Definitionsr
  )selfr  r  r  r   r   r   __init__[  s   
zGenerateSchema.__init__c                   s   t    tjdtd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)clsr   r   r   r  i  s   

z GenerateSchema.__init_subclass__c                 C     | j jS r   )r  tailr  r   r   r   _config_wrapperq     zGenerateSchema._config_wrapperrw   c                 C  r  r   )r  types_namespacer  r   r   r   _types_namespaceu  r  zGenerateSchema._types_namespacer   c                 C  r  r   )r  arbitrary_types_allowedr  r   r   r   _arbitrary_typesy  r  zGenerateSchema._arbitrary_types
items_typer   r*   c                 C     t | |S r   )r0   list_schemagenerate_schemar  r$  r   r   r   _list_schema     zGenerateSchema._list_schema	keys_typevalues_typec                 C  s   t | || |S r   )r0   dict_schemar'  )r  r+  r,  r   r   r   _dict_schema  s   zGenerateSchema._dict_schemac                 C  r%  r   )r0   
set_schemar'  r(  r   r   r   _set_schema  r*  zGenerateSchema._set_schemac                 C  r%  r   )r0   frozenset_schemar'  r(  r   r   r   _frozenset_schema  r*  z GenerateSchema._frozenset_schema	enum_type
type[Enum]c                   sN  t j  tjsd ntj}|dkrd }j|ddd  D d t	t
r:dtd}n!t	trGdtd}nt	trTdtd}ntdd	 } rdfdd}tjdd tjju }tj |rxd njd|gid}| jjrtjtd||d}|S d fdd}tjd|gidS )NzAn enumeration.)r   r   c                 S  r   r   r   r   r   r   r   r     r   z/GenerateSchema._enum_schema.<locals>.<dictcomp>intr   floatc                 S     | S r   r   xr   r   r   <lambda>      z-GenerateSchema._enum_schema.<locals>.<lambda>r   r*   handlerr?   r   rL   c                   s    || }| |}|  |S r   )resolve_ref_schemaupdate)r   r<  json_schemaoriginal_schema)
js_updatesr   r   get_json_schema  s   

z4GenerateSchema._enum_schema.<locals>.get_json_schema__func__pydantic_js_functions)sub_typemissingrefmetadatavalue)r   c                   s.   |t j d}||}| |S )N)rE  rG  )r0   enum_schemar=  r>  )_r<  r?  r@  casesenum_refr3  rA  rE  r   r   get_json_schema_no_cases  s   

z=GenerateSchema._enum_schema.<locals>.get_json_schema_no_casesrH  )r   r*   r<  r?   r   rL   )r<  r?   r   rL   )list__members__valuesr]   r  inspectcleandocr   r   
issubclassr5  r0   simple_ser_schemar   r6  r   r   	_missing_r   rC  rJ  r  use_enum_values no_info_after_validator_functionr   is_instance_schema)r  r3  r   value_ser_typerB  default_missingrJ  rO  r   rL  r   _enum_schema  sN   


	
zGenerateSchema._enum_schemar   c                   s   ddl m}m} tdtdtdtdtdtdi dfdd}t	j
t	| t	jt	t	 t	dt	j|dddd fddgidS )NrR   )IP_VALIDATOR_LOOKUPIpTypeipv4ipv4networkipv4interfaceipv6ipv6networkipv6interfaceipr   r   core_schema.SerializationInfor   str | IpTypec                   D   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)rg  r   r   r   r   ser_ip     
z)GenerateSchema._ip_schema.<locals>.ser_ipr?  python_schemaTalwaysinfo_argr   rD  c                   s   d  dS )Nstringr   formatr   _1_2ip_type_json_schema_formatr   r   r   r:        z+GenerateSchema._ip_schema.<locals>.<lambda>
lax_schemastrict_schemar   rH  )rg  r   r   rh  r   ri  )_validatorsr_  r`  r   r   r   r   r   r   r0   lax_or_strict_schema no_info_plain_validator_functionjson_or_python_schemarZ  
str_schemar[  r   )r  r   r_  r`  rq  r   r~  r   
_ip_schema  s&   		zGenerateSchema._ip_schema	path_typec           	        s   t ju rtthvrtstdddt ju rtjn tu r*t	j
ddnt	jdd}tu r8t	
 nt	 }d fd
d}dfdd}t	jt	||t	d}t	jt	j|t	||gdd d|t	j|dddddd gid}|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              
     s   z6t u r(t| t r#z|  } W n! ty" } ztdd|d }~ww tddt| ts2tdd | W S  tyH } ztdd|d }~ww )N
bytes_typezInput must be valid byteszInput must be bytesr  zInput is not a valid path)bytesrn  decodeUnicodeDecodeErrorr,   r   r   )r  e)path_constructorr  r   r   path_validator   s"   




z3GenerateSchema._path_schema.<locals>.path_validatorpathr   r   rh  str | os.PathLike[Any]c                   rj  rk  rm  )r  r   rp  r   r   ser_path  rr  z-GenerateSchema._path_schema.<locals>.ser_pathrs  r  zInput is not a valid path for custom_error_typecustom_error_messageru  rv  rD  c                 S  s   i || ddiS )Nrz  r  r   )sourcer<  r   r   r   r:  *      z-GenerateSchema._path_schema.<locals>.<lambda>r  )r  r  r   r  )r  r   r   rh  r   r  )osPathLiker   r  r7   is_anyrF   pathlibPurePathr0   bytes_schemar  r  rZ  r[  r  union_schemar   )	r  r   r  strict_inner_schemalax_inner_schemar  r  instance_schemar   r   )r  r  r   r   _path_schema  s6    	

zGenerateSchema._path_schemac                 C  s|   ddl m} ddlm} | |}tj|dd}tj|tjt	j
ddd}t||}tj|t||gtj||d	d
dS )NrR   serialize_sequence_via_list)deque_validatorFr  Dequecls_reprrs  Tr   rw  r  r  r   )_serializersr  r  r  r'  r0   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  r   r   r   _deque_schema.  s    
zGenerateSchema._deque_schemac                 C  s  ddl m}m}m} || }| |}t  tjdtd | |}	W d    n1 s.w   Y  t	j
||	dd}
|tu rC|
}|S t	j|
t	|d}|tju ra||}tt	jt||d}ntt	j|}||
}t	||g}t	j||t	jd	d
 |
ddd}|S )NrR   )MAPPING_ORIGIN_MAPdefaultdict_validator'get_defaultdict_default_default_factoryignorecategoryFr  rs  )default_default_factoryc                 S  s   || S r   r   )r   hr   r   r   r:  o  s    z0GenerateSchema._mapping_schema.<locals>.<lambda>r  r  )r  r  r  r  r'  r   catch_warningssimplefilterrQ   r0   r-  r   r  r[  r  defaultdictr   r  rZ  r  r  r  )r  r   r+  r,  r  r  r  mapped_originkeys_schemar   r-  r   r  r  coerce_instance_wrapr  r  r   r   r   _mapping_schemaG  s@   

	


zGenerateSchema._mapping_schemac                 C  sL   ddl m} tjt|tjt|ttdtjddddd gid	S )
z7Support for [`fractions.Fraction`][fractions.Fraction].rR   )fraction_validatorrs  ru  r   rD  c                 S  
   dddS )Nrx  fractionry  r   r{  r   r   r   r:       
 z1GenerateSchema._fraction_schema.<locals>.<lambda>r  )	r  r  r0   r  r  r  r[  r   to_string_ser_schema)r  r  r   r   r   _fraction_schemau  s   
zGenerateSchema._fraction_schemac                 C  s.   t |tst|dt t S t|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`.)rn  r   r   r   rN   r0   r   r[  )r  r   r   r   r   _arbitrary_type_schema  s   

z%GenerateSchema._arbitrary_type_schemaobjc                 C  s   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.)rD   r  r  r   r   r   _unknown_type_schema  s   
z#GenerateSchema._unknown_type_schemar   discriminatorstr | Discriminator | Nonec                 C  sF   |d u r|S z
t ||| jjW S  t jy"   t || | Y S w r   )rT   apply_discriminatorr
  _definitionsMissingDefinitionForUnionRefset_discriminator_in_metadata)r  r   r  r   r   r   _apply_discriminator_to_union  s   z,GenerateSchema._apply_discriminator_to_unionc                 C     | j |S r   )r
  finalize_schema)r  r   r   r   r   clean_schema  s   zGenerateSchema.clean_schemametadata_schemajs_functionCallable[..., Any]c                 C  s6   | di }|dg }||vr|| ||d< d S )NrH  rD  )r   
setdefaultappend)r  r  r  rH  rD  r   r   r   _add_js_function  s
   
zGenerateSchema._add_js_functionr   c                 C  s^   |  ||}|du r| |}t|}|dur%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__`.
        N)	'_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  r   r   r   r'    s   
zGenerateSchema.generate_schemar  type[BaseModel]c                   s\  t  }j|\}}|dur|W  d   S |jd}|durQt|tsQ|d dkr5j|}t|}|rHj	|W  d   S |W  d   S t
|jdd}j| j| jj|jd}|jsw||u r~t|di }	n3d|jvrt|jd	|jd
dzt|jjjpi d}	W n ty }
 zt|
|
d}
~
ww |j  j}tt j  j  j  h |	! |!   j" }d}d}|ddkrZ|j#d |u sJ |j#d t$u sJ |j#dd D ]^}t|di dd}|durYt|t%r"t&j't&j(|dddgj)R  }t*|}|t+vr/t,dj-|dd\}}|t%urB.|}t/0|sM.|}|dusW|durY nqt|di d}|j1r2d|	d  \}}t3||d}t4j5|||t|dddt|dd||d}nBt4j6 fdd|	7 D  fd d!| D |||jd"}t8| j9 }t3||d}t4j5|||t|dddt|dd||d}:| j; }t3||d#}j	|W  d   W  d   W  d   S 1 sw   Y  W d   n1 sw   Y  W d   dS W d   dS 1 s'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  r  extra_fields_behaviorallowr   r   __annotations____pydantic_extra__T)is_argumentis_classzEThe type annotation for `__pydantic_extra__` must be `dict[str, ...]`required__pydantic_generic_metadata__originrootinner__pydantic_custom_init____pydantic_post_init__)generic_origincustom_init
root_model	post_initconfigrG  c                   s    i | ]\}}| || qS r   )_generate_md_field_schemar   r   r  r   r   r   X  s     z0GenerateSchema._model_schema.<locals>.<dictcomp>c                      g | ]	} | jqS r   _computed_field_schemafield_serializersr   dr  r   r   r   Y      z0GenerateSchema._model_schema.<locals>.<listcomp>)computed_fieldsextras_schemaextras_keys_schema
model_nameouter)<rt   r
  get_schema_or_ref__dict__r   rn  rv   unpack_definitionsr\   "create_definition_reference_schemarX   model_configr  pushr  r  core_configr   __pydantic_fields_complete__r   rE   rn   r  	NameErrorfrom_name_error__pydantic_decorators__r  r   r   field_validatorsrS  r  
validatorskeysmodel_validatorsr   objectr   rW   eval_type_backport_make_forward_refr!  r5   r   rD    _get_args_resolving_forward_refsr'  r7   r  __pydantic_root_model___common_field_schemaapply_model_validatorsr0   model_schemamodel_fields_schemar   r   root_validators_apply_model_serializersmodel_serializers)r  r  
BaseModel_	model_refmaybe_schemar   rG  r  r  r   r  r  r"  r  r  candidate_clsextras_annotationr   extra_keys_typeextra_items_typer  r   rK  r*  fields_schemar   r  r   _model_schema  s   
 


	











4$zGenerateSchema._model_schemac                 C  s"   | j  }|d u rtddd|S )Nz(`typing.Self` is invalid in this contextzinvalid-self-typer   )r	  r   rF   r  r   r   r   _resolve_self_types  s   
z!GenerateSchema._resolve_self_typer  core_schema.CoreSchema | Nonec                 C  sL  t  }t|dd }t|dd |jju }|d url|sl| j|\}}|d ur/|W  d    S W d    n1 s9w   Y  ||u rEd}nd}||t| j| |d}	|	d dkr^| j|	}	t	|	}
|
rj| j
|	S |	S |d u rt|dd  }d urd	d
lm} t||rtd|j dt ntdt tdd | D S d S d S )N__get_pydantic_core_schema__rC  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                 S  s   g | ]}t |qS r   r0   "with_info_plain_validator_functionr   r   r   r   r   r         zJGenerateSchema._generate_schema_from_get_schema_method.<locals>.<listcomp>)rt   r   r:  rC  r
  r  r{   r  r  r\   r  pydantic.v1r   rV  r   r   r   r  rO   r0   r  )r  r  r  r/  
get_schemais_base_model_get_schemarK  r1  r<  r   rG  r   BaseModelV1r   r   r   r  y  sL   
z6GenerateSchema._generate_schema_from_get_schema_methodc              
   C  sp   zt j|g| jR  }W n ty } zt||d }~ww t|tr-t|jd| | j	r6t
|| j	}|S )Nz%Unable to evaluate forward reference )rW   r$  r!  r  rE   r  rn  r!   __forward_arg__r  rs   )r  r  r  r   r   r   _resolve_forward_ref  s   
z#GenerateSchema._resolve_forward_refr  Literal[True]tuple[Any, ...]c                 C     d S r   r   )r  r  r  r   r   r   r&       z/GenerateSchema._get_args_resolving_forward_refstuple[Any, ...] | Nonec                 C  rJ  r   r   r  r   r   r   r&    rK  Fc                   sV   t |}|rt|trdd |D }t fdd|D }|S |r)td| d|S )Nc                 s  s(    | ]}t |trt|n|V  qd S r   )rn  r   rW   r%  r   ar   r   r   	<genexpr>     & zBGenerateSchema._get_args_resolving_forward_refs.<locals>.<genexpr>c                 3  s(    | ]}t |tr |n|V  qd S r   )rn  r!   rG  rM  r  r   r   rO    rP  z	Expected z+ to have generic parameters but it had none)r4   rn  r   r   r   )r  r  r  argsr   r  r   r&    s   
c                 C  s   |  |}|s	tS |d S )Nr   )r&  r   )r  r  rQ  r   r   r   _get_first_arg_or_any  s   
z$GenerateSchema._get_first_arg_or_anytuple[Any, Any]c                 C  sJ   |  |}|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   lenr5   r   )r  r  rQ  r  r   r   r   _get_first_two_args_or_any  s   
z)GenerateSchema._get_first_two_args_or_anyc                 C  s   t |r
| |}t t|r| |S t|tr|S t|tr&t	|}t|t	r3| 
| |S t }t||rV| j| | |W  d    S 1 sQw   Y  t|trbtj|jdS | |S )N)
schema_ref)r7   is_selfr8  is_annotatedr5   _annotated_schemarn  r   r   r!   r'  rG  rt   r|   r	  r  r7  rq   r0   definition_reference_schematype_ref
match_type)r  r  r   r   r   r   r    s$   






 

z%GenerateSchema._generate_schema_innerc                 C  s  |t u rt S |tu rt S |tu rt S |tu r t S |t	u r(t
 S |tu r0t S t|s9|tu r=t S |tju rFt S |tju rOt S |tju rXt S |tju rat S |tu rit S |tu rqt S |tu ryt S |tu r|   S |t!u rt" S |du s|t#j$u rt% S |t&u rt' S |t(v r| )|S |t*v r| +|S |t,v r| -t.S |t/v r| 0t.S |t1v r| 2t.S |t3v r| 4t.S |t5v r| 6|S |t7v r| 8t.t.S |t9v r| :|t.S |t;v r| <t.S |t=v r| >|t.t.S |t?v r| >|t.tS t@|r| A|S |tBu r&| C S t#D|r0tE S tFtG|r=| H|S tI|rH| J|dS t#K|rT| L|dS tM|r`| N|jOS |tPv rj| Q|S t#R|rt| S S tT|tUjVr| W|S t#X|r|tYu rt S | N| Z|S tT|t[r| \|S t]^|rt_|t`r| a|S |tbu r| c S tde|r| f|dS tG|}|dur| g||S | jhr| i|S | j|S )a  Main mapping of types to schemas.

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

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

        The idea is that we'll evolve this into adding more and more user facing methods over time
        as they get requested and we figure out what the right API for them is.
        N)kr   r0   r  r  r  r5  
int_schemar6  float_schemar   bool_schemacomplexcomplex_schemar7   r  r#  r   datetimedatedate_schemadatetime_schematimetime_schema	timedeltatimedelta_schemar
   decimal_schemar'   uuid_schemar/   
url_schemar   r  r+   multi_host_url_schemarW   NoneTypenone_schemar)   missing_sentinel_schemar   r  r   _tuple_schemar   r)  r   r   r0  r   r2  r   _sequence_schemar   _iterable_schemar   r.  r   r  r   r  MAPPING_TYPESr  COUNTER_TYPESis_typealiastype_type_alias_type_schemar   _type_schemais_callablecallable_schema
is_literalr5   _literal_schemar6   _typed_dict_schemais_namedtuple_namedtuple_schema
is_newtyper'  __supertype__r   _pattern_schemais_hashable_hashable_schemarn  typingr#   _unsubstituted_typevar_schemais_finalvarr    rR  VALIDATE_CALL_SUPPORTED_TYPES_call_schemarT  isclassrV  r   r^  r(   _zoneinfo_schemadataclassesis_dataclass_dataclass_schema_match_generic_typer#  r  r  )r  r  r  r   r   r   r\    s   



























zGenerateSchema.match_typer  c                 C  s  t |r| ||S t|r| ||S | ||}|d ur"|S t|r,| 	|S t
|r5| |S |tv r>| |S |tv rJ| | |S |tv rV| | |S |tv rb| | |S |tv rn| j| | S |tv r{| || |S |tv r| | |S |tv r| j|g| |R  S |tv r| || |tS t |r| !||S |t"v r| #|S |t$v r| %| |S |t&v r| '|S |t(v r| )|S | j*r| +|S | ,|S r   )-r  r  r  rW   r~  r  r  r7   rv  rw  r:   _union_schemar   rq  r   r)  rR  r   r0  r   r2  r   r.  rU  r   r  r   r  rt  r  ru  r5  r6   r}  r   _subclass_schemar   rr  r   rs  r   r  r#  r  r  )r  r  r  r   r   r   r   r  ~  sT   










z"GenerateSchema._match_generic_typeTr  r  r   
field_infor   r   r`   core_schema.TypedDictFieldc             	   C  sB   |  |||\}}tj|| sdn||jt|j|j|j|dS )zAPrepare a TypedDictField to represent a model or typeddict field.F)r  serialization_excluder   r   serialization_exclude_ifrH  )	r(  r0   typed_dict_fieldis_requiredr   _convert_to_aliasesr   r   
exclude_if)r  r  r  r   r  r   rH  r   r   r   _generate_td_field_schema  s   	z(GenerateSchema._generate_td_field_schemacore_schema.ModelFieldc              	   C  s8   |  |||\}}tj||jt|j|j|j|j|dS )z0Prepare a ModelField to represent a model field.)r  r   r   r  r   rH  )	r(  r0   model_fieldr   r  r   r   r  r   r  r  r  r   r   rH  r   r   r   r    s   z(GenerateSchema._generate_md_field_schemacore_schema.DataclassFieldc                 C  sR   |  |||\}}tj|||j|jpd|jrdnd|jt|j|j	|j
|j|dS )zJPrepare a DataclassField to represent the parameter/field, of a dataclass.NF)	r   	init_onlyr   r  r   r   r  r   rH  )r(  r0   dataclass_fieldr   r   r   r   r  r   r   r  r   r  r   r   r   _generate_dc_field_schema  s   z(GenerateSchema._generate_dc_field_schema!tuple[CoreSchema, dict[str, Any]]c                   s6  j j}}dfdd}dd t|j |D }j|  jd ur3j||| |d}n||| }W d    n1 sEw   Y  t|j	 |}	t
|	rYd	_d
d |	D   fdd|	D }	t| }t||	} s|t|}|t|j |}t\}
}i }t||
|d ||fS )Nr   r*   r   c                   s    |  j} | S r   )r  r  )r   )r  r  r   r   set_discriminator  s   z>GenerateSchema._common_field_schema.<locals>.set_discriminatorc                 S  s   g | ]}t |jj |qS r   )r   r   ro  _from_decorator)r   	decoratorr   r   r   r     s    z7GenerateSchema._common_field_schema.<locals>.<listcomp>)transform_inner_schemaTc                 S  s   g | ]
}|j jd u r|qS T)r   	each_itemr@  r   r   r   r     r   c                   s   g | ]}| vr|qS r   r   r@  )r   r   r   r     s    pydantic_js_updatespydantic_js_extrar   r*   r   r*   )
annotationrH  r   r  rS  r  r  r  _apply_annotationsr   $_validators_require_validate_defaultr   r   r   r  wrap_default_apply_field_serializersr  r   r[   )r  r  r  r   source_typer   r  validators_from_decoratorsr   this_field_validatorsr  r  core_metadatar   )r   r  r  r   r(    sD   




z#GenerateSchema._common_field_schema
union_typec           
      C  s   | j |dd}g }d}|D ]}|du s|tju rd}q|| | qt|dkr/|d }n)g }|D ]}tt|di d}	|	durM|||	f q3|| q3t	
|}|r_t	|}|S )	zGenerate schema for a Union.Tr  FNrR   r   rH  pydantic_internal_union_tag_key)r&  rW   rn  r  r'  rT  r%   rZ   r   r0   r  nullable_schema)
r  r  rQ  choicesr   argschoices_with_tagschoicetagr   r   r   r  &  s&   


zGenerateSchema._union_schemar3   c           	      C  s  | j |s\}}|d ur|W  d    S t|p|}t|}| j|> ztj|jg| j	R  }W n t
yF } zt||d }~ww t||}| |}|d dksYJ ||d< W d    n1 sgw   Y  | j |W  d    S 1 s|w   Y  d S )Nr   r  rG  )r
  r  r5   rr   r  r  rW   	eval_type	__value__r!  r  rE   r  rs   r'  r  )	r  r  rG  r1  r  r  r  r  r   r   r   r   rw  A  s(   



	$z&GenerateSchema._type_alias_type_schemaliteral_typec                 C  s\   t t|ddd}|sJ d| t|}| jjr,tdd |D r,tdd |}|S )	zGenerate schema for a Literal.Feager)
type_checkunpack_type_aliasesz(literal "expected" cannot be empty, obj=c                 s  s    | ]}t |tV  qd S r   )rn  r   r@  r   r   r   rO  Z      z1GenerateSchema._literal_schema.<locals>.<genexpr>c                 S  s   t | tr| jS | S r   )rn  r   rI  )r   r   r   r   r:  \  r  z0GenerateSchema._literal_schema.<locals>.<lambda>)rQ  r9   r0   literal_schemar  rY  anyrZ  )r  r  expectedr   r   r   r   r|  T  s   
zGenerateSchema._literal_schematyped_dict_clsc                   s  t  }j| j|\}}|dur)|W  d   W  d   S t|}|dur3|}tsBt|jdkrBt	dddzt
|d}W n tyT   d}Y nw j|q jj|jd}|j}	i }
t|  j jjrt|dd	}nd}z
tj|jd
}W n ty } zt||d}~ww g }| D ]O\}}|j|tjd}t |j!||_!||	v pd|j"v od|j"v}d|j"v r|#| |dur|j$du r||v r|| |_$t%j|| j&|| |d|
|< q|r&d'dd |D }t(|dk}t)*d|rdnd d| d|jd|rdnd d	t+ d}d}t,t-|dd}t-|dt.j/}|rAd }d}nt01|sQd!}2t ||}jj3 }d"v r|ro|d!krot)j*d#|j4d$t5d% nt01|s|d krt)j*d#|j4d&t5d% n|}t6j7|
| fd'd( j89 D ||||d)}:| j;9 }t<| j=9 d*}j>|W  d   W  d   W  d   S 1 sw   Y  W d   n1 sw   Y  W d   dS W d   dS 1 sw   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                 s      | ]}t |V  qd S r   r   )r   fr   r   r   rO        z4GenerateSchema._typed_dict_schema.<locals>.<genexpr>r;   Itemr  r    z on TypedDict class areiszk using the `ReadOnly` qualifier. Pydantic will not protect items from any mutation on dictionary instances.r  
__closed__F__extra_items__forbidr  )r  r  zTypedDict class zk is closed, but 'extra' configuration is set to `'allow'`. The 'extra' configuration value will be ignored.r  zu allows extra items, but 'extra' configuration is set to `'forbid'`. The 'extra' configuration value will be ignored.c                   r  r   r	  r  r  r   r   r     r  z5GenerateSchema._typed_dict_schema.<locals>.<listcomp>)r  r  extra_behaviorr  rG  r  all)?ru   r	  r  r
  r  rr   _SUPPORTS_TYPEDDICTr   r  rF   rg   AttributeErrorr  r  r  r   __required_keys__r`   buildupdate_from_configuse_attribute_docstringsrk   rW   get_cls_type_hintsr  r  rE   r  r   from_annotationr8   
TYPED_DICTrs   r  _qualifiersr  r   rp   r  joinrT  r   r   r  r   r   typing_extensionsNoExtraItemsr7   is_noextraitemsr'  extrar  rP   r0   typed_dict_schemar  rS  r-  r.  r)  r"  r  )r  r  r  r   typed_dict_refr1  r  r  r  required_keysr   field_docstringsr   r  readonly_fields
field_namer  r  r  fields_reprpluralr  r  	is_closedextra_itemsconfig_extra	td_schemar   r   r  r   r}  a  s   








 
Tz!GenerateSchema._typed_dict_schemanamedtuple_clsc           	        sT  j   j \}}|dur$|W  d   W  d   S t |dur.| z
tj jd}W n tyJ } zt	
||d}~ww |sTt jt}rafdd| D }tj fdd| D ddid	}tj| |d
}j|W  d   W  d   S 1 sw   Y  W d   dS 1 sw   Y  dS )z!Generate schema for a NamedTuple.Nr  c                   s   i | ]
\}}|t | qS r   rs   r   r  r  r  r   r   r     s    
z5GenerateSchema._namedtuple_schema.<locals>.<dictcomp>c              
     s0   g | ]\}}j ||tj j|tjd qS ))r  r   )_generate_parameter_schemar8   NAMED_TUPLE_field_defaultsr   r   emptyr  )r  r  r   r   r   
  s    z5GenerateSchema._namedtuple_schema.<locals>.<listcomp>'pydantic_js_prefer_positional_argumentsTrP  )rG  )r	  r  r
  r  rr   rW   r  r  r  rE   r  r   fromkeys_fieldsr   r   r0   arguments_schemacall_schemar  )	r  r  r  namedtuple_refr1  r   r  r  r   r   )r  r  r  r   r    sD   

	
	
Rz!GenerateSchema._namedtuple_schemar  	type[Any]r8   r   ro  JLiteral['positional_only', 'positional_or_keyword', 'keyword_only'] | Nonecore_schema.ArgumentsParameterc           
      C  s   t  }|tju r|j||d}n|j|||d}|jdus!J dt| j|| | j	| | j
|j|gdd}W d   n1 sCw   Y  | sQt||}tj|||t|j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 schemaF'check_unsupported_field_info_attributes)ro  r   )ru   r   r  r  from_annotated_attributer  rp   r  r  r  r  r  r  r0   arguments_parameterr  r   )
r  r  r  r  r   ro  r   r   r   parameter_schemar   r   r   r    s,   


z)GenerateSchema._generate_parameter_schemaLiteral['positional_only', 'positional_or_keyword', 'keyword_only', 'var_args', 'var_kwargs_uniform', 'var_kwargs_unpacked_typed_dict'] core_schema.ArgumentsV3Parameterc           
      C  s   t  }|tju r|j||d}n|j|||d}t| j|| | j| | j	|j
|gdd}W d   n1 s:w   Y  | sHt||}tj|||t|j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  Fr  N)r  r   ro  r   )ru   r   r  r  r  rp   r  r  r  r  r  r  r  r0   arguments_v3_parameterr  r   )
r  r  r  r  ro  r   r   r   r   r  r   r   r   _generate_parameter_v3_schemaE  s*   


z,GenerateSchema._generate_parameter_v3_schema
tuple_typec                   s   t | |}r|rtfdd|D }|s-|tv r(tjt gddS tg S |d tu rJt|dkrFtj 	|d gddS t
dt|dkr[|d d	kr[tg S t fd
d|D S )zIGenerate schema for a Tuple, e.g. `tuple[int, str]` or `tuple[int, ...]`.c                 3  s    | ]}t | V  qd S r   r  r   paramr  r   r   rO  ~  r  z/GenerateSchema._tuple_schema.<locals>.<genexpr>r   )r   r   r;   z&Variable tuples can only have one typerR   r   c                   s   g | ]}  |qS r   )r'  r  r  r   r   r     rA  z0GenerateSchema._tuple_schema.<locals>.<listcomp>)rr   r&  r   r   r0   tuple_schemar   EllipsisrT  r'  
ValueError)r  r  paramsr   )r  r  r   rq  w  s   


zGenerateSchema._tuple_schemac                 C  s   t jt tdddS )Nis_typezInput should be a typer  )r0   custom_error_schemar[  r   r  r   r   r   rx    s
   zGenerateSchema._type_schemac                 C  s.   ddl m} ddd gi}tj|t |dS )z/Generate schema for a zone_info.ZoneInfo objectrR   )validate_str_is_valid_iana_tzrD  c                 S  r  )Nrx  zoneinfory  r   r{  r   r   r   r:    r  z1GenerateSchema._zoneinfo_schema.<locals>.<lambda>r   rH  )r  r  r0   r  r  )r  r  rH  r   r   r   r    s   zGenerateSchema._zoneinfo_schemac                   s&    j |dd}t fdd|D S )z*Generate schema for `type[Union[X, ...]]`.Tr  c                      g | ]	}  t| qS r   r'  r   )r   rQ  r  r   r   r         z<GenerateSchema._union_is_subclass_schema.<locals>.<listcomp>)r&  r0   r  )r  r  rQ  r   r  r   _union_is_subclass_schema  s   z(GenerateSchema._union_is_subclass_schematype_c                   s0    |}t|p|}t|r  S t|r" t|j	 S t
|rQ|jr=tt|jr7 |jS t|jS |jrMt fdd|jD S   S tt|r\ |S t|rf |}t|r}td|dtt| dddt|s|du rttjS td|t|S )	z-Generate schema for a type, e.g. `type[int]`.c                   r   r   r!  )r   cr  r   r   r     r"  z3GenerateSchema._subclass_schema.<locals>.<listcomp>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 )rR  rW   annotated_typer7   r  rx  rv  r'  r   r  
is_typevar	__bound__r:   r5   r#  r0   is_subclass_schema__constraints__r  rW  r8  is_generic_aliasrF   rV   display_as_typerT  r  rn  r   )r  r$  
type_paramr   r  r   r    s@   









zGenerateSchema._subclass_schemac           	      C  s   ddl m} | |}t|}t|}tjtjdd}t	
|s2ddlm} t|t||g}tj||dd}tj|||dS )	z5Generate schema for a Sequence, e.g. `Sequence[int]`.rR   r  Sequencer  )sequence_validatorTr  )r?  rt  r   )r  r  r'  r0   r&  r}   r[  r  r.  r7   r  r  r/  r  r  r  r  )	r  r$  r  r  r&  r?  rt  r/  r   r   r   r   rr    s    


zGenerateSchema._sequence_schemacore_schema.GeneratorSchemac                 C  s   |  |}t| |S )z$Generate a schema for an `Iterable`.)rR  r0   generator_schemar'  )r  r$  	item_typer   r   r   rs    s   
zGenerateSchema._iterable_schemapattern_typec                 C  s   ddl m} ddd gi}tjtddt d}|tju s#|tju r,tj	|j
||d	S | j|d
dd }|tu rBtj	|j||d	S |tu rOtj	|j||d	S td|d)NrR   )r  rD  c                 S  r  )Nrx  regexry  r   r{  r   r   r   r:    r  z0GenerateSchema._pattern_schema.<locals>.<lambda>patternr   )r   return_schemar  Tr  r   r  r   )r   r  r0   r   r   r  r  Patternrer  pattern_either_validatorr&  r   pattern_str_validatorr  pattern_bytes_validatorrD   )r  r3  r  rH  serr  r   r   r   r    s0   zGenerateSchema._pattern_schemac                 C  s<   t jt jt t  t tjjgt tjjddddS )Nrs  r  zInput should be hashable)r   r  r  )	r0   r  r  r  r   r[  r  abcHashabler  r   r   r   r    s   zGenerateSchema._hashable_schema	dataclasstype[StandardDataclass]type[StandardDataclass] | Nonec                   s  j | j|\}}|dur&|W  d   W  d   S |jd}|durkt|tsk|d dkrAj|}t	|}|r[j
|W  d   W  d   S |W  d   W  d   S t|}|duru|}t|dd}ddlm}	 j|2 j| |	|r| rdd	 |j D }
|r|
 D ]}|j|gjR   qn)zt|jj|pi d
}
W n ty } zt||d}~ww t||jd}
jjdkr|
 D ]\}}|jdu rtd| dddq|jd  du rt !|  "j t# fdd|
 D dd d}t$|d}t$|d}t%j&|j'| fdd j( D |d}t)| j* } j+ }t,||d}jj-|j'd}t%j.|||||dd t/|D ||jj0j1d 	}2| j3 }t,||d!}j
|W  d   W  d   W  d   W  d   S 1 sw   Y  W d   n	1 sw   Y  W d   n1 sw   Y  W d   dS W d   dS 1 sw   Y  dS )"z Generate schema for a dataclass.Nr  r   r  r  r;   )is_pydantic_dataclassc                 S  s   i | ]	\}}|t |qS r   r   )r   f_namer  r   r   r   r   B  s    z4GenerateSchema._dataclass_schema.<locals>.<dictcomp>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  s"    | ]\}} || V  qd S r   )r  r   r  r   r   rO  j  s     z3GenerateSchema._dataclass_schema.<locals>.<genexpr>c                 S  s   |  dduS )Nr   F)r   )rN  r   r   r   r:  k  r  z2GenerateSchema._dataclass_schema.<locals>.<lambda>)key__post_init__	__slots__c                   r  r   r	  r  r  r   r   r   s  r  z4GenerateSchema._dataclass_schema.<locals>.<listcomp>)r  collect_init_onlyr  r  c                 S  s   g | ]}|j qS r   )r  )r   r   r   r   r   r     s    )r  r  rG  r   slotsr  r   r  )4r	  r  r
  r  r  r   rn  rv   r  r\   r  rr   r   r  rB  r  r  r  r  r   rS  apply_typevars_mapr!  rm   r  r  rE   r  rl   r  r   rF   r`   r  r  sortedhasattrr0   dataclass_args_schemar   r  r   r,  r"  r)  r  dataclass_schemar   r  r   r-  r.  )r  r?  r  dataclass_refr1  r   rG  r  r  rB  r   r   r  r  rQ  has_post_init	has_slotsargs_schemar   r"  r  	dc_schemar   r  r   r    s   



 









2Tz GenerateSchema._dataclass_schemafunctionValidateCallSupportedTypescore_schema.CallSchemac           
      C  sn   |  |}d}| j}|jr/t|}|j}||jur/| j\}}tj|||dhd}	| 	|	d }t
j|||dS )zsGenerate schema for a Callable.

        TODO support functional validators once we support them in Config
        Nr   )globalnslocalnsinclude_keys)r6  )_arguments_schemar  validate_returnr   return_annotationr  r!  rW   get_function_type_hintsr'  r0   r  )
r  rS  r  r6  r  sigreturn_hintrV  rW  
type_hintsr   r   r   r    s"   



zGenerateSchema._call_schemaparameters_callbackParametersCallback | Nonecore_schema.ArgumentsSchemac                 C  s  t jdt jdt jdi}t|}| j\}}tj|||d}g }d}	d}
d}t|j	
 D ]\}\}}|j|ju r>ttt}n|| }|durQ||||}|dkrQq+||j}|durl| ||tj|j|}|| q+|jt jkrx| |}	q+|jt jksJ |jt|}|durt|p|}t|std|dd	d
d |j	
 D }||j}|rtd|j dt!|dkrdnd dd"dd t#|D  dd	d}| $|t|}
q+d}| |}
q+t%j&||	||
| j'j(dS )z Generate schema for a Signature.positional_onlypositional_or_keywordkeyword_onlyrV  rW  Nskip7Expected a `TypedDict` class inside `Unpack[...]`, got unpack-typed-dictr   c                 S      h | ]\}}|j tjkr|qS r   kindr   POSITIONAL_ONLYr   r  pr   r   r   	<setcomp>      z3GenerateSchema._arguments_schema.<locals>.<setcomp>Typed dictionary  overlaps with parameterr;   r  r   r  r  c                 s  r  r   r  r   ro  r   r   r   rO    r  z3GenerateSchema._arguments_schema.<locals>.<genexpr>overlapping-unpack-typed-dictzunpacked-typed-dictuniform)var_args_schemavar_kwargs_modevar_kwargs_schemavalidate_by_name))r   rm  POSITIONAL_OR_KEYWORDKEYWORD_ONLYr   r!  rW   r\  	enumerate
parametersr   r  r  r  r%   r   r   rl  r  r8   FUNCTIONr   r  VAR_POSITIONALr'  VAR_KEYWORDunpack_typer5   r6   rF   intersectionr  r   rT  r  rJ  r}  r0   r  r  rz  )r  rS  r`  mode_lookupr]  rV  rW  r_  arguments_listrw  ry  rx  ir  ro  r  resultparameter_mode
arg_schemar  r  non_pos_only_param_namesoverlapping_paramsr   r   r   rY    sx   


z GenerateSchema._arguments_schemacore_schema.ArgumentsV3Schemac                 C  s  t jdt jdt jdt jdi}t|}| j\}}tj|||d}g }t	|j
 D ]\}	\}
}|d ur>||	|
|j}|dkr>q(|jt ju rKttt}n||
 }||j}|d u r|jt jksdJ |jt|}|d urt|pr|}t|std|dd	d
d |j
 D }||j}|rtd|jdt|dkrdnd dddd t|D  dd	d}|}nd}|| j|
|t j!||j"d q(t#j$|| j%j&dS )Nrc  rd  var_argsre  rf  rg  rh  ri  r   c                 S  rj  r   rk  rn  r   r   r   rp    rq  z6GenerateSchema._arguments_v3_schema.<locals>.<setcomp>rr  rs  r;   r  r   r  r  c                 s  r  r   r  rt  r   r   r   rO  '  r  z6GenerateSchema._arguments_v3_schema.<locals>.<genexpr>ru  var_kwargs_unpacked_typed_dictvar_kwargs_uniform)r   )rz  )'r   rm  r{  r  r|  r   r!  rW   r\  r}  r~  r   r  r  r  r%   r   r   rl  r  r  r5   r6   rF   r  r  r   rT  r  rJ  r  r  r8   r  r   r0   arguments_v3_schemar  rz  )r  rS  r`  r  r]  rV  rW  r_  parameters_listr  r  ro  r  r  r  r  r  r  r  r   r   r   _arguments_v3_schema  sl   	


z#GenerateSchema._arguments_v3_schematypevartyping.TypeVarc                 C  sx   z|  }W n	 ty   Y n	w |r| |jS |j }r%| tj| S |j }r8| |}t	
d|d< |S t	 S )Nr  r   )has_defaultr  r'  __default__r*  r  r  r$   r(  r0   rW  r   )r  r  r  constraintsr   r   r   r   r   r  :  s   


z,GenerateSchema._unsubstituted_typevar_schemar  Decorator[ComputedFieldInfo]r  2dict[str, Decorator[FieldSerializerDecoratorInfo]]core_schema.ComputedFieldc           	   
   C  s   |j jtur|j j}nztj|j| jjd}W n ty) } zt	
||d }~ww |tu r4tdddt|| j}tj|j |d|_ | |}| |t| |j}t|j \}}i }t|ddi|rf|ni |d tj|j||j j|d	S )
NrW  zComputed field is missing return type annotation or specifying `return_type` to the `@computed_field` decorator (e.g. `@computed_field(return_type=int | str)`)zmodel-field-missing-annotationr   )return_typereadOnlyTr  )r6  r   rH  )r   r  r.   rS   get_callable_return_typefuncr!  localsr  rE   r  rF   rs   r  r  replacer'  r  r   rS  r   r   r[   r0   computed_fieldr   )	r  r  r  r  r  return_type_schemar  r  r  r   r   r   r
  N  s<   

z%GenerateSchema._computed_field_schemar&  c                 C  sF   t  }| j|dd^}}| ||}|D ]}t||r t||}q|S )zdGenerate schema for an Annotated type, e.g. `Annotated[int, Field(...)]` or `Annotated[int, Gt(0)]`.Tr  )ru   r&  r  rn  r  )r  r&  r   r  r   r   r  r   r   r   rY  z  s   


z GenerateSchema._annotated_schemac                 C  r7  r   r   r8  r   r   r   r:    r;  zGenerateSchema.<lambda>r  r   	list[Any]r  "Callable[[CoreSchema], CoreSchema]r  c                   s   t t|}g }d fdd}t| }|D ]}|du r q j||||d}q|}	|r<|	d	i }
t|
|d
 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                   sV     | }|d u r | }t| }|d ur't| j}|d ur' || |S r   )r  r  r  r  r
  r  )r  r   r  r  r  r  r  r   r   inner_handler  s   
z8GenerateSchema._apply_annotations.<locals>.inner_handlerNr  rH  ) pydantic_js_annotation_functionsr  r   r   r*   )
rQ  rU   expand_grouped_metadatar{   _get_wrapped_inner_schemar  r[   r   r  r   )r  r  r   r  r  r  r  get_inner_schemar  r   r  r   r  r   r    s$   
z!GenerateSchema._apply_annotationsrH  c              	   C  s  t  }t||r\|rBt||u rB| | }D ]\}}tjd|d|d|dtd q|jrB| j	 d u rBd|vrBtjdtd |j
D ]}| ||}qE|jd urZ| ||j}|S |d d	krx|	d
t }	| |	|}	|	rv|	|d
< |S |}
|	d}|d ur| }|dt|  }| j| }d ur|S ||d< n1|d dkr|d }| j| }d ur| }|dt|  }| j| }d ur|S ||d< t||}|d ur|S |
S )NzThe z attribute with value zY was provided to the `Field()` function, which has no effect in the context it was used. a   is field-specific metadata, and can only be attached to a model field using `Annotated` metadata or by assignment. This may have happened because an `Annotated` type alias using the `type` statement was used, or if the `Field()` function was attached to a single member of a union type.r  defaut_factoryzA 'default_factory' taking validated data as an argument was provided to the `Field()` function, but no validated data is available in the context it was used.r   r   r   rG  rK  definition-refrV  )ru   rn  r   &_get_unsupported_field_info_attributesr   r   rQ   $default_factory_takes_validated_datar	  r   rH  _apply_single_annotationr  r  r0   r   r	   r   r
  get_schema_from_refrU   apply_known_metadata)r  r   rH  r  r   unsupported_attributesattrrI  field_metadatar  r@  rG  new_refexistingreferenced_schemamaybe_updated_schemar   r   r   r    sf   





z'GenerateSchema._apply_single_annotationc                 C  sR   t  }t||r'|jD ]}| ||}qt|\}}|di }t|||d |S )NrH  r  )ru   rn  rH  $_apply_single_annotation_json_schemar   r  r[   )r  r   rH  r   r  r  r  r  r   r   r   r  	  s   

z3GenerateSchema._apply_single_annotation_json_schemar   c                 C  s^   g }t D ](\}}t|| }|ur,|dvs| j dur,|dvs%d|jvr,|||f q|S )zoGet the list of unsupported `FieldInfo` attributes when not directly used in `Annotated` for field annotations.)r   r   N)r   r   r   )r   r   r	  r   _attributes_setr  )r  r  unused_metadataunused_metadata_nameunset_valueunused_metadata_valuer   r   r   r  	  s   
z5GenerateSchema._get_unsupported_field_info_attributesr  r>   r  list[GetJsonSchemaFunction]r{   c                   s.   t  dd d fdd}t|S )	Nr:  r  r   r   r   c                   sV   d ur
| }n| }j | d}| }t }|d ur)| |S )Nr  )r  r  r  r  )r  r   r  r  annotation_get_schemar  r  r  r  r   r   new_handler2	  s   
z=GenerateSchema._get_wrapped_inner_schema.<locals>.new_handler)r  r   r   r   )r   r{   )r  r  r  r  r  r  r   r  r   r  )	  s   
z(GenerateSchema._get_wrapped_inner_schemaserializers-list[Decorator[FieldSerializerDecoratorInfo]]c           
   
   C  s0  |rt |}|d dkr|d }| |||d< |S d|v r$| j|}|d }t|j|jj\}}|jjt	ur=|jj}nzt
j|j| jjd}W n ty[ } zt||d}~ww |t	u rcd}	n| |}	|jjdkrtj|j|||	|jjd	|d
< |S |jjdksJ tj|j|||	|jjd	|d
< |S )z$Apply field serializers to a schema.r   r  r   rG  r   r  Nr   )is_field_serializerrw  r6  r   r   r   )r	   r  r
  r  rh   r  r   ro  r  r.   rS   r  r!  r  r  rE   r  r'  r0   r  r   r   )
r  r   r  r   
serializerr  rw  r  r  r6  r   r   r   r  E	  sR   





z'GenerateSchema._apply_field_serializers1Iterable[Decorator[ModelSerializerDecoratorInfo]]c           
   
   C  s   | dd}|rot|d }t|j|jj}|jjtur!|jj}nztj	|j| j
jd}W n ty? } zt||d}~ww |tu rGd}n| |}|jjdkr_tj|j|||jjd}	ntj|j|||jjd}	|	|d< |ru||d< |S )z$Apply model serializers to a schema.rG  Nr   r  r   )rw  r6  r   r   )poprQ  ri   r  r   ro  r  r.   rS   r  r!  r  r  rE   r  r'  r0   r  r   r   )
r  r   r  rG  r  rw  r  r  r6  
ser_schemar   r   r   r-  }	  sD   



z'GenerateSchema._apply_model_serializers)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*   )r3  r4  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   r9  )r  r   r  rH  r   rI  )r  r   r   rL  )F)r  r   r  r   r   rL  )r  r   r   rS  )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  r3   r   r*   )r  r   r   r*   )r  r   r  r   r   r   )r  r   r  r   r   r   )r  r   r  r  r  r8   r   r   ro  r	  r   r
  )r  r   r  r   r  r8   ro  r  r   r   r   r  )r  r   r   r   )r   r   )r$  r   r   r   )r$  r   r   r   )r$  r   r   r0  )r3  r   r   r   )r?  r@  r  rA  r   r   )rS  rT  r   rU  r   )rS  rT  r`  ra  r   rb  )rS  rT  r`  ra  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   rH  r   r  r   r   r   )r   r   rH  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   )Kr   r  r  r  rF  r  r  propertyr  r!  r#  r)  r.  r0  r2  r^  r  r  r  r  r  r  r  r  r  r  r'  r7  r8  r  rG  r&   r&  rR  rU  r  r\  r  r  r  r  r(  r  rw  r|  r}  r  r   r  r  r  rq  rx  r  r#  r  rr  rs  r  r  r  r  rY  r  r  r
  rY  r  r  r  r  r  r  r-  __classcell__r   r   r  r   r  O  s    





H
!
:

.



' ;	x99 1:2'zLD,4J8r  c                 C     t | |S r   )r0   !no_info_before_validator_functionr  r   r   r   r   r:  	      r:  c                 C  r  r   )r0   rZ  r  r   r   r   r:  	  r  c                 C  
   t | S r   )r0   r  r  rK  r   r   r   r:  	  r  c                 C  r  r   )r0   r  r  r   r   r   r:  	  r  c                 C  r  r   )r0   #with_info_before_validator_functionr  r   r   r   r:  	  r  c                 C  r  r   )r0   "with_info_after_validator_functionr  r   r   r   r:  	  r  c                 C  r  r   r>  r  r   r   r   r:  	  r  c                 C  r  r   )r0   !with_info_wrap_validator_functionr  r   r   r   r:  	  r  ))r   no-info)r   r  )r   r  )r   r  )r   	with-info)r   r  )r   r  )r   r  zMapping[tuple[FieldValidatorModes, Literal['no-info', 'with-info']], Callable[[Callable[..., Any], core_schema.CoreSchema], core_schema.CoreSchema]]_VALIDATOR_F_MATCHr   Iterable[Decorator[RootValidatorDecoratorInfo]] | Iterable[Decorator[ValidatorDecoratorInfo]] | Iterable[Decorator[FieldValidatorDecoratorInfo]]c                 C  sF   |D ]}t |j|jjdd}|rdnd}t|jj|f |j| } q| 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   ro  r   r  r  )rj   r  r   ro  r  )r   r   	validatorrw  val_typer   r   r   r   	  s
   r   +Iterable[Decorator[ValidatorDecoratorInfo]]c                 C  s   | D ]	}|j jr dS q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   ru  )r   r  r   r   r   r  	  s
   
r  r   %str | AliasChoices | AliasPath | None4str | list[str | int] | list[list[str | int]] | Nonec                 C  s   t | ttfr|  S | S r   )rn  r<   r=   convert_to_aliases)r   r   r   r   r  	  s   r  0Iterable[Decorator[ModelValidatorDecoratorInfo]]ro   Literal['inner', 'outer', 'all']c                 C  s  |  dd}|D ]q}|dkr|jjdkrq|dkr |jjdkr qt|j|jjdd}|jjdkrD|r;tj|j| d	} qtj|j| d	} q|jjdkr^|rUtj|j| d	} qtj	|j| d	} q|jjd
ksfJ |rqtj
|j| d	} qtj|j| d	} q|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.
    rG  Nr  r   r  modelr  r   )rS  r   r   )r  r   ro  rj   r  r0   r  r  r  r  r  rZ  )r   r   ro  rG  r  rw  r   r   r   r)  	  s,   r)  r  r   c                 C  sD   | j rtj|| j t| j | jdS | jtur tj|| j| jd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`.
    )r   default_factory_takes_datar   )r   r   )r   r0   with_default_schemaro   r   r   r.   )r  r   r   r   r   r   
  s   


r  GetJsonSchemaFunction | Nonec                 C  s   t | dd}t| dr8t }|duo|jj|t |ddfv}|s8t | dd}td|r0d| dnd	 d
ddt|  }durDt|S |du rJdS |S )z`Extract `__get_pydantic_json_schema__` from a type, handling the deprecated `__modify_schema__`.__get_pydantic_json_schema__N__modify_schema__rC  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   rK  rt   r  rC  rF   r5   r  )r   js_modify_functionr   has_custom_v2_modify_js_funccls_namer  r   r   r   r  9
  s*   
r  r  r  CoreSchema | Nonec                 C  s2   | d dkr| | d S | d dkr| d S | S )Nr   r  rV  r  r   )r  r   r  r   r   r   r  Y
  s
   r  def_ref%core_schema.DefinitionReferenceSchema.Literal['inline', 'keep', 'preserve_metadata']c                 C  s:   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   keeprH  inlinerR   %pydantic_internal_union_discriminatorpreserve_metadata)r   rT  )r  rH  r   r   r   _inlining_behaviorb
  s   

r  c                   @  sp   e Zd ZU dZded< 	 ded< 	 d#dd	Zed$ddZd%ddZd&ddZ	d'ddZ
d(ddZd)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                 C  s   t  | _i | _d S r   )r   r  r  r  r   r   r   r  
  s   
z_Definitions.__init__r   r   CGenerator[tuple[str, core_schema.DefinitionReferenceSchema | None]]c             	   c  sj    t |}|| jv s|| jv r|t|fV  dS | j| z|dfV  W | j| dS | j| 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]   r  r  r0   rZ  adddiscard)r  r   rG  r   r   r   r  
  s   z_Definitions.get_schema_or_refrG  r   r  c                 C  r  )z,Resolve the schema from the given reference.)r  r   )r  rG  r   r   r   r  
  s   z _Definitions.get_schema_from_refr   r*   r  c                 C  s   |d }|| j |< t|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.
        rG  )r  r0   rZ  )r  r   rG  r   r   r   r  
  s   

z/_Definitions.create_definition_reference_schemacore_schema.DefinitionsSchemac                 C  s$   |d D ]	}|| j |d < q|d S )zZStore the definitions of the `'definitions'` core schema and return the inner core schema.r  rG  r   )r  )r  r   
def_schemar   r   r   r  
  s   z_Definitions.unpack_definitionsc              
   C  s<  | j }zt||d}W n ty } zt|d}~ww i }|d  D ]E\}}|dur`t| }dkr`|dkrE|  || || q#|dkr_|	d}	|  || || |	|d< q#| ||||< q#|d D ]!}
|
d 	d	d}|du r|qmt
|
 ||}|
  |
| qm|rtj|g | d
}|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_referencesr  r  r  rH  deferred_discriminator_schemasr  r  )r  rz   ry   r   r   r  clearr>  _resolve_definitionr  rT   r  r	   r0   definitions_schemarS  )r  r   r  gather_resultr  remaining_defsrG  inlinable_def_refinlining_behaviormetacsr  appliedr   r   r   r  
  sB   

z_Definitions.finalize_schemar  dict[str, CoreSchema]c                 C  s   || }|d dkr|S t  }|d dkrAt|dkrA|d }||v r,t| ddd|| || }|d dkrAt|dksi |d|iS )	Nr   r  r  rV  z) contains a circular reference to itself.zcircular-reference-schemar   rG  )r   r  rF   r  )r  rG  r  
definitionvisitedrV  r   r   r   r  
  s   

z _Definitions._resolve_definitionNr  )r   r   r   r  )rG  r   r   r  )r   r*   r   r  )r   r  r   r*   r  )rG  r   r  r  r   r*   )r   r  r  r  r  r  r   r  r  r  r  r  r  r   r   r   r   r  v
  s   
 	

 

	
:c                   @  2   e Zd ZdZdddZedd	d
ZdddZdS )r  _stackr   r   c                 C  
   g | _ d S r   r  r  r   r   r   r       
z_FieldNameStack.__init__r  r   Iterator[None]c                 c  "    | j | d V  | j   d S r   r  r  r  )r  r  r   r   r   r       z_FieldNameStack.push
str | Nonec                 C     | j r| j d S d S Nr   r  r  r   r   r   r        
z_FieldNameStack.getNr  )r  r   r   r  )r   r  r   r  r  rF  r  r   r  r   r   r   r   r   r        
r  c                   @  r  )r  r  r   r   c                 C  r  r   r  r  r   r   r   r  &  r  z_ModelTypeStack.__init__type_objr   r  c                 c  r  r   r  )r  r  r   r   r   r  )  r  z_ModelTypeStack.pushtype | Nonec                 C  r  r  r  r  r   r   r   r   /  r  z_ModelTypeStack.getNr  )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   r  r   r  )r   r   r   r  ro  r  r   r   )r  r   r   r   r   r   )r   r   r   r  )r   r*   r  r  r   r  )r  r  r   r  (  r  
__future__r   _annotationscollections.abcr  r  rb  rT  r  r  r8  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  r(   r  pydantic_corer)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   typing_inspectionr7   typing_inspection.introspectionr8   r9   r:   aliasesr<   r=   annotated_handlersr>   r?   r  r@   rA   rB   rC   errorsrD   rE   rF   functional_validatorsrG   rH   rI   rJ   rK   r?  rL   versionrM   rN   rO   rP   rQ   r   rS   rT   rU   rV   rW   _configrX   rY   _core_metadatarZ   r[   _core_utilsr\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   _docs_extractionrk   r  rl   rm   rn   ro   rp   _forward_refrq   	_genericsrr   rs   _import_utilsrt   ru   _mock_val_serrv   _namespace_utilsrw   rx   _schema_gatherry   rz   _schema_generation_sharedr{   _utilsr|   r}   r   r~   r   mainr   r   _dataclassesr   r   version_infor  r   r   AnyFieldDecoratorr   r  r   r   Tupler   r   ListrQ  r=  MutableSequencer   Setr   
MutableSetr   	FrozenSet	frozensetr   Dictr   r   r   r.  r   r   Typer   r   r7  r   r  Pathr  	PosixPathPurePosixPathPureWindowsPathr   MutableMappingOrderedDictDefaultDictr  rt  Counterru  r  r  r   rT  r  r   r   r   r   r   r   r   JsonEncodersr   	Exceptionr   r  r  r   r  r  r)  r  r  r  r  r  r  r  r   r   r   r   <module>   sZ    0,8
 	






#
"                r




	
/

 
	 