Your IP : 3.21.43.72


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/pydantic/v1/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/pydantic/v1/__pycache__/generics.cpython-311.pyc

�

�&f�E�
�t�UddlZddlZddlZddlmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZddlmZmZddlmZmZddlmZddlmZddlmZmZdd	lm Z dd
lm!Z!m"Z"m#Z#m$Z$m%Z%ddl&m'Z'm(Z(ej)dkrdd
lm*Z*ej)dkrddlmZedd���Z+eZ,e
eeee
edffZ-ee,eefZ.ej)dkr!ee-eefZ/eeee.fZ0neZ/eZ0e/��Z1e0��Z2Gd�de��Z3dedeeefdefd�Z4dee3de
edfddfd�Z5i�6��j7Z8eee9d<dede	e,fd�Z:de
ee;e<ffd �Z=d!ee3d"ee;efd#ee;e>fd$eee>fddf
d%�Z?dS)&�N)�
TYPE_CHECKING�Any�ClassVar�Dict�
ForwardRef�Generic�Iterator�List�Mapping�Optional�Tuple�Type�TypeVar�Union�cast)�WeakKeyDictionary�WeakValueDictionary)�	Annotated�Literal�)�gather_all_validators)�DeferredType)�	BaseModel�create_model)�JsonWrapper)�display_as_type�get_all_type_hints�get_args�
get_origin�typing_base)�
all_identical�lenient_issubclass���
)�_UnionGenericAlias�r$�)r�
GenericModelT�GenericModel)�bound.)r$�	c�@�eZdZUdZdZeeed<eree	e
dfed<deede
eee	eedffdeefd	�Zedeede	eedfdefd
���Zededeeefd���Zd
S)r*�F�__concrete__.�__parameters__�cls�params�returnc
���dtdtf�fd�}t�||����}|�|S�jrt
�jvrtd���t|t��s|f}�tur(td�|D����rtd���t�d��std	�j
�d
����t�|��tt!�j|����}t%|���|�����r|r�S��|��}t-���}t/������}d�|D��}�fd�|D��}	t3��\}
}t5t6tt9|f|
p�j�ft��|����zd|dd
�|	����}|t>|<|rCd}
|}t@j!|jj"}|
|ur|�#||��}
|dz
}|
|u��j$|_$td�tK|�����D����}||_|r||_|t||��<tM|��dkr|t||d��<tO||	||��|S)a�Instantiates a new class from a generic class `cls` and type variables `params`.

        :param params: Tuple of types the class . Given a generic class
            `Model` with 2 type variables and a concrete model `Model[str, int]`,
            the value `(str, int)` would be passed to `params`.
        :return: New model class inheriting from `cls` with instantiated
            types described by `params`. If no parameters are given, `cls` is
            returned as is.

        �_paramsr3c����t|��}t|��dkr8t|dt��rt	|d��|df}�||fS)N�rr)r�len�
