a
    y{JhU                     @  s   d Z ddlmZ ddl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mZ ejrdd
lmZ ddlmZ ejdddZdZedZG dd deeje ZdS )z%RootModel class and type definitions.    )annotationsN)copydeepcopy)PydanticUndefined   )PydanticUserError)_repr)	BaseModel_object_setattr)Any)LiteralModelr	   )bound)	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	d
dZ
de
_ed/ddddd fddZddddZdddddZdddddZd0ddddddZejrd ddd!d!d!d!d!dd"	d#d$d$d%d%d%d%d%d%dd&
d'd(Zd$d%d) fd*d+Zd,dd-d.Z  ZS )1r   a  Usage docs: https://docs.pydantic.dev/2.5/concepts/models/#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f i | d S )Nextraz<`RootModel` does not support setting `model_config['extra']`zroot-model-extra)code)Zmodel_configgetr   super__init_subclass__)clskwargsr   	__class__ E/var/www/shaz/venv/lib/python3.9/site-packages/pydantic/root_model.pyr   /   s    zRootModel.__init_subclass__None)r   returnc                 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)Zself_instance)r   
ValueErrorZ__pydantic_validator__Zvalidate_python)Z__pydantic_self__r   dataZ__tracebackhide__r   r   r   __init__7   s    zRootModel.__init__ztype[Model]zset[str] | Noner   )r   r   _fields_setr   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   r"   )r   model_construct)r   r   r"   r   r   r   r#   C   s    zRootModel.model_constructzdict[Any, Any])r   c                 C  s   | j | jdS )N__dict____pydantic_fields_set__r$   selfr   r   r   __getstate__S   s    zRootModel.__getstate__)stater   c                 C  s$   t | d|d  t | d|d  d S )Nr&   r%   )r
   )r(   r*   r   r   r   __setstate__Y   s    zRootModel.__setstate__)r(   r   c                 C  s:   t | }||}t|dt| j t|dt| j |S )z$Returns a shallow copy of the model.r%   r&   )type__new__r
   r   r%   r&   )r(   r   mr   r   r   __copy__]   s
    
zRootModel.__copy__zdict[int, Any] | None)r(   memor   c                 C  s>   t | }||}t|dt| j|d t|dt| j |S )z!Returns a deep copy of the model.r%   )r0   r&   )r,   r-   r
   r   r%   r   r&   )r(   r0   r   r.   r   r   r   __deepcopy__e   s
    
zRootModel.__deepcopy__pythonF)	modeincludeexcludeby_aliasexclude_unsetexclude_defaultsexclude_none
round_tripwarningszLiteral['json', 'python'] | strr   bool)
r3   r4   r5   r6   r7   r8   r9   r:   r;   r   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.
            Nr   )
r(   r3   r4   r5   r6   r7   r8   r9   r:   r;   r   r   r   
model_dumpq   s    zRootModel.model_dump)otherr   c                   s2   t |tstS | jd j|jd jko0t |S Nr   )
isinstancer   NotImplementedZmodel_fields
annotationr   __eq__)r(   r>   r   r   r   rC      s    
zRootModel.__eq__z_repr.ReprArgsc                 c  s   d| j fV  d S r?   )r   r'   r   r   r   __repr_args__   s    zRootModel.__repr_args__)N)N)__name__
__module____qualname____doc__Z__pydantic_root_model__Z__pydantic_private__Z__pydantic_extra____annotations__r   r   r!   Z__pydantic_base_init__classmethodr#   r)   r+   r/   r1   typingTYPE_CHECKINGr=   rC   rD   __classcell__r   r   r   r   r      s6   


$r   )rH   
__future__r   Z_annotationsrK   r   r   Zpydantic_corer    r   	_internalr   mainr	   r
   rL   r   typing_extensionsr   TypeVarr   __all__r   Genericr   r   r   r   r   <module>   s   
