o
    3h                     @  s   d Z ddlmZ ddlmZ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mZ ddlmZ dd	lmZmZ dd
lmZmZ erbddlmZ ddlmZ edeefdG dd dejZnejZdZ edZ!G dd dee	e! edZ"dS )z%RootModel class and type definitions.    )annotations)copydeepcopy)TYPE_CHECKINGAnyGenericLiteralTypeVar)PydanticUndefined)Selfdataclass_transform   )PydanticUserError)_model_construction_repr)	BaseModel_object_setattr)Field)PrivateAttrF)kw_only_defaultfield_specifiersc                   @  s   e Zd ZdS )_RootModelMetaclassN)__name__
__module____qualname__ r   r   N/var/www/html/chatgem/venv/lib/python3.10/site-packages/pydantic/root_model.pyr      s    r   )	RootModelRootModelRootTypec                      s   e Zd ZU dZdZdZdZded<  fddZe	fd:d
dZ
de
_ed;d< fddZd=ddZd>ddZd?ddZd;d@ddZerUddddddddddddddAd2d3ZdB fd5d6ZdCd8d9Z  ZS )Dr   a  !!! abstract "Usage Documentation"
        [`RootModel` and Custom Root Types](../concepts/models.md#rootmodel-and-custom-root-types)

    A Pydantic `BaseModel` for the root object of the model.

    Attributes:
        root: The root object of the model.
        __pydantic_root_model__: Whether the model is a RootModel.
        __pydantic_private__: Private fields in the model.
        __pydantic_extra__: Extra fields in the model.

    TNr   rootc                   s6   | j d}|d urtdddt jdi | d S )Nextraz<`RootModel` does not support setting `model_config['extra']`zroot-model-extra)coder   )model_configgetr   super__init_subclass__)clskwargsr    	__class__r   r   r%   4   s   zRootModel.__init_subclass__returnNonec                K  s0   d}|r|t urtd|}| jj|| d d S )NTz_"RootModel.__init__" accepts either a single positional argument or arbitrary keyword arguments)self_instance)r
   
ValueError__pydantic_validator__validate_python)selfr   data__tracebackhide__r   r   r   __init__<   s   zRootModel.__init___fields_setset[str] | Noner   c                   s   t  j||dS )aS  Create a new model using the provided root object and update fields set.

        Args:
            root: The root object of the model.
            _fields_set: The set of fields to be updated.

        Returns:
            The new model.

        Raises:
            NotImplemented: If the model is not a subclass of `RootModel`.
        )r   r4   )r$   model_construct)r&   r   r4   r(   r   r   r6   H   s   zRootModel.model_constructdict[Any, Any]c                 C  s   | j | jdS )N__dict____pydantic_fields_set__r8   r0   r   r   r   __getstate__X   s   zRootModel.__getstate__statec                 C  s$   t | d|d  t | d|d  d S )Nr:   r9   )r   )r0   r=   r   r   r   __setstate__^   s   zRootModel.__setstate__c                 C  s:   t | }||}t|dt| j t|dt| j |S )z$Returns a shallow copy of the model.r9   r:   )type__new__r   r   r9   r:   )r0   r&   mr   r   r   __copy__b   s
   
zRootModel.__copy__memodict[int, Any] | Nonec                 C  s>   t | }||}t|dt| j|d t|dt| j |S )z!Returns a deep copy of the model.r9   )rC   r:   )r?   r@   r   r   r9   r   r:   )r0   rC   r&   rA   r   r   r   __deepcopy__j   s
   
zRootModel.__deepcopy__pythonF)modeincludeexcludecontextby_aliasexclude_unsetexclude_defaultsexclude_noneexclude_computed_fields
round_tripwarningsserialize_as_anyrG   Literal['json', 'python'] | strrH   r   rI   rJ   dict[str, Any] | NonerK   bool | NonerL   boolrM   rN   rO   rP   rQ   'bool | Literal['none', 'warn', 'error']rR   c                C  s   dS )a  This method is included just to get a more accurate return type for type checkers.
            It is included in this `if TYPE_CHECKING:` block since no override is actually necessary.

            See the documentation of `BaseModel.model_dump` for more details about the arguments.

            Generally, this method will have a return type of `RootModelRootType`, assuming that `RootModelRootType` is
            not a `BaseModel` subclass. If `RootModelRootType` is a `BaseModel` subclass, then the return
            type will likely be `dict[str, Any]`, as `model_dump` calls are recursive. The return type could
            even be something different, in the case of a custom serializer.
            Thus, `Any` is used here to catch all of these cases.
            Nr   )r0   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   r   r   r   
model_dumpv   s   zRootModel.model_dumpotherc                   s2   t |tstS | jd j|jd jkot |S Nr   )
isinstancer   NotImplemented__pydantic_fields__
annotationr$   __eq__)r0   rY   r(   r   r   r_      s   

zRootModel.__eq___repr.ReprArgsc                 c  s    d| j fV  d S rZ   )r   r;   r   r   r   __repr_args__   s   zRootModel.__repr_args__)r   r   r*   r+   )N)r   r   r4   r5   r*   r   )r*   r7   )r=   r7   r*   r+   )r*   r   )rC   rD   r*   r   )rG   rS   rH   r   rI   r   rJ   rT   rK   rU   rL   rV   rM   rV   rN   rV   rO   rV   rP   rV   rQ   rW   rR   rV   r*   r   )rY   r   r*   rV   )r*   r`   )r   r   r   __doc____pydantic_root_model____pydantic_private____pydantic_extra____annotations__r%   r
   r3   __pydantic_base_init__classmethodr6   r<   r>   rB   rE   r   rX   r_   ra   __classcell__r   r   r(   r   r       s>   
 




r   )	metaclassN)#rb   
__future__r   _annotationsr   r   typingr   r   r   r   r	   pydantic_corer
   typing_extensionsr   r    r   	_internalr   r   mainr   r   fieldsr   PydanticModelFieldr   PydanticModelPrivateAttrModelMetaclassr   __all__r   r   r   r   r   r   <module>   s$    