isinstance�list�tuple)r5�argsr1s  ��I/opt/cloudlinux/venv/lib/python3.11/site-packages/pydantic/v1/generics.py�
_cache_keyz2GenericModel.__class_getitem__.<locals>._cache_keyWsV����G�$�$�D��4�y�y�A�~�~�*�T�!�W�d�";�";�~��d�1�g����Q��0�����%�%�Nz?Cannot parameterize a concrete instantiation of a generic modelc3�@K�|]}t|t��V��dS�N)r9r��.0�params  r=�	<genexpr>z1GenericModel.__class_getitem__.<locals>.<genexpr>es,����&V�&V�e�z�%��'A�'A�&V�&V�&V�&V�&V�&Vr?zDType parameters should be placed on typing.Generic, not GenericModelr0zType z< must inherit from typing.Generic before being parameterizedc�F�i|]\}}t|��tu�||��Sr.)rr)rC�k�vs   r=�
<dictcomp>z2GenericModel.__class_getitem__.<locals>.<dictcomp>us/��\�\�\���1�j��m�m�S[�>[�>[�q�!�>[�>[�>[r?c�d��i|],}|�jv�|t���j|jf��-Sr.)�
__fields__r�
field_info)rCrGr1s  �r=rIz2GenericModel.__class_getitem__.<locals>.<dictcomp>ws=���x�x�x��de�il�iw�dw�dw�!�l�n�n�c�n�Q�&7�&B�C�dw�dw�dwr?)�
__module__�__base__�
__config__�__validators__�__cls_kwargs__�_c��i|]}|d��SrAr.rBs  r=rIz2GenericModel.__class_getitem__.<locals>.<dictcomp>�s��U�U�U�U�U�D�U�U�Ur?rr)(r�CacheKey�_generic_types_cache�getr/r�	__bases__�	TypeErrorr9r;r*�any�hasattr�__name__�check_parameters_count�dict�zipr0r!�keys�values�__concrete_name__rr�items�get_caller_frame_inforrrrM�__parameterized_bases__�_assigned_parameters�sys�modules�__dict__�
setdefault�Config�iter_contained_typevarsr8�_prepare_model_fields)r1r2r>�cached�typevars_map�
model_name�
validators�
type_hints�instance_type_hints�fields�model_module�called_globally�
created_model�object_by_reference�reference_name�reference_module_globals�
new_paramss`                r=�__class_getitem__zGenericModel.__class_getitem__Ksq���	&��	&��	&�	&�	&�	&�	&�	&�&�)�)�*�*�V�*<�*<�=�=�����M���	_��s�}� <� <��]�^�^�^��&�%�(�(�	��Y�F��,���3�&V�&V�v�&V�&V�&V�#V�#V���b�c�c�c��s�,�-�-�	p��n�C�L�n�n�n�o�o�o��s�F�+�+�+�59�#�c�>P�RX�:Y�:Y�5Z�5Z����*�*�,�,�l�.A�.A�.C�.C�D�D�	��	��J��*�*�6�2�2�
�*�3�/�/�
�'��,�,�2�2�4�4�
�\�\�
�\�\�\��x�x�x�x�M`�x�x�x��(=�(?�(?�%��o�������
�'�9�3�>���%��(C�(C�L�(Q�(Q�"R�"R�R��)�#�

�
��
�
�
�
�
�/;��]�+��	&�"&��'�N�'*�{�=�3K�'L�'U�$�%�]�:�:�&>�&I�&I�.�Zg�&h�&h�#��#�%��&�]�:�:� #�z�
���U�U�&=�l�>Q�>Q�>S�>S�&T�&T�U�U�U�
�
�
�*4�^�
�"��	6�+5�M�(�4A��Z�Z��/�/�0��v�;�;�!���:G� ���F�1�I�!6�!6�7�	�m�V�5H�,�W�W�W��r?c�^�d�|D��}d�|��}|j�d|�d�S)a�Compute class name for child classes.

        :param params: Tuple of types the class . Given a generic class
            `Model` with 2 type variables and a concrete model `Model[str, int]`,
            the value `(str, int)` would be passed to `params`.
        :return: String representing a the new class where `params` are
            passed to `cls` as type variables.

        This method can be overridden to achieve a custom naming scheme for GenericModels.
        c�,�g|]}t|����Sr.)rrBs  r=�
