Viewing File: /opt/hc_python/lib/python3.12/site-packages/pydantic/_internal/__pycache__/_fields.cpython-312.pyc

�

e��gV:���dZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZmZddl
mZddlmZd	d
lmZd	dlmZd	dlmZd	d
lmZd	dlmZmZmZmZerddlmZddlm Z ddl!m"Z"d	dl#m$Z$d	dl%m&Z&		d$							d%d�Z'Gd�de�Z(d&d�Z)e	d��d'd��Z*d(d�Z+dd�											d)d�Z,d*d�Z-d+d�Z.ddd �									d,d!�Z/d-d"�Z0d-d#�Z1y).zmPrivate logic related to fields (the `Field()` function and `FieldInfo` class), and arguments to `Annotated`.�)�annotationsN)�copy)�	lru_cache)�
TYPE_CHECKING�Any)�PydanticUndefined)�PydanticUserError�)�
_typing_extra)�
ConfigWrapper)�extract_docstrings_from_cls)�Representation)�get_cls_type_hints_lenient�get_type_hints�is_classvar�is_finalvar��BaseMetadata���	FieldInfo��	BaseModel)�StandardDataclass)�DecoratorInfosc��t|dd�}d}|r	tj|j}t||||��S#t$rY�wxYw)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)�objrr �module_namers     �I/opt/hc_python/lib/python3.12/site-packages/pydantic/_internal/_fields.py�get_type_hints_infer_globalnsr)s[��$�#�|�T�2�K�&*�H��	��{�{�;�/�8�8�H��#��'�R`�a�a���	��	�s�?�	A�
Ac��eZdZdZdZy)�PydanticMetadataz0Base class for annotation markers like `Strict`.�N)�__name__r�__qualname__�__doc__�	__slots__r,�r(r+r+<s
��:��Ir1r+c�"�t�|�S)z�Create a new `_PydanticGeneralMetadata` class with the given metadata.

    Args:
        **metadata: The metadata to add.

    Returns:
        The new `_PydanticGeneralMetadata` class.
    )�_general_metadata_cls)�metadatas r(�pydantic_general_metadatar5Bs��#� �"�8�,�,r1)�maxsizec�2�ddlm}Gd�dt|�}|S)zCDo it this way to avoid importing `annotated_types` at import time.rrc��eZdZdZdd�Zy)�7_general_metadata_cls.<locals>._PydanticGeneralMetadataz,Pydantic general metadata like `max_digits`.c��||_y�N)r$)�selfr4s  r(�__init__z@_general_metadata_cls.<locals>._PydanticGeneralMetadata.__init__Vs	��$�D�Mr1N)r4r)r-rr.r/r=r,r1r(�_PydanticGeneralMetadatar9Ss
��:�	%r1r>)�annotated_typesrr+)rr>s  r(r3r3Ns��-�%�#3�\�%�$�#r1c��|jr@t|�}|j�D]!\}}|j��||vs�|||_�#yyr;)�use_attribute_docstringsr
�items�description)�cls�fields�config_wrapper�fields_docs�ann_name�
field_infos      r(�_update_fields_from_docstringsrJ\sO���.�.�1�#�6��$*�L�L�N� �H�j��%�%�-�(�k�2I�)4�X�)>�
�&�%3�/r1)�typevars_mapc���ddlm}t||�}|jj	di�}i}t�}	|j
�D�]p\�}
�dk(r�
|jD]�}�j|�s�|D]N}t|��s�ddl
m}
t||
�r�|jvr�1td��dt|���d|�d	���t!�fd
�|jD��}t#j$d��d|�d|�d
�t&���t)|
�r|	j+����t-|
t|�t.��r|	j+����t1��s��|j2r�dk7rtd��d���t|di�j	d�}|D]�}t5j6|�rt5j|�ndD�chc]}|j8��}}t|��s�S||ur�X�|vr�]�|vr�bt#j$d��d|j:�d|j:�d�t&���	t|�t.�}|t.urt<�	t?|
��|j@|
|�}	tC|��|jd}�|jLvrtOd��||�<��s|r'|jQ�D]}|jS||��tU|||�||	fScc}w#t<$rY�zwxYw#t<$rt�|vr|jD|
�}nZi}|jFddd�D]}|jIt|di��� �|vrtK|��}n|jD|
�}Y��wxYw)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.
    rr�__annotations__�model_configrzField "z" conflicts with member z of protected namespace "z".c3�F�K�|]}�j|�r�|���y�wr;��
