o
    niE{                     @  sf  d Z ddlmZ ddlZddlZddlmZ ddlm	Z	 ddl
mZmZ ddlmZ ddlmZmZmZmZmZ dd	lmZ d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# ddl$m%Z% ddl&m'Z' ddl(m)Z)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3 erddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z< ddl=m>Z> G dd de0Z?ej@dzi e,G d d! d!ZAd{d&d'ZBe	d|d)d*ZCd}d3d4ZDd~dd<d=ZEddCdDZFddGdHZGddKdLZHh dMZIh dNZJddOddVdWZKddZd[ZLdd]d^ZMddd_ddcddZNddfdgZOddidjZPddkdlZQddpdqZRdd5drddxdyZSdS )zmPrivate logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`.    )annotationsN)Mapping)cache)	Parameterismethoddescriptor)Pattern)TYPE_CHECKINGAnyCallableTypeVarcast)PydanticUndefined)TypeIs)AnnotationSource)PydanticDeprecatedSince211)PydanticUserError   )AliasGenerator   )	_generics_typing_extra)ConfigWrapper)extract_docstrings_from_cls)import_cached_base_modelimport_cached_field_info)
slots_true)
NsResolver)Representation)can_be_positionalget_first_not_noneBaseMetadata)	FieldInfo)	BaseModel)PydanticDataclassStandardDataclass)DecoratorInfosc                   @  s   e Zd ZdZdZdS )PydanticMetadataz0Base class for annotation markers like `Strict`. N)__name__
__module____qualname____doc__	__slots__r(   r(   r(   Z/var/www/html/arapca_proje/venv/lib/python3.10/site-packages/pydantic/_internal/_fields.pyr'   '   s    r'   c                   @  s   e Zd ZU ded< ded< dS )PydanticExtraInfor	   
annotationboolcompleteN)r)   r*   r+   __annotations__r(   r(   r(   r.   r/   -   s   
 r/   metadatar	   returnr!   c                  K  s
   t  | S )zCreate a new `_PydanticGeneralMetadata` class with the given metadata.

    Args:
        **metadata: The metadata to add.

    Returns:
        The new `_PydanticGeneralMetadata` class.
    )_general_metadata_cls)r4   r(   r(   r.   pydantic_general_metadata4   s   
	r7   type[BaseMetadata]c                  C  s"   ddl m}  G dd dt| }|S )zCDo it this way to avoid importing `annotated_types` at import time.r   r    c                   @  s   e Zd ZdZdddZdS )z7_general_metadata_cls.<locals>._PydanticGeneralMetadataz,Pydantic general metadata like `max_digits`.r4   r	   c                 S  s
   || _ d S N)__dict__)selfr4   r(   r(   r.   __init__H   s   
z@_general_metadata_cls.<locals>._PydanticGeneralMetadata.__init__N)r4   r	   )r)   r*   r+   r,   r<   r(   r(   r(   r.   _PydanticGeneralMetadataE   s    r=   )annotated_typesr!   r'   )r!   r=   r(   r(   r.   r6   @   s   r6   protected_namespacestuple[str | Pattern[str], ...]ann_namestrbasestuple[type[Any], ...]cls_nameNonec                 C  s<  t  }| D ]}d}t|tr||d u}n
t|tr ||}|r|D ]%}t||rIt||r8|t|di v sIt	d|dt|| d|dq$g }| D ]%}	t|	tre|	|sd|
d|	jd qN||	ss|
d	|	 d	 qNd
d| t|dkrdnd }
tjd|d|d|d|
 d	tdd qd S )NF__pydantic_fields__Field z conflicts with member z of protected namespace .zre.compile()'(z, r   z,)z in z$ conflicts with protected namespace zX.

You may be able to solve this by setting the 'protected_namespaces' configuration to    
stacklevel)r   
isinstancer   matchrB   
startswithhasattr
issubclassgetattr
ValueErrorappendpatternjoinlenwarningswarnUserWarning)r?   rA   rC   rE   r#   protected_namespacens_violationbvalid_namespacespnvalid_namespaces_strr(   r(   r.   _check_protected_namespacesN   sH   






