o
    Ú­jú  ã                   @  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   úP/var/www/html/CropPilot/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  sP   t | ƒ}| |¡}t| jƒ}t| jd ƒ|d< t|d|ƒ t|dt| jƒƒ |S )z$Returns a shallow copy of the model.r   r9   r:   )ÚtypeÚ__new__r   r9   r   r:   )r0   r&   ÚmÚnew_dictr   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   )rD   r:   )r?   r@   r   r   r9   r   r:   )r0   rD   r&   rA   r   r   r   Ú__deepcopy__l   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_anyrH   úLiteral['json', 'python'] | strrI   r   rJ   rK   údict[str, Any] | NonerL   úbool | NonerM   ÚboolrN   rO   rP   rQ   rR   ú'bool | Literal['none', 'warn', 'error']rS   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   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   r   r   r   Ú
model_dumpx   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   rZ   r(   r   r   r`   •   s   
ÿþ
þzRootModel.__eq__ú_repr.ReprArgsc                 c  s   � d| j fV  d S r[   )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   )rD   rE   r*   r   )rH   rT   rI   r   rJ   r   rK   rU   rL   rV   rM   rW   rN   rW   rO   rW   rP   rW   rQ   rW   rR   rX   rS   rW   r*   r   )rZ   r   r*   rW   )r*   ra   )r   r   r   Ú__doc__Ú__pydantic_root_model__Ú__pydantic_private__Ú__pydantic_extra__Ú__annotations__r%   r
   r3   Ú__pydantic_base_init__Úclassmethodr6   r<   r>   rC   rF   r   rY   r`   rb   Ú__classcell__r   r   r(   r   r       s>   
 





òr   )Ú	metaclassN)#rc   Ú
__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$    