startswith)�.0�xrHs  �r(�	<genexpr>z'collect_model_fields.<locals>.<genexpr>�s$�����-�#F�a�h�Na�Na�bc�Nd��#F�s�!�!z)" has conflict with protected namespace "z_".

You may be able to resolve this warning by setting `model_config['protected_namespaces'] = z`.�rootzUnexpected field with name z4; only 'root' is allowed as a field of a `RootModel`�__pydantic_generic_metadata__�originr,zField name "z" in "z"" shadows an attribute in parent "�"N����model_fields�__pydantic_decorators__z0you can't override a field with a computed field)+rErrr$�get�setrB�protected_namespacesrQ�hasattr�mainr�
issubclassrZ�	NameErrorr!�tuple�warnings�warn�UserWarningr�add�_is_finalvar_with_default_valr�is_valid_field_name�__pydantic_root_model__�dataclasses�is_dataclass�namer.�AttributeError�#_warn_on_nested_alias_in_annotation�from_annotated_attribute�delattr�from_annotation�	__bases__�updater�computed_fields�
ValueError�values�apply_typevars_maprJ)rD�basesrF�types_namespacerKr�
type_hintsrrE�
class_vars�ann_type�protected_namespace�br�valid_namespaces�generic_origin�base�field�dataclass_fields�defaultrI�model_fields_lookuprS�
decoratorsrHs                        @r(�collect_model_fieldsr�ds����<#�+�C��A�J��,�,�"�"�#4�b�9�K�#%�F��5�J�(�.�.�0���(��~�%�
�#1�#F�#F���"�"�#6�7��A��q�(�+�4� *�1�i� 8�X����=W�"+�")�(��3K�G�TU�W_�L`�Ka�";�<O�;P�PR�!T�#���(-�-�#1�#F�#F�-�(�$��M�M�!�(��+T�Uh�Ti�jD�DT�CU�UW�Y�$�	�$G�*�x� ��N�N�8�$��(��7�3��J[�3\�]��N�N�8�$��"�8�,���&�&�8�v�+=��-�h�\�9m�n��
�!��&E�r�J�N�N�x�X���D�EP�E]�E]�^b�Ec��);�);�D�)A�ik�)k� �)k�u��
�
�)k�
� ��t�X�&��>�)���/�/���;�.���
�
�"�8�*�F�3�3C�3C�2D�E��)�)�*�!�-���%�0	��c�8�->�?�G��+�+�$�$�,�*
0��(�C�;��;�;�H�g�N�J�
���X�&�&)�\�\�2K�%L�
��z�1�1�1��O�P�P�%��x��S1�V��]�]�_�E��$�$�\�?�C�%�#�3���?��:����K ��j"�
��
��5�	E��;�&�6�Y�6�6�x�@�
�=?�#����t��t�,�A�'�.�.�w�q�.�"�/M�N�-��2�2�"&�&9�(�&C�!D�J�
";��!:�!:�8�!D�J��#	E�s+�K:�L�K?�?	L�
L�A:N�
Nc��ddlm}t|d�r{|jD]k}t	j
|�s�t	j|�D];}t||�s�|j��tjd|�d�t��k�myy)Nrr�__args__z `alias` specification on field "z5" must be set on outermost annotation to take effect.)rErr_r�r�is_annotated�get_args�
isinstance�aliasrdrerf)r}rHr�anno_arg�
anno_type_args     r(roros~��"��x��$� �)�)�H��)�)�(�3�%2�%;�%;�H�%E�M�!�-��;�
�@S�@S�@_� �
�
�>�x�j�H}�~�'���
&F�*�%r1c��ddlm}t|�sy|turyt	||�r|j
tur
|j�yy)NrrFT)rErrrr�r��default_factory)�type_�valrs   r(rhrhsC��"��u���	�!�	!��	�C��	#����8I�)I�c�Na�Na�Ni��r1)rKrFc��ddlm}i}|j}tt	|��}t
jj|j�}|�i|j�|xsi�}|j�D�]J\}	}
tj|
j||�}t|�r�4|
js;|
j t"j$k(r|
j&t"j$k(r�{t)|
j |�r^|
j j*r*|
j jdurt-d|	�d�d�����|j.||
j �}n|j.||
�}|||	<|j t0us��t)t3||	|�|�s��4t5||	|j ���M|r'|j7�D]}
|
j9||��|�
t;|||�|S)aFCollect 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.
        config_wrapper: The config wrapper instance.

    Returns:
        The dataclass fields.
    rrFzDataclass field zD has init=False and init_var=True, but these are mutually exclusive.zclashing-init-and-init-var)�code)rEr�__dataclass_fields__�dict�varsr"r#r\rr$rBr�eval_type_lenient�typer�initr�rk�MISSINGr�r��init_varr	rprr!�setattrrwrxrJ)rDrzrKrFrrEr��cls_localns�
