
    df.                    r   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZmZmZ e	rddlmZ ddlmZ ddlmZ ddlm Z  	 	 d	 	 	 	 	 	 	 ddZ! G d de      Z" G d de"e      Z#dd	 	 	 	 	 	 	 	 	 	 	 ddZ$d dZ%dd	 	 	 	 	 	 	 d!dZ&d"dZ'd"dZ(y)#zmPrivate logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`.    )annotationsN)copy)TYPE_CHECKINGAny)BaseMetadata)PydanticUndefined   )_typing_extra)ConfigWrapper)Representation)get_cls_type_hints_lenientget_type_hintsis_classvaris_finalvar   	FieldInfo	BaseModel)StandardDataclass)DecoratorInfosc                    t        | dd      }d}|r	 t        j                  |   j                  }t        | |||      S # t        $ r Y w xY w)a  Gets type hints for an object by inferring the global namespace.

    It uses the `typing.get_type_hints`, The only thing that we do here is fetching
    global namespace from `obj.__module__` if it is not `None`.

    Args:
        obj: The object to get its type hints.
        localns: The local namespaces.
        include_extras: Whether to recursively include annotation metadata.

    Returns:
        The object type hints.
    
__module__N)globalnslocalnsinclude_extras)getattrsysmodules__dict__KeyErrorr   )objr   r   module_namer   s        S/home/api-vastappli/venv/lib/python3.12/site-packages/pydantic/_internal/_fields.pyget_type_hints_infer_globalnsr%      s[    $ #|T2K&*H	{{;/88H #'R`aa  		s   ? 	A
Ac                      e Zd ZdZdZy)PydanticMetadataz0Base class for annotation markers like `Strict`. N)__name__r   __qualname____doc__	__slots__r(       r$   r'   r'   6   s
    :Ir-   r'   c                      e Zd ZdZddZy)PydanticGeneralMetadataz*Pydantic general metada like `max_digits`.c                    || _         y N)r    )selfmetadatas     r$   __init__z PydanticGeneralMetadata.__init__?   s	     r-   N)r3   r   )r)   r   r*   r+   r4   r(   r-   r$   r/   r/   <   s
    4!r-   r/   )typevars_mapc                  ddl m} t        | |      }| j                  j	                  di       }i }t               }	|j                         D ]R  \  }
dk(  r|j                  D ]  }j                  |      s|D ]N  }t        |      sddl
m} t        ||      r|j                  v r1t        d dt        |       d| d	       t!        fd
|j                  D              }t#        j$                  d d| d| dt&                t)        |
      r|	j+                         t-        |
t        | t.                    r|	j+                         t1              s| j2                  rdk7  rt        dd      t        | di       j	                  d      }|D ]  }t5        j6                  |      rt5        j                   |      ndD ch c]  }|j8                   }}t        |      sS||u rX|v r]t#        j$                  d d|j:                   dt&                	 t        | t.              }|t.        u rt<        	  |j>                  |
|      }	 tA        |        | j                  d   }|jJ                  v rtM        d      ||<   U |r'|jO                         D ]  }|jQ                  ||        ||	fS c c}w # t<        $ r Y mw xY w# t<        $ rt |v r |jB                  |
      }nZi }| jD                  ddd   D ]  }|jG                  t        |di                |v rtI        |         }n |jB                  |
      }Y w xY w)a[  Collect the fields of a nascent pydantic model.

    Also collect the names of any ClassVars present in the type hints.

    The returned value is a tuple of two items: the fields dict, and the set of ClassVar names.

    Args:
        cls: BaseModel or dataclass.
        bases: Parents of the class, generally `cls.__bases__`.
        config_wrapper: The config wrapper instance.
        types_namespace: Optional extra namespace to look for types in.
        typevars_map: A dictionary mapping type variables to their concrete types.

    Returns:
        A tuple contains fields and class variables.

    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.
    r   r   __annotations__model_configr   zField "z" conflicts with member z of protected namespace "z".c              3  F   K   | ]  }j                  |      r|  y wr1   