$rd   Fcls	type[Any]fieldsdict[str, FieldInfo]use_inspectr1   c                 C  s>   t | |d}| D ]\}}|jd u r||v r|| |_q
d S )Nri   )r   itemsdescription)re   rg   ri   fields_docsrA   
field_infor(   r(   r.   _update_fields_from_docstringsy   s   
ro   title_generatorCallable[[str, FieldInfo], str]
field_namern   r"   c                 C  sB   |j d u r| ||}t|tstd|  d|j ||_ d S d S )Nzfield_title_generator  must return str, not )titlerP   rB   	TypeError	__class__)rp   rr   rn   rt   r(   r(   r.   *_apply_field_title_generator_to_field_info   s   



rw   alias_generator%Callable[[str], str] | AliasGeneratorc                 C  s  |j du s|j dks|jdu s|jdu s|jdu rd\}}}t| tr,| |\}}}nt| rD| |}t|tsDt	d|  d|j
 |j du sN|j dkrQd|_ |j dkret|||_t|||_||_|jdu rm||_|jdu rxt|||_|jdu rt|||_dS dS dS )av  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_name: The name of the field from which to generate the alias.
        field_info: The `FieldInfo` instance to which the alias generator is (maybe) applied.
    Nr   )NNNzalias_generator rs   )alias_priorityaliasvalidation_aliasserialization_aliasrP   r   generate_aliasescallablerB   ru   rv   r   )rx   rr   rn   r{   r|   r}   r(   r(   r.   $_apply_alias_generator_to_field_info   s4   











r   config_wrapperr   c                 C  s@   |j p| j }|durt||| | jdurt| j|| dS dS )ap  Update the `FieldInfo` instance from the configuration set on the model it belongs to.

    This will apply the title and alias generators from the configuration.

    Args:
        config_wrapper: The configuration from the model.
        field_name: The field name the `FieldInfo` instance is attached to.
        field_info: The `FieldInfo` instance to update.
    N)field_title_generatorrw   rx   r   )r   rr   rn   r   r(   r(   r.   update_field_from_config   s   

r   >   copydictjson_iter_calculate_keys_copy_and_set_values>
   schemafrom_ormvalidate	construct	parse_obj	parse_raw
_get_value
parse_fileschema_jsonupdate_forward_refs)typevars_maptype[BaseModel]ns_resolverr   r   Mapping[TypeVar, Any] | None?tuple[dict[str, FieldInfo], PydanticExtraInfo | None, set[str]]c             
     sr  t  }t  | j}i }t|D ]}t|dd }r|| qtj| |d}	t| }
i }t	 }|	
 D ]b\}\}}|dkr@q4t|j||| jd t|rU|| q4t| |ttur~t fddtD s|tdr~t fd	dtD r~tt|sq4| jr|d
krtd|d|D ]D}t||r||
vrqt| di d}||u rqdd t|rt|ndD }||v rqtjd| d| j d|j dtdd qtu r||
v s||vr|j |t!j"d}||_#|sd|_$n{|| % }|r	t&|||dd}ni|}nft'|r't(j)r'j)*d| }|_)|j+d< |j,|t!j"d}|_-||_#|s=d|_$n#d|j.v r`|/ s`tjd|d|d |d!t0dd" || q4zt1| | W n
 t2yq   Y nw | j3d# }||j4v rt5d$|d%| jd&|||< |j$rt6||| q4|j7rt8| | d}d'|	v r|	d' \}}t9||d(}|||fS ))a  Collect the fields and class variables names of a nascent Pydantic model.

    The fields collection process is *lenient*, meaning it won't error if string annotations
    fail to evaluate. If this happens, the original annotation (and assigned value, if any)
    is stored on the created `FieldInfo` instance.

    The `rebuild_model_fields()` should be called at a later point (e.g. when rebuilding the model),
    and will make use of these stored attributes.

    Args:
        cls: BaseModel or dataclass.
        config_wrapper: The config wrapper instance.
        ns_resolver: Namespace resolver to use when getting model annotations.
        typevars_map: A dictionary mapping type variables to their concrete types.

    Returns:
        A three-tuple containing the model fields, the `PydanticExtraInfo` instance if the `__pydantic_extra__` annotation is set,
        and class variables names.

    Raises:
        NameError:
            - If there is a conflict between a field name and protected namespaces.
            - If there is a field other than `root` in `RootModel`.
            - If a field shadows an attribute in the parent model.
    rG   N)r   model_config)r?   rA   rC   rE   c                 3  s     | ]}t  |d u V  qd S r9   )rU   .0	depr_name
