o
    i                     @  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)Zkw_only_defaultZfield_specifiersc                   @  s   e Zd ZdS )_RootModelMetaclassN)__name__
__module____qualname__ r   r   M/home/kim/smarthome/.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   )Z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)Zself_instance)r
   
ValueErrorZ__pydantic_validator__Zvalidate_python)selfr   dataZ__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   r-   )r!   model_construct)r#   r   r-   r%   r   r   r/   H   s   zRootModel.model_constructdict[Any, Any]c                 C  s   | j | jdS )N__dict____pydantic_fields_set__r1   r*   r   r   r   __getstate__X   s   zRootModel.__getstate__statec                 C  s$   t | d|d  t | d|d  d S )Nr3   r2   )r   )r*   r6   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.r2   r3   )type__new__r   r   r2   r3   )r*   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.r2   )r<   r3   )r8   r9   r   r   r2   r   r3   )r*   r<   r#   r:   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_anyr@   Literal['json', 'python'] | strrA   r   rB   rC   dict[str, Any] | NonerD   bool | NonerE   boolrF   rG   rH   rI   rJ   'bool | Literal['none', 'warn', 'error']rK   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*   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   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   NotImplementedZ__pydantic_fields__
annotationr!   __eq__)r*   rR   r%   r   r   rW      s   

zRootModel.__eq___repr.ReprArgsc                 c  s    d| j fV  d S rS   )r   r4   r   r   r   __repr_args__   s   zRootModel.__repr_args__)r   r   r'   r(   )N)r   r   r-   r.   r'   r   )r'   r0   )r6   r0   r'   r(   )r'   r   )r<   r=   r'   r   )r@   rL   rA   r   rB   r   rC   rM   rD   rN   rE   rO   rF   rO   rG   rO   rH   rO   rI   rO   rJ   rP   rK   rO   r'   r   )rR   r   r'   rO   )r'   rX   )r   r   r   __doc__Z__pydantic_root_model__Z__pydantic_private__Z__pydantic_extra____annotations__r"   r
   r,   Z__pydantic_base_init__classmethodr/   r5   r7   r;   r>   r   rQ   rW   rY   __classcell__r   r   r%   r   r       s>   
 




r   )	metaclassN)#rZ   
__future__r   Z_annotationsr   r   typingr   r   r   r   r	   Zpydantic_corer
   Ztyping_extensionsr   r    r   	_internalr   r   mainr   r   fieldsr   ZPydanticModelFieldr   ZPydanticModelPrivateAttrZModelMetaclassr   __all__r   r   r   r   r   r   <module>   s$    