startswith).0xann_names     r$   	<genexpr>z'collect_model_fields.<locals>.<genexpr>}   s$      -hNaNabcNd-s   !!z)" has conflict with protected namespace "z_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = z`.rootzUnexpected field with name z4; only 'root' is allowed as a field of a `RootModel`__pydantic_generic_metadata__originr(   zField name "z"" shadows an attribute in parent "z"; Nmodel_fields__pydantic_decorators__z0you can't override a field with a computed field))fieldsr   r   r    getsetitemsprotected_namespacesr;   hasattrmainr   
issubclassrD   	NameErrorr   tuplewarningswarnUserWarningr   add_is_finalvar_with_default_valr   is_valid_field_name__pydantic_root_model__dataclassesis_dataclassnamer*   AttributeErrorfrom_annotated_attributedelattrfrom_annotation	__bases__updater   computed_fields
ValueErrorvaluesapply_typevars_map)clsbasesconfig_wrappertypes_namespacer5   r   
type_hintsr   rF   
class_varsann_typeprotected_namespacebr   valid_namespacesgeneric_originbasefielddataclass_fieldsdefault
field_infomodel_fields_lookupr=   
decoratorsr>   s                           @r$   collect_model_fieldsrv   C   s   < #+CAJ ,,""#4b9K#%F5J(..0 b&(~% #1#F#F 	""#67 Aq(+4 *1i 8X=W"+")(3KGTUW_L`Ka";<O;PPR!T#  (- -#1#F#F- ($ MM!(+TUhTi jDDTCUUWY $		* x NN8$(73J[3\]NN8$"8,&&8v+=-h\9mn  !&ErJNNxX 	DEPE]E]^bEc););D)Aik $

    tX&>)// "8*,NtO`O`Naade	$	c8->?G++$$ ,* <;;HgNJX& &)\\2K%L
z111OPP%xEb&H ]]_ 	DE$$\?C	D :y \ " 3  	E;&6Y66x@
 =?#tt, OA'..wq."/MNO22 "&&9(&C!DJ
 ";!:!:8!DJ#	Es+   K2K#&K	K K #A:M M c                    ddl m} t        |       sy|t        u ryt	        ||      r|j
                  t        u r|j                  yy)Nr   r   FT)rF   r   r   r   
isinstancerr   default_factory)type_valr   s      r$   rT   rT      sC    "u	!	!	C	#8I)IcNaNaNir-   c                  ddl m} i }| j                  }t        t	        |             }|j                         D ]  \  }}t        j                  |j                  ||      }	t        |	      r4|j                  s|j                  t        j                  k(  r^t        |j                  |      r5|j                  j                   r |j"                  |	|j                        }
n |j"                  |	|      }
|
||<   |
j                  t$        ust        t'        | ||
      |      st)        | ||
j                          |r'|j+                         D ]  }|j-                  ||        |S )a  Collect the fields of a dataclass.

    Args:
        cls: dataclass.
        types_namespace: Optional extra namespace to look for types in.
        typevars_map: A dictionary mapping type variables to their concrete types.

    Returns:
        The dataclass fields.
    r   r   )rF   r   __dataclass_fields__dictvarsrI   r
   eval_type_lenienttyper   initry   rW   MISSINGrx   rr   init_varr[   r   r   setattrrb   rc   )rd   rg   r5   r   rF   rq   cls_localnsr>   dataclass_fieldrj   rs   rp   s               r$   collect_dataclass_fieldsr      sL    ##%F585M5MtCy/K%5%;%;%= 7!/ 22?3G3GZefx ##(G(G;K^K^(^ o--y9&&//;;;HoF]F]^J;;;HoVJ%x%66:gcS[]gFhjs;tC:#5#56+7. ]]_ 	DE$$\?C	D Mr-   c                &    | j                  d       S )N_r:   rY   s    r$   rU   rU     s    s###r-   c                L    | j                  d      xr | j                  d       S )Nr   __r:   r   s    r$   is_valid_privateattr_namer     s"    ??3=(=$==r-   )NF)r"   r   r   dict[str, Any] | Noner   boolreturnzdict[str, Any])rd   ztype[BaseModel]re   ztuple[type[Any], ...]rf   r   rg   r   r5   dict[Any, Any] | Noner   z%tuple[dict[str, FieldInfo], set[str]])rz   z	type[Any]r{   r   r   r   )rd   ztype[StandardDataclass]rg   r   r5   r   r   zdict[str, FieldInfo])rY   strr   r   ))r+   
__future__r   _annotationsrW   r   rP   r   typingr   r   annotated_typesr   pydantic_corer    r
   _configr   _reprr   r   r   r   r   rF   r   rL   r   _dataclassesr   _decoratorsr   r%   r'   r/   rv   rT   r   rU   r   r(   r-   r$   <module>r      s   s 2  
   % ( +  " ! _ _" /+
 &* b	b"b b 	b:~ !. ! +/P	P P "P +	P (P +Pf
 tx.	 .3H.[p..b$>r-   