source_modulerH�dataclass_fieldr}rIr�s              r(�collect_dataclass_fieldsr�s���$#�#%�F�58�5M�5M���t�C�y�/�K��K�K�O�O�C�N�N�3�M�� �O�]�3�3�O��8M�2�O��%5�%;�%;�%=�!��/� �2�2�?�3G�3G��Ze�f���x� �� �$�$��'�'�;�+>�+>�>��/�/�;�3F�3F�F�
��o�-�-�y�9��&�&�/�/�"�*�*�/�/�5�8�+�*�8�*�4x�y�9����;��;�;�H�o�F]�F]�^�J�;��;�;�H�o�V�J�%��x�����%6�6�:�g�c�S[�]g�Fh�js�;t��C��:�#5�#5�6�A&>�D��]�]�_�E��$�$�\�?�C�%��!�&�s�F�N�C��Mr1c�&�|jd�S)N�_rP�rms r(ririds�����s�#�#�#r1c�L�|jd�xr|jd�S)Nr��__rPr�s r(�is_valid_privateattr_namer�hs"���?�?�3��=�����(=�$=�=r1)NF)r&rr�dict[str, Any] | Noner �bool�returnzdict[str, Any])r4rr�r)r�ztype[BaseMetadata])rD�	type[Any]rE�dict[str, FieldInfo]rFrr��None)rDztype[BaseModel]ryztuple[type[Any], ...]rFrrzr�rK�dict[Any, Any] | Noner�z%tuple[dict[str, FieldInfo], set[str]])r}r�rH�str)r�r�r�rr�r�)
rDztype[StandardDataclass]rzr�rKr�rFzConfigWrapper | Noner�r�)rmr�r�r�)2r/�
__future__r�_annotationsrkr"rdr�	functoolsr�typingrr�
pydantic_corer�pydantic.errorsr	�r�_configr�_docs_extractionr
�_reprrrrrrr?rrErr`r�_dataclassesr�_decoratorsrr)r+r5r3rJr�rorhr�rir�r,r1r(�<module>r�sL��s�2��
����%�+�-��"�9�!�_�_��,�"� �/�+�
&*� �b�	�b�
"�b��b��	b�:�~��	-��4��
$��
$�?�+/�
Y�	�Y� �Y�"�Y�+�	Y�(�
Y�+�Y�x�
�"+/�+/�E�	 �E�*�E�(�	E�
)�E��
E�P$�>r1
Back to Directory File Manager