BaseModel_assigned_valuer(   r.   	<genexpr>&  s    z'collect_model_fields.<locals>.<genexpr>__func__c                 3  s*    | ]}t t  |d dd ju V  qd S )Nr   )rU   r   r   r   r(   r.   r   *  s
    
rootzUnexpected field with name z4; only 'root' is allowed as a field of a `RootModel`__pydantic_generic_metadata__originc                 S  s   h | ]}|j qS r(   name)r   fieldr(   r(   r.   	<setcomp>G  s    z'collect_model_fields.<locals>.<setcomp>r(   zField name "z" in "z"" shadows an attribute in parent ""   rN   _sourceFTr   r   lenientdefaultfinalzAnnotation z= is marked as final and has a default value. Pydantic treats zz as a class variable, but it will be considered as a normal field in V3 to be aligned with dataclasses. If you still want zV to be considered as a class variable, annotate it as: `ClassVar[<type>] = <default>.`)categoryrO   __pydantic_decorators__rH   z
 of class zf overrides symbol of same name in a parent class. This override with a computed_field is incompatible.__pydantic_extra__r0   r2   ):r   r   	__bases__reversedrU   updater   get_model_type_hintssafe_get_annotationssetrk   rd   r?   r)   is_classvar_annotationaddr   any_deprecated_method_namesrS   _deprecated_classmethod_namesis_valid_field_name__pydantic_root_model__	NameErrorgetdataclassesis_dataclassrg   r[   r\   r+   r]   from_annotationr   CLASS_original_annotation	_complete_copy_recreate_field_inforP   r   r   __get___attributes_setfrom_annotated_attribute_original_assignment_qualifiersis_requiredr   delattrAttributeErrorr:   computed_fieldsru   r   use_attribute_docstringsro   r/   )re   r   r   r   
FieldInfo_rC   parent_fields_lookupbasemodel_fields
type_hintscls_annotationsrg   
class_varsrA   ann_type	evaluatedgeneric_origindataclass_fieldsrn   parent_field_infor   
decoratorspydantic_extra_infoannr2   r(   r   r.   collect_model_fields   s    












r   Mapping[TypeVar, Any]5tuple[dict[str, FieldInfo], PydanticExtraInfo | None]c          	      C  s   i }| | V | j D ]\}}|jr|||< qt|||dd}t||| |||< q| jdurF| jjsFtt	j
| jjg|jR  dd}n| j}W d   ||fS W d   ||fS 1 s`w   Y  ||fS )a^  Rebuild the (already present) model fields by trying to reevaluate annotations.

    This function should be called whenever a model with incomplete fields is encountered.

    Returns:
        A two-tuple, the first element being the rebuilt fields, the second element being
        the rebuild `PydanticExtraInfo` instance, if available.

    Raises:
        NameError: If one of the annotations failed to evaluate.

    Note:
        This function *doesn't* mutate the model fields in place, as it can be called during
        schema generation, where you don't want to mutate other model's fields.
    Fr   NTr   )pushrG   rk   r   r   r   __pydantic_extra_info__r2   r/   r   	eval_typer0   types_namespace)	re   r   r   r   rebuilt_fieldsf_namern   	new_fieldrebuilt_extra_infor(   r(   r.   rebuild_model_fields  s6   



r   r   c          
      C  s   t  }| j}|rt| j|}tj|g|jR  \}}ntj| jg|jR  }t||}tj|g|jR  }d}| j	 }t
u rI|j|tjd}	n|j||tjd}	||	_	||	_|	jd ur`|	jn||	_|shd|	_|	S )NTr   F)r   rl   r   replace_typesr   r   try_eval_typer   r   r   r   r   r   r   r   r   )
rn   r   r   r   r   existing_descr   r   assignr   r(   r(   r.   r     s<   r   )r   r   type[StandardDataclass]NsResolver | Nonedict[Any, Any] | Nonec             	   C  s  t  }i }|p	t }| j}t| jD ]}t|sq|| | D ]\}}	t	
|}
||
vr2q$|j\}}t	|	j||\}}t	|rGq$|	jsW|	jtju rW|	jtju rWq$t|	j|r|	jjrr|	jjdu rqtd| dddq$|j||	jtjd}|	j|_n|j||	tjd}|	|_|sd|_||_|||< t||| |jturtt| |||rt| ||j q$W d   n1 sw   Y  q|r|  D ]}|!| q|j"rt#| |t$| d d	 |S )
a|  Collect the fields of a dataclass.

    Args:
        cls: dataclass.
        config_wrapper: The config wrapper instance.
        ns_resolver: Namespace resolver to use when getting dataclass annotations.
            Defaults to an empty instance.
        typevars_map: A dictionary mapping type variables to their concrete types.

    Returns:
        The dataclass fields.
    FzDataclass field zD has init=False and init_var=True, but these are mutually exclusive.zclashing-init-and-init-var)coder   N__is_pydantic_dataclass__rj   )%r   r   __dataclass_fields__r   __mro__r   r   r   rk   r   r   r   r   typer   initr   MISSINGdefault_factoryrP   init_varr   r   r   	DATACLASSr   r   r   r   r   rU   setattrvaluesapply_typevars_mapr   ro   rS   )re   r   r   r   r   rg   r   r   rA   dataclass_field	base_annsglobalnslocalnsr   r   rn   r   r(   r(   r.   collect_dataclass_fields  sx   







9
r	  type[PydanticDataclass]c                C  s   t  }i }|| N | j D ]?\}}|jr|||< q|j}tj|jg|j	R  }	t
|	|}	|j|	|jtjd}
|
jdurB|
jn||
_t|||
 |
