a
    “˜ë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rÄ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	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   úR/mnt/bigstor/www/usecases/.venv/lib/python3.9/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	œd
d„Z
de
_ed0ddddœ‡ fdd„ƒZddœdd„Zdddœdd„Zddœdd„Zd1dddœdd„Zerèddddddd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 )2r   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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__r   r   r"   4   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)Úselfr   ÚdataZ__tracebackhide__r   r   r   Ú__init__<   s    ÿzRootModel.__init__zset[str] | Noner   )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.   H   s    zRootModel.model_constructzdict[Any, Any])r(   c                 C  s   | j | jdœS )N©Ú__dict__Ú__pydantic_fields_set__r/   ©r*   r   r   r   Ú__getstate__X   s    þzRootModel.__getstate__)Ústater(   c                 C  s$   t | d|d ƒ t | d|d ƒ d S )Nr1   r0   )r   )r*   r4   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   r0   r1   )ÚtypeÚ__new__r   r0   r   r1   )r*   r#   ÚmZnew_dictr   r   r   Ú__copy__b   s    

zRootModel.__copy__zdict[int, Any] | None)Úmemor(   c                 C  s>   t | ƒ}| |¡}t|dt| j|d�ƒ t|dt| jƒƒ |S )z!Returns a deep copy of the model.r0   )r:   r1   )r6   r7   r   r   r0   r   r1   )r*   r:   r#   r8   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_anyzLiteral['json', 'python'] | strr   zdict[str, Any] | Nonezbool | NoneÚboolz'bool | Literal['none', 'warn', 'error'])r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   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.

            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=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   r   r   r   Ú
model_dumpx   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__pydantic_fields__Ú
annotationr!   Ú__eq__)r*   rK   r%   r   r   rP   •   s    
ÿ
þzRootModel.__eq__z_repr.ReprArgsc                 c  s   d| j fV  d S rL   )r   r2   r   r   r   Ú__repr_args__œ   s    zRootModel.__repr_args__)N)N)r   r   r   Ú__doc__Z__pydantic_root_model__Z__pydantic_private__Z__pydantic_extra__Ú__annotations__r"   r
   r,   Z__pydantic_base_init__Úclassmethodr.   r3   r5   r9   r;   r   rJ   rP   rQ   Ú__classcell__r   r   r%   r   r       s<   



ò*r   )Ú	metaclassN)#rR   Ú
__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"   