o
    }j6h                     @  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mZ dd	lmZmZ ejradd
lmZmZ ddlmZmZ d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j!e  edZ"dS )z%RootModel class and type definitions.    )annotationsN)copydeepcopy)PydanticUndefined   )PydanticUserError)_model_construction_repr)	BaseModel_object_setattr)AnyLiteral)Selfdataclass_transform)Field)PrivateAttrF)kw_only_defaultfield_specifiersc                   @  s   e Zd ZdS )_RootModelMetaclassN)__name__
__module____qualname__ r   r   b/var/www/html/chefvision.cloud.itp360.com/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d9d
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jrUddddddddddddd@d1d2ZdA fd4d5ZdBd7d8Z  ZS )Cr   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"   7   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   r1   )r!   model_construct)r#   r   r1   r%   r   r   r3   K   s   zRootModel.model_constructdict[Any, Any]c                 C  s   | j | jdS )N__dict____pydantic_fields_set__r5   r-   r   r   r   __getstate__[   s   zRootModel.__getstate__statec                 C  s$   t | d|d  t | d|d  d S )Nr7   r6   )r   )r-   r:   r   r   r   __setstate__a   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.r6   r7   )type__new__r   r   r6   r7   )r-   r#   mr   r   r   __copy__e   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.r6   )r@   r7   )r<   r=   r   r   r6   r   r7   )r-   r@   r#   r>   r   r   r   __deepcopy__m   s
   
zRootModel.__deepcopy__pythonF)modeincludeexcludecontextby_aliasexclude_unsetexclude_defaultsexclude_none
round_tripwarningsserialize_as_anyrD   Literal['json', 'python'] | strrE   r   rF   rG   dict[str, Any] | NonerH   bool | NonerI   boolrJ   rK   rL   rM   'bool | Literal['none', 'warn', 'error']rN   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   )r-   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   r   r   r   
model_dumpy   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__)r-   rU   r%   r   r   r[      s   

zRootModel.__eq___repr.ReprArgsc                 c  s    d| j fV  d S rV   )r   r8   r   r   r   __repr_args__   s   zRootModel.__repr_args__)r   r   r'   r(   )N)r   r   r1   r2   r'   r   )r'   r4   )r:   r4   r'   r(   )r'   r   )r@   rA   r'   r   )rD   rO   rE   r   rF   r   rG   rP   rH   rQ   rI   rR   rJ   rR   rK   rR   rL   rR   rM   rS   rN   rR   r'   r   )rU   r   r'   rR   )r'   r\   )r   r   r   __doc____pydantic_root_model____pydantic_private____pydantic_extra____annotations__r"   r   r0   __pydantic_base_init__classmethodr3   r9   r;   r?   rB   typingTYPE_CHECKINGrT   r[   r]   __classcell__r   r   r%   r   r   #   s<   
 




r   )	metaclass)#r^   
__future__r   _annotationsre   r   r   pydantic_corer    r   	_internalr   r	   mainr
   r   rf   r   r   typing_extensionsr   r   fieldsr   PydanticModelFieldr   PydanticModelPrivateAttrModelMetaclassr   __all__TypeVarr   Genericr   r   r   r   r   <module>   s&    
 