||< qW d   |S 1 s[w   Y  |S )a  Rebuild the (already present) dataclass fields by trying to reevaluate annotations.

    This function should be called whenever a dataclass with incomplete fields is encountered.

    Raises:
        NameError: If one of the annotations failed to evaluate.

    Note:
        This function *doesn't* mutate the dataclass fields in place, as it can be called during
        schema generation, where you don't want to mutate other dataclass's fields.
    r   N)r   r   rG   rk   r   rl   r   r   r   r   r   r   r   r   r   r  r   )re   r   r   r   r   r   r   rn   r   r   r   r(   r(   r.   rebuild_dataclass_fields{  s4   


r  r   c                 C  s   |  d S )N_rR   r   r(   r(   r.   r     s   r   c                 C  s   |  do
|  d S )Nr  __r  r   r(   r(   r.   is_valid_privateattr_name  s   r  r   3Callable[[], Any] | Callable[[dict[str, Any]], Any]'TypeIs[Callable[[dict[str, Any]], Any]]c              	   C  s^   zt | }W n ttfy   Y dS w t|j }t|dko.t|d o.|d j	t
ju S )zMWhether the provided default factory callable has a validated data parameter.Fr   r   )r   signature_no_evalrV   ru   list
parametersr  rZ   r   r   r   empty)r   sigr  r(   r(   r.   takes_validated_data_argument  s   (r  )validated_datacall_default_factoryr   :Callable[[], Any] | Callable[[dict[str, Any]], Any] | Noner  dict[str, Any] | Noner  c                C  s`   ddl m} |du r|| S |r.t|dr&td|}|du r"td||S td|}| S tS )zMResolve the default value using either a static default or a default_factory.r   )smart_deepcopyN)r   zCallable[[dict[str, Any]], Any]zpThe default factory requires the 'validated_data' argument, which was not provided when calling 'get_default()'.zCallable[[], Any])_utilsr  r  r   rV   r   )r   r   r  r  r  facr(   r(   r.   resolve_default_value  s   


r  r(   )r4   r	   r5   r!   )r5   r8   )
r?   r@   rA   rB   rC   rD   rE   rB   r5   rF   )F)re   rf   rg   rh   ri   r1   r5   rF   )rp   rq   rr   rB   rn   r"   )rx   ry   rr   rB   rn   r"   )r   r   rr   rB   rn   r"   r5   rF   )
re   r   r   r   r   r   r   r   r5   r   )
re   r   r   r   r   r   r   r   r5   r   )
rn   r"   r   r   r   r   r   r1   r5   r"   )
re   r   r   r   r   r   r   r   r5   rh   )
re   r
  r   r   r   r   r   r   r5   rh   )r   rB   r5   r1   )r   r  r5   r  )
r   r	   r   r  r  r  r  r1   r5   r	   )Tr,   
__future__r   _annotationsr   r[   collections.abcr   	functoolsr   inspectr   r   rer   typingr   r	   r
   r   r   pydantic_corer   typing_extensionsr   typing_inspection.introspectionr   pydanticr   pydantic.errorsr   aliasesr    r   r   _configr   _docs_extractionr   _import_utilsr   r   _internal_dataclassr   _namespace_utilsr   _reprr   r  r   r   r>   r!   rg   r"   mainr#   _dataclassesr$   r%   _decoratorsr&   r'   	dataclassr/   r7   r6   rd   ro   rw   r   r   r   r   r   r   r   r	  r  r   r  r  r  r(   r(   r(   r.   <module>   sr    

+


2 
U
/0
l
.