<listcomp>z2GenericModel.__concrete_name__.<locals>.<listcomp>�s ��B�B�B�%��u�-�-�B�B�Br?z, �[�])�joinr[)r1r2�param_names�params_components    r=razGenericModel.__concrete_name__�sD��C�B�6�B�B�B���9�9�[�1�1���,�4�4�!1�4�4�4�4r?rnc#���K�dttdtdtttf�fd�}�jD]�}t|t��s�t
|dd��s�*�tvrH|tvr�=�fd�t����D��}|||��Ed{V���{||���Ed{V����dS)a�
        Returns unbound bases of cls parameterised to given type variables

        :param typevars_map: Dictionary of type applications for binding subclasses.
            Given a generic class `Model` with 2 type variables [S, T]
            and a concrete model `Model[str, int]`,
            the value `{S: str, T: int}` would be passed to `typevars_map`.
        :return: an iterator of generic sub classes, parameterised by `typevars_map`
            and other assigned parameters of `cls`

        e.g.:
        ```
        class A(GenericModel, Generic[T]):
            ...

        class B(A[V], Generic[V]):
            ...

        assert A[int] in B.__parameterized_bases__({V: int})
        ```
        �
base_model�mapped_typesr3c3���K�t�fd�|jD����}|�|��}||us|�urdS|V�dS)Nc3�(�K�|]}�|V��
dSrAr.)rCrDr�s  �r=rEzQGenericModel.__parameterized_bases__.<locals>.build_base_model.<locals>.<genexpr>�s(�����#_�#_�E�L��$7�#_�#_�#_�#_�#_�#_r?)r;r0r{)r�r��base_parameters�parameterized_baser1s `  �r=�build_base_modelz>GenericModel.__parameterized_bases__.<locals>.build_base_model�sp������$�#_�#_�#_�#_�Z�E^�#_�#_�#_�_�_�O�!+�!=�!=�o�!N�!N��!�Z�/�/�3E��3L�3L���$�$�$�$�$�$r?r0Nc�D��i|]\}}|��||����Sr.)rV)rC�key�valuerns   �r=rIz8GenericModel.__parameterized_bases__.<locals>.<dictcomp>�s<���5�5�5�@J��U��\�-�-�e�U�;�;�5�5�5r?)	rr*�Parametrizationr	rW�
issubclass�getattrrerb)r1rnr�r�r�s``   r=rdz$GenericModel.__parameterized_bases__�sJ������0	%��\�*�	%�:I�	%�
�d�<�(�
)�	%�	%�	%�	%�	%�	%��-�	F�	F�J��j�,�7�7�
F���Z�)9�4�@�@�
F���,�,�,��!5�5�5��
5�5�5�5�Nb�cf�Ng�Nm�Nm�No�No�5�5�5�L� 0�/�
�L�I�I�I�I�I�I�I�I�I�I�,�+�J��E�E�E�E�E�E�E�E�E�E�9	F�	Fr?N)r[rM�__qualname__�	__slots__r/r�bool�__annotations__rr
�TypeVarTyperr)rrr{�classmethod�strrar�r	rdr.r?r=r*r*@s9��������I�#(�L�(�4�.�(�(�(��:�!��{�C�'7�!8�9�9�9�9�]�t�M�2�]�E�$�s�)�U�SW�X[�S\�^a�Sa�Mb�Bb�<c�]�hl�mp�hq�]�]�]�]�~�
5�t�C�y�
5�%��S�	�3��2G�
5�C�
5�
5�
5��[�
5��=F�?�=F�x�PT�UX�PY�GZ�=F�=F�=F��[�=F�=F�=Fr?�type_�type_mapr3c�����s|St|��}t|��}|tur.|^}}tt|���t	|��fS|t
ustjdkr|tur��	||��S|r�t	�fd�|D����}t||��r|S|�Ut|t��r@t|t��s+t|dd���tt|j��}|�J�tjdkr|t jurt%||��S||S|sXt'|t(��rC|js<|j}t	�fd�|D����}t||��r|S||St|t.t0f��r/t1�fd�|D����}t||��r|S|S|s1t'|t2��rt|j���|_|S��	||��}t|t6��rt9|��S|S)a�Return type with all occurrences of `type_map` keys recursively replaced with their values.

    :param type_: Any type, class or generic alias
    :param type_map: Mapping from `TypeVar` instance to concrete types.
    :return: New type representing the basic structure of `type_` with all
        `typevar_map` keys recursively replaced.

    >>> replace_types(Tuple[str, Union[List[str], float]], {str: int})
    Tuple[int, Union[List[int], float]]

    r'c3�8�K�|]}t|���V��dSrA��
replace_types)rC�argr�s  �r=rEz replace_types.<locals>.<genexpr>s-�����"U�"U�C�=��h�#?�#?�"U�"U�"U�"U�"U�"Ur?N�_namer#c3�8�K�|]}t|���V��dSrAr�)rC�tr�s  �r=rEz replace_types.<locals>.<genexpr>0s-�����"Q�"Q�!�=��H�#=�#=�"Q�"Q�"Q�"Q�"Q�"Qr?c3�8�K�|]}t|���V��dSrAr�)rC�elementr�s  �r=rEz replace_types.<locals>.<genexpr>8s-�����S�S�'�]�7�H�=�=�S�S�S�S�S�Sr?)rrrr�r;�
ExtLiteralrf�version_inforrVr!r9r r��typingr��types�	UnionTyper&r"r*r/r0r
r:r�
inner_typer�r)	r�r��	type_args�origin_type�annotated_type�annotations�resolved_type_args�
resolved_list�new_types	 `       r=r�r��s������������I��U�#�#�K��i���'0�$�����~�x�@�@�%��BT�BT�T�U�U��z�!�!�s�'7�6�'A�'A�k�U\�F\�F\��|�|�E�5�)�)�)��/�"�"U�"U�"U�"U�9�"U�"U�"U�U�U����$6�7�7�	��L��#��5�+�.�.�
$��{�K�8�8�
$���w��-�-�9�
"�&�%�+�6�6�K��&�&�&���w�&�&�;�%�/�+I�+I�%�k�3E�F�F�F��-�.�.��)�-�e�\�B�B�)�5�K]�)��(�	�"�"Q�"Q�"Q�"Q�y�"Q�"Q�"Q�Q�Q����$6�7�7�	��L��'�(�(��%�$���&�&���S�S�S�S�U�S�S�S�S�S�
���
�.�.�	��L�����-�e�[�A�A��(��)9�8�D�D������|�|�E�5�)�)�H��(�C� � ���(�#�#�#��r?r1�
parametersc
��t|��}t|j��}||kr*||krdnd}td|�d|j�d|�d|�����dS)N�many�fewzToo z parameters for z	; actual z, expected )r8r0rXr[)r1r��actual�expected�descriptions     r=r\r\Msv��
��_�_�F��3�%�&�&�H�
���� &�� 1� 1�f�f�u���p�{�p�p�C�L�p�p�SY�p�p�fn�p�p�q�q�q��r?�
DictValuesrHc#�K�t|t��r|V�dSt|d��r3t|��s$t	|t
��r|jEd{V��dSt|ttf��r|D]}t|��Ed{V���dSt|��}|D]}t|��Ed{V���dS)zdRecursively iterate through all subtypes and type args of `v` and yield any typevars that are found.r0N)r9rrZrr"r*r0r�r:rkr)rH�varr<r�s    r=rkrkXs�����!�W���
4�������	��$�	%�	%�4�j��m�m�4�@R�ST�Vb�@c�@c�4��#�#�#�#�#�#�#�#�#�#�	�A�
�D�)�	*�	*�4��	4�	4�C�.�s�3�3�3�3�3�3�3�3�3�3�	4�	4���{�{���	4�	4�C�.�s�3�3�3�3�3�3�3�3�3�3�	4�	4r?c���	tjd��}n.#t$r}td��|�d}~wt$rYdSwxYw|j}|�d��|j|ufS)z�
    Used inside a function to check whether it was called globally

    Will only work against non-compiled code, therefore used only in pydantic.generics

    :returns Tuple[module_name, called_globally]
    r7z2This function must be used inside another functionN)NFr[)rf�	_getframe�
ValueError�RuntimeError�AttributeError�	f_globalsrV�f_locals)�previous_caller_frame�e�
frame_globalss   r=rcrcgs���� #�
�a� 0� 0�����X�X�X��O�P�P�VW�W����������{�{�����)�3�M����Z�(�(�*?�*H�M�*Y�Y�Ys��
A�1�
A�Arvrsrrrnc�N�|j���D]�\}}||vr|jjtusJ��|jjtusJ|jj���||}t||��}||_||_|���||j|<��dS)zP
    Replace DeferredType fields with concrete type hints and prepare them.
    N)	rKrbr��	__class__rr��outer_type_�preparer�)rvrsrrrnr��field�field_type_hint�
concrete_types        r=rlrlys���$�.�4�4�6�6�
;�
;�
��U��f����;�(��<�<�<�<���{�$��4�4�4�e�k�6K�4�4�4�-�c�2��%�o�|�D�D�
�#���)���
�
�
����-:�
�%�c�*�*�
;�
;r?)@rfr�r�rrrrrrr	r
rrr
rrrr�weakrefrr�typing_extensionsrrr��class_validatorsrrsr�mainrrrrrrrr �utilsr!r"r�r&r)r�rTr��GenericTypesCache�AssignedParametersrUrer*r�r\r`r�r�r�rkr�r�rc�typerlr.r?r=�<module>r�s��
�
�
�
�
�����
�
�
�
�����������������������������������";�:�:�:�:�:�:�:�>�>�>�>�>�>�>�>�3�3�3�3�3�3� � � � � � �)�)�)�)�)�)�)�)�������Z�Z�Z�Z�Z�Z�Z�Z�Z�Z�Z�Z�Z�Z�4�4�4�4�4�4�4�4���w���)�)�)�)�)�)���v������������~�>�>�>�
�����c��C��s�C�x��0�1���+�t�C�y�0�1����v���+�H�d�9�o�,E�F��*�4�	�?�O�+K�L���+��*��)�(�*�*��*�)�+�+��xF�xF�xF�xF�xF�9�xF�xF�xF�vO��O���S��(9�O�c�O�O�O�O�dr��\� 2�r��c�3�h��r�TX�r�r�r�r��	�	���-�
�D��I�-�-�-�4�s�4�x��'<�4�4�4�4�Z�u�X�c�]�D�%8�9�Z�Z�Z�Z�$;���%�;��C��H��;�!��d��+�;��#�t�)�$�	;�

�;�;�;�;�;�;r?

?>