
    dh                    <   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r1ddlmZ ddlmZ  edeef       G d dej<                               Znej<                  ZdZ  ed      Z! G d dee	e!   e      Z"y)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                      e Zd Zy)_RootModelMetaclassN)__name__
__module____qualname__     F/var/www/zara/venv/lib/python3.12/site-packages/pydantic/root_model.pyr   r      s    CFr   r   )	RootModelRootModelRootTypec                       e Zd ZU dZdZdZdZded<    fdZe	fddZ
de
_        edd fd       Zdd	Zdd
ZddZdddZer+ddddddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZd fdZddZ xZS )r    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                x    | j                   j                  d      }|t        dd      t        |   di | y )Nextraz<`RootModel` does not support setting `model_config['extra']`zroot-model-extra)coder   )model_configgetr   super__init_subclass__)clskwargsr%   	__class__s      r   r*   zRootModel.__init_subclass__4   sD      $$W-#NUg  	!+F+r   c               p    d}|r|t         urt        d      |}| j                  j                  ||        y )NTz_"RootModel.__init__" accepts either a single positional argument or arbitrary keyword arguments)self_instance)r   
ValueError__pydantic_validator__validate_python)selfr#   data__tracebackhide__s       r   __init__zRootModel.__init__<   sD     ,, u  D##33D3Mr   c                &    t         |   ||      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#   _fields_set)r)   model_construct)r+   r#   r8   r-   s      r   r9   zRootModel.model_constructH   s     w&Dk&JJr   c                4    | j                   | j                  dS )N__dict____pydantic_fields_set__r;   r3   s    r   __getstate__zRootModel.__getstate__X   s    '+'C'C
 	
r   c                D    t        | d|d          t        | d|d          y )Nr=   r<   )r   )r3   states     r   __setstate__zRootModel.__setstate__^   s&    7?X9YZj%
*;<r   c                    t        |       }|j                  |      }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=   )r3   r+   ms      r   __copy__zRootModel.__copy__b   sK    4jKK:tDMM':;4d4;W;W6XYr   c                    t        |       }|j                  |      }t        |dt        | j                  |             t        |dt        | j                               |S )z!Returns a deep copy of the model.r<   )memor=   )rD   rE   r   r   r<   r   r=   )r3   rI   r+   rF   s       r   __deepcopy__zRootModel.__deepcopy__j   sO    4jKK:xD'IJ 	4d4;W;W6XYr   pythonF)modeincludeexcludecontextby_aliasexclude_unsetexclude_defaultsexclude_noneexclude_computed_fields
round_tripwarningsserialize_as_anyc                    y)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   )r3   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   s                r   
model_dumpzRootModel.model_dumpv   s    6 r   c                    t        |t              st        S | j                  d   j                  |j                  d   j                  k(  xr t
        |   |      S Nr#   )
isinstancer    NotImplemented__pydantic_fields__
annotationr)   __eq__)r3   otherr-   s     r   r`   zRootModel.__eq__   sW    %+!!''/::e>W>W?

* /.	/r   c              #  ,   K   d| j                   f y wr[   )r#   r>   s    r   __repr_args__zRootModel.__repr_args__   s     diis   )r#   r!   returnNone)N)r#   r!   r8   zset[str] | Nonerd   r   )rd   dict[Any, Any])rA   rf   rd   re   )rd   r   )rI   zdict[int, Any] | Nonerd   r   )rL   zLiteral['json', 'python'] | strrM   r   rN   r   rO   zdict[str, Any] | NonerP   zbool | NonerQ   boolrR   rg   rS   rg   rT   rg   rU   rg   rV   z'bool | Literal['none', 'warn', 'error']rW   rg   rd   r   )ra   r   rd   rg   )rd   z_repr.ReprArgs)r   r   r   __doc____pydantic_root_model____pydantic_private____pydantic_extra____annotations__r*   r   r6   __pydantic_base_init__classmethodr9   r?   rB   rG   rJ   r   rY   r`   rc   __classcell__)r-   s   @r   r    r        s!    #
, 5F N '+H#K K
= 
 5=-1$("'%*!&,1$@D%*	 2	 		
 	 +	 "	  	 #	 	 &*	 	 >	 #	 	:/ r   r    )	metaclassN)#rh   
__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   <module>r~      s    + 2  @ @ + 7  1 ,3?
 BTVnAopF1@@F qF-<<
/0 { 	7#45AT { r   