o
    $6d9                     @  s:  U d Z ddlmZ ddlZddlZddlZddlmZmZ ddlm	Z	m
Z
 ddlZddlZddlmZ ddlmZmZmZmZmZmZmZmZmZmZmZ dd	lmZ dd
l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(m)Z) ddl*m+Z+m,Z,m-Z-m.Z.m/Z/ ddlm0Z0 ej1rddl2m3Z3 ddl4m5Z5 ddlm6Z6m7Z7m8Z8 ddlm9Z9m:Z: ddl;m<Z<m=Z= ddl&m>Z? e@e	e	e	f ZAejBejCeDe	f ddf ZEejFdddZGdZHdeId< ne0ZJdZKejLZMG dd dejNdZOejPddeQddd d;d0d1ZRejPdeQddd2d<d5d1ZRddeQdddd6d=d:d1ZReeQZSdS )>zLogic for creating models.    )annotationsN)copydeepcopy)AnyClassVarPydanticUndefined   )_annotated_handlers_config_decorators_fields_forward_ref	_generics_mock_val_ser_model_construction_repr_typing_extra_utils)getattr_migration)
ConfigDict)copy_internals)parse)PydanticUndefinedAnnotationPydanticUserError)ComputedFieldInfo	FieldInfoModelPrivateAttr)DEFAULT_REF_TEMPLATEGenerateJsonSchemaJsonSchemaModeJsonSchemaValuemodel_json_schema)PydanticDeprecatedSince20)	Signature)Path)
CoreSchemaSchemaSerializerSchemaValidator)LiteralUnpack)AbstractSetIntStrMappingIntStrAny)FieldModel	BaseModel)boundz<set[int] | set[str] | dict[int, Any] | dict[str, Any] | Noneztyping_extensions.TypeAliasIncEx)r/   create_modelc                
      s  e Zd ZU dZejrdded< 	 ded< 	 ded< ded	< d
ed< ded< ded< ded< ded< ded< ded< ded< ded< ded< ded< eddZd ed!< eddZ	d"ed#< eddZ
d ed$< ni Ze Zejd%d&d'd(Zejd%d)d'd(Zd*Ze ZdZdZdd/d0Zd1e_edd3d4Zedd5d6Zedd7d8Zeddd@dAZd9ddBddGdHZ dId9d9dddddd1dJ	ddWdXZ!d9d9d9dddddd1dY	dd]d^Z"ed1e#e$d_fddddeZ%eddhdiZ&ddkdlZ'edd1dmd9dnddudvZ(ed9d9d9dwdd|d}Z)ed9d9d~dddZ*edddZ+edddZ,edddZ-dddZ.d ddZ/dd!ddZ0ejsTd" fddZ1d#ddZ2d"ddZ3d$ddZ4d%ddZ5d&ddZ6ejr|d'ddZ7d(ddZ8d)ddZ9d*ddZ:e;j<j=Z=e;j<j>Z>e;j<j?Z?e;j<j@Z@d)ddZAeeBjCdeDdd+ddZEeeBjCdeDddddÄZFeBjCdeDdd9d9dddddŜd,ddȄZGeBjCdeDdd9d9ddddeHeHdʜd-ddЄZIeeBjCdeDdd.ddӄZJeeBjCdeDdd9dd9dd֜d/ddZKeeBjCdeDdd9dd9dd֜d0ddZLeeBjCdeDdd.ddZMeeBjCdeDdddddZNeBjCdeDdd9d9d9ddd1ddZOeeBjCdeDdd1e#fd2ddZPeeBjCdeDdd1e#dd3ddZQeeBjCdeDdd4ddZReeBjCdeDdd5ddZSeBjCd eDdd6ddZTeBjCdeDdd6ddZUeeBjCdeDdd6dd	ZVeBjCd
eDdd6ddZW  ZXS (7  r/   a  Usage docs: https://docs.pydantic.dev/2.2/usage/models/

    A base class for creating Pydantic models.

    Attributes:
        __class_vars__: The names of classvars defined on the model.
        __private_attributes__: Metadata about the private attributes of the model.
        __signature__: The signature for instantiating the model.

        __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
        __pydantic_core_schema__: The pydantic-core schema used to build the SchemaValidator and SchemaSerializer.
        __pydantic_custom_init__: Whether the model has a custom `__init__` function.
        __pydantic_decorators__: Metadata containing the decorators defined on the model.
            This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
        __pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
            __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
        __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
        __pydantic_post_init__: The name of the post-init method for the model, if defined.
        __pydantic_root_model__: Whether the model is a `RootModel`.
        __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the model.
        __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the model.

        __pydantic_extra__: An instance attribute with the values of extra fields from validation when
            `model_config['extra'] == 'allow'`.
        __pydantic_fields_set__: An instance attribute with the names of fields explicitly specified during validation.
        __pydantic_private__: Instance attribute with the values of private attributes set on the model instance.
    zClassVar[ConfigDict]model_configzClassVar[dict[str, FieldInfo]]model_fieldszClassVar[set[str]]__class_vars__z%ClassVar[dict[str, ModelPrivateAttr]]__private_attributes__zClassVar[Signature]__signature__zClassVar[bool]__pydantic_complete__zClassVar[CoreSchema]__pydantic_core_schema__Z__pydantic_custom_init__z$ClassVar[_decorators.DecoratorInfos]__pydantic_decorators__z+ClassVar[_generics.PydanticGenericMetadata]__pydantic_generic_metadata__zClassVar[dict[str, Any] | None]__pydantic_parent_namespace__z+ClassVar[None | Literal['model_post_init']]__pydantic_post_init____pydantic_root_model__zClassVar[SchemaSerializer]__pydantic_serializer__zClassVar[SchemaValidator]__pydantic_validator__F)initdict[str, Any] | None__pydantic_extra__set[str]__pydantic_fields_set____pydantic_private__zXPydantic models should inherit from BaseModel, BaseModel cannot be instantiated directly	validatorzbase-model-instantiated)Z
val_or_sercode
serializer)__dict__rE   rC   rF   datar   returnNonec                 K  s   d}| j j|| d dS )aj  Create a new model by parsing and validating input data from keyword arguments.

        Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be
        validated to form a valid model.

        `__init__` uses `__pydantic_self__` instead of the more common `self` for the first arg to
        allow `self` as a field name.
        T)Zself_instanceNr@   Zvalidate_python)Z__pydantic_self__rK   __tracebackhide__ rP   dC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\pydantic/main.py__init__   s   
zBaseModel.__init__Tdict[str, ComputedFieldInfo]c                 C  s   dd | j j D S )zGet the computed fields of this model instance.

        Returns:
            A dictionary of computed field names and their corresponding `ComputedFieldInfo` objects.
        c                 S  s   i | ]\}}||j qS rP   )info.0kvrP   rP   rQ   
<dictcomp>   s    z3BaseModel.model_computed_fields.<locals>.<dictcomp>)r:   Zcomputed_fieldsitemsselfrP   rP   rQ   model_computed_fields   s   zBaseModel.model_computed_fieldsc                 C     | j S )zGet extra fields set during validation.

        Returns:
            A dictionary of extra fields, or `None` if `config.extra` is not set to `"allow"`.
        )rC   r[   rP   rP   rQ   model_extra   s   zBaseModel.model_extrac                 C  r^   )zReturns the set of fields that have been set on this model instance.

        Returns:
            A set of strings representing the fields that have been set,
                i.e. that were not filled from defaults.
        )rE   r[   rP   rP   rQ   model_fields_set   s   zBaseModel.model_fields_setNclstype[Model]_fields_setset[str] | Nonevaluesr.   c                 K  s(  |  | }i }i }| j D ]-\}}|jr#|j|v r#||j||< q||v r/||||< q| s;|jdd||< q|du rFt| }|	| d}| j
ddkrei }| D ]\}	}
|
||	< q[n|	| t|d| t|d| | jst|d| | jr|d |S | jst|d	d |S )
aS  Creates a new instance of the `Model` class with validated data.

        Creates a new model setting `__dict__` and `__pydantic_fields_set__` from trusted or pre-validated data.
        Default values are respected, but no other validation is performed.
        Behaves as if `Config.extra = 'allow'` was set since it adds all passed values

        Args:
            _fields_set: The set of field names accepted for the Model instance.
            values: Trusted or pre-validated data dictionary.

        Returns:
            A new instance of the `Model` class with validated data.
        T)Zcall_default_factoryNextraallowrJ   rE   rC   rF   )__new__r4   rZ   aliaspopZis_requiredZget_defaultsetkeysupdater3   get_object_setattrr>   r=   model_post_init)ra   rc   re   mZfields_valuesdefaultsnamefield_extrarW   rX   rP   rP   rQ   model_construct   s>   




zBaseModel.model_construct)rm   deepr\   rm   rw   boolc                C  s   |r|   n|  }|rD| jddkr6| D ]\}}|| jv r'||j|< q|jdu r/i |_||j|< qn|j| |j	|
  |S )a  Usage docs: https://docs.pydantic.dev/2.2/usage/serialization/#model_copy

        Returns a copy of the model.

        Args:
            update: Values to change/add in the new model. Note: the data is not validated
                before creating the new model. You should trust this data.
            deep: Set to `True` to make a deep copy of the model.

        Returns:
            New model instance.
        rf   rg   N)__deepcopy____copy__r3   rn   rZ   r4   rJ   rC   rm   rE   rl   )r\   rm   rw   ZcopiedrW   rX   rP   rP   rQ   
model_copy   s   

zBaseModel.model_copypython)	modeincludeexcludeby_aliasexclude_unsetexclude_defaultsexclude_none
round_tripwarningsr}   Literal['json', 'python'] | strr~   r1   r   r   r   r   r   r   r   dict[str, Any]c       	   
      C  s    | j j| |||||||||	d
S )a  Usage docs: https://docs.pydantic.dev/2.2/usage/serialization/#modelmodel_dump

        Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

        Args:
            mode: The mode in which `to_python` should run.
                If mode is 'json', the dictionary will only contain JSON serializable types.
                If mode is 'python', the dictionary may contain any Python objects.
            include: A list of fields to include in the output.
            exclude: A list of fields to exclude from the output.
            by_alias: Whether to use the field's alias in the dictionary key if defined.
            exclude_unset: Whether to exclude fields that are unset or None from the output.
            exclude_defaults: Whether to exclude fields that are set to their default value from the output.
            exclude_none: Whether to exclude fields that have a value of `None` from the output.
            round_trip: Whether to enable serialization and deserialization round-trip support.
            warnings: Whether to log warnings when invalid fields are encountered.

        Returns:
            A dictionary representation of the model.
        )	r}   r   r~   r   r   r   r   r   r   )r?   Z	to_python)
r\   r}   r~   r   r   r   r   r   r   r   rP   rP   rQ   
model_dump  s   !zBaseModel.model_dump	indentr~   r   r   r   r   r   r   r   r   
int | Nonestrc       	   
      C  s$   | j j| |||||||||	d
 S )aF  Usage docs: https://docs.pydantic.dev/2.2/usage/serialization/#modelmodel_dump_json

        Generates a JSON representation of the model using Pydantic's `to_json` method.

        Args:
            indent: Indentation to use in the JSON output. If None is passed, the output will be compact.
            include: Field(s) to include in the JSON output. Can take either a string or set of strings.
            exclude: Field(s) to exclude from the JSON output. Can take either a string or set of strings.
            by_alias: Whether to serialize using field aliases.
            exclude_unset: Whether to exclude fields that have not been explicitly set.
            exclude_defaults: Whether to exclude fields that have the default value.
            exclude_none: Whether to exclude fields that have a value of `None`.
            round_trip: Whether to use serialization/deserialization between JSON and class instance.
            warnings: Whether to show any warnings that occurred during serialization.

        Returns:
            A JSON string representation of the model.
        r   )r?   to_jsondecode)
r\   r   r~   r   r   r   r   r   r   r   rP   rP   rQ   model_dump_jsonB  s   zBaseModel.model_dump_jsonZ
validationref_templateschema_generatortype[GenerateJsonSchema]r    c                 C  s   t | ||||dS )a  Generates a JSON schema for a model class.

        Args:
            by_alias: Whether to use attribute aliases or not.
            ref_template: The reference template.
            schema_generator: To override the logic used to generate the JSON schema, as a subclass of
                `GenerateJsonSchema` with your desired modifications
            mode: The mode in which to generate the schema.

        Returns:
            The JSON schema for the given model class.
        )r   r   r   r}   )r"   )ra   r   r   r   r}   rP   rP   rQ   r"   n  s   
zBaseModel.model_json_schemaparamstuple[type[Any], ...]c                 C  s>   t | tjs
tddd |D }d|}| j d| dS )a}  Compute the class name for parametrizations of generic classes.

        This method can be overridden to achieve a custom naming scheme for generic BaseModels.

        Args:
            params: Tuple of types of the class. Given a generic class
                `Model` with 2 type variables and a concrete model `Model[str, int]`,
                the value `(str, int)` would be passed to `params`.

        Returns:
            String representing the new class where `params` are passed to `cls` as type variables.

        Raises:
            TypeError: Raised when trying to generate concrete names for non-generic models.
        z;Concrete names should only be generated for generic models.c                 S  s$   g | ]}t |tr|nt|qS rP   )
isinstancer   r   Zdisplay_as_typerV   paramrP   rP   rQ   
<listcomp>  s   $ z5BaseModel.model_parametrized_name.<locals>.<listcomp>, [])
issubclasstypingGeneric	TypeErrorjoin__name__)ra   r   Zparam_namesZparams_componentrP   rP   rQ   model_parametrized_name  s
   
z!BaseModel.model_parametrized_name_BaseModel__contextc                 C     dS )zOverride this method to perform additional initialization after `__init__` and `model_construct`.
        This is useful if you want to do some validation that requires the entire model to be initialized.
        NrP   )r\   r   rP   rP   rQ   rp     s   zBaseModel.model_post_init   )forceraise_errors_parent_namespace_depth_types_namespacer   r   r   intr   bool | Nonec          	      C  s   |s| j rdS d| jv rt| d |dur| }n-|dkr;tj|dp%i }t| jp-i }i ||}t	|| _nt| j}t
| |}i | jddi}tj| | jtj|dd||dS )	a1  Try to rebuild the pydantic-core schema for the model.

        This may be necessary when one of the annotations is a ForwardRef which could not be resolved during
        the initial attempt to build the schema, and automatic rebuilding fails.

        Args:
            force: Whether to force the rebuilding of the model schema, defaults to `False`.
            raise_errors: Whether to raise errors, defaults to `True`.
            _parent_namespace_depth: The depth level of the parent namespace, defaults to 2.
            _types_namespace: The types namespace, defaults to `None`.

        Returns:
            Returns `None` if the schema is already "complete" and rebuilding was not required.
            If rebuilding _was_ required, returns `True` if rebuilding was successful, otherwise `False`.
        Nr9   r   )Zparent_depthZdefer_buildF)check)r   types_namespace)r8   rJ   delattrr   r   Zparent_frame_namespacer   Zunpack_lenient_weakvaluedictr<   Zbuild_lenient_weakvaluedictZget_cls_types_namespacer3   Zcomplete_model_classr   r   ConfigWrapper)	ra   r   r   r   r   r   Zframe_parent_nsZcls_parent_nsconfigrP   rP   rQ   model_rebuild  s0   



zBaseModel.model_rebuildstrictfrom_attributescontextobjr   r   r   c                C  s   d}| j j||||dS )a  Validate a pydantic model instance.

        Args:
            obj: The object to validate.
            strict: Whether to raise an exception on invalid fields.
            from_attributes: Whether to extract data from object attributes.
            context: Additional context to pass to the validator.

        Raises:
            ValidationError: If the object could not be validated.

        Returns:
            The validated model instance.
        Tr   rN   )ra   r   r   r   r   rO   rP   rP   rQ   model_validate  s   zBaseModel.model_validater   r   	json_datastr | bytes | bytearrayc                C  s   d}| j j|||dS )a  Validate the given JSON data against the Pydantic model.

        Args:
            json_data: The JSON data to validate.
            strict: Whether to enforce types strictly.
            context: Extra variables to pass to the validator.

        Returns:
            The validated Pydantic model.

        Raises:
            ValueError: If `json_data` is not a JSON string.
        Tr   )r@   Zvalidate_json)ra   r   r   r   rO   rP   rP   rQ   model_validate_json  s   zBaseModel.model_validate_json_BaseModel__sourcetype[BaseModel]_BaseModel__handler(_annotated_handlers.GetCoreSchemaHandlerr&   c                 C  s"   d| j v r| jd s| jS ||S )a  Hook into generating the model's CoreSchema.

        Args:
            __source: The class we are generating a schema for.
                This will generally be the same as the `cls` argument if this is a classmethod.
            __handler: Call into Pydantic's internal JSON schema generation.
                A callable that calls into Pydantic's internal CoreSchema generation logic.

        Returns:
            A `pydantic-core` `CoreSchema`.
        r9   origin)rJ   r;   r9   )ra   r   r   rP   rP   rQ   __get_pydantic_core_schema__  s   

z&BaseModel.__get_pydantic_core_schema___BaseModel__core_schema(_annotated_handlers.GetJsonSchemaHandlerr!   c                 C  s   ||S )ac  Hook into generating the model's JSON schema.

        Args:
            __core_schema: A `pydantic-core` CoreSchema.
                You can ignore this argument and call the handler with a new CoreSchema,
                wrap this CoreSchema (`{'type': 'nullable', 'schema': current_schema}`),
                or just call the handler with the original schema.
            __handler: Call into Pydantic's internal JSON schema generation.
                This will raise a `pydantic.errors.PydanticInvalidForJsonSchema` if JSON schema
                generation fails.
                Since this gets called by `BaseModel.model_json_schema` you can override the
                `schema_generator` argument to that function to change JSON schema generation globally
                for a type.

        Returns:
            A JSON schema, as a Python object.
        rP   )ra   r   r   rP   rP   rQ   __get_pydantic_json_schema__/  s   z&BaseModel.__get_pydantic_json_schema__kwargsc                 K  r   )a  This is intended to behave just like `__init_subclass__`, but is called by `ModelMetaclass`
        only after the class is actually fully initialized. In particular, attributes like `model_fields` will
        be present when this is called.

        This is necessary because `__init_subclass__` will always be called by `type.__new__`,
        and it would require a prohibitively large refactor to the `ModelMetaclass` to ensure that
        `type.__new__` was called in such a manner that the class would already be sufficiently initialized.

        This will receive the same `kwargs` that would be passed to the standard `__init_subclass__`, namely,
        any kwargs passed to the class definition that aren't used internally by pydantic.

        Args:
            **kwargs: Any keyword arguments passed to the class definition that aren't used internally
                by pydantic.
        NrP   ra   r   rP   rP   rQ   __pydantic_init_subclass__H  s   z$BaseModel.__pydantic_init_subclass__typevar_values!type[Any] | tuple[type[Any], ...]3type[BaseModel] | _forward_ref.PydanticRecursiveRefc           
   	     s  t | |}|d ur|S | tu rtdt| ds t|  d| jd s2tj| jvr2t|  dt	|t
s:|f}t | | tt| jd | t    ra ra| }t | || |S | jd }|sk|}nt
 fdd|D }| jd	 p|| }||}t
d
d t   D }t ||N}	|	d ur|	W  d    S t | |||}|d ur|W  d    S z|jdd W n	 ty   Y nw t ||||}t | |||| W d    |S 1 sw   Y  |S )NzAType parameters should be placed on typing.Generic, not BaseModel__parameters__zG cannot be parametrized because it does not inherit from typing.Generic
parametersz is not a generic classargsc                 3  s    | ]	}t | V  qd S N)r   Zreplace_types)rV   argZtypevars_maprP   rQ   	<genexpr>z      z.BaseModel.__class_getitem__.<locals>.<genexpr>r   c                 S  s   i | ]}|d qS r   rP   r   rP   rP   rQ   rY     s    z/BaseModel.__class_getitem__.<locals>.<dictcomp>   )r   )r   Zget_cached_generic_type_earlyr/   r   hasattrr;   r   r   	__bases__r   tupleZcheck_parameters_countdictzipr   Zall_identicalrl   re   Zset_cached_generic_typer   Ziter_contained_typevarsZgeneric_recursion_self_typeZget_cached_generic_type_later   r   Zcreate_generic_submodel)
ra   r   cachedZsubmodelZparent_argsr   r   Z
model_namer   Zmaybe_self_typerP   r   rQ   __class_getitem__[  s^   

%

	
zBaseModel.__class_getitem__c                 C  s   t | }||}t|dt| j t|dt| j t|dt| j | jdu r1t|dd |S t|ddd | j D  |S )z$Returns a shallow copy of the model.rJ   rC   rE   NrF   c                 S     i | ]\}}|t ur||qS rP   r   rU   rP   rP   rQ   rY         z&BaseModel.__copy__.<locals>.<dictcomp>)	typerh   ro   r   rJ   rC   rE   rF   rZ   )r\   ra   rq   rP   rP   rQ   rz     s   

zBaseModel.__copy__memodict[int, Any] | Nonec                 C  s   t | }||}t|dt| j|d t|dt| j|d t|dt| j | jdu r5t|dd |S t|dtdd | j	 D |d |S )	z!Returns a deep copy of the model.rJ   )r   rC   rE   NrF   c                 S  r   rP   r   rU   rP   rP   rQ   rY     r   z*BaseModel.__deepcopy__.<locals>.<dictcomp>)
r   rh   ro   r   rJ   rC   r   rE   rF   rZ   )r\   r   ra   rq   rP   rP   rQ   ry     s   

zBaseModel.__deepcopy__itemc              
     s   t | d}||v r;|| }t|dr|| t| S z| j| W S  ty: } ztt| jd||d }~ww t | d}|d urdz|| W S  tyc } ztt| jd||d }~ww t| j	|rpt
 |S tt| jd|)Nr6   __get__ object has no attribute rC   )object__getattribute__r   r   r   rF   KeyErrorAttributeErrorr   	__class__super)r\   r   Zprivate_attributes	attributeexcpydantic_extrar   rP   rQ   __getattr__  s,   

zBaseModel.__getattr__rs   valuec              	   C  s  || j v rt|d| jj d| jj d| dt|sI| jd u s(|| jvr0t| || d S | j| }t	|drB|
| | d S || j|< d S | jdd rad|f|d}tj| jj|gt| j|dd	r|d
|f|d}tj| jj|gt| j|d }t|tr|
| | d S | jdd r| j| || d S | jddkr|| jvrtd| jj d| d| jddkr|| jvr|| j|< d S || j|< | j| d S )Nz is a ClassVar of `zR` and cannot be set on an instance. If you want to set a value on the class, use `.z
 = value`.__set__frozenZfrozen_instancer   locinputFZfrozen_fieldvalidate_assignmentrf   rg   "z" object has no field ")r5   r   r   r   r   is_valid_field_namerF   r6   ro   r   r   r3   rn   pydantic_coreValidationErrorfrom_exception_datagetattrr4   r   propertyr@   r   
ValueErrorrC   rJ   rE   add)r\   rs   r   r   errorattrrP   rP   rQ   __setattr__  sR   






zBaseModel.__setattr__c              
   C  s   || j v r7| j | }t|dr||  d S z| j|= W d S  ty6 } ztt| jd||d }~ww || jv rDt	
| | d S | jd urT|| jv rT| j|= d S z	t	
| | W d S  typ   tt| jd|w )N
__delete__r   )r6   r   r  rF   r   r   r   r   r4   r   __delattr__rC   )r\   r   r   r   rP   rP   rQ   r    s(   




zBaseModel.__delattr__dict[Any, Any]c                 C  s0   | j }|rdd | D }| j| j| j|dS )Nc                 S  r   rP   r   rU   rP   rP   rQ   rY   '  r   z*BaseModel.__getstate__.<locals>.<dictcomp>)rJ   rC   rE   rF   )rF   rZ   rJ   rC   rE   )r\   privaterP   rP   rQ   __getstate__$  s   zBaseModel.__getstate__statec                 C  sD   t | d|d  t | d|d  t | d|d  t | d|d  d S )NrE   rC   rF   rJ   )ro   )r\   r  rP   rP   rQ   __setstate__/  s   zBaseModel.__setstate__otherc                 C  sZ   t |tr+| jd p| j}|jd p|j}||ko*| j|jko*| j|jko*| j|jkS tS )Nr   )r   r/   r;   r   rJ   rF   rC   NotImplemented)r\   r	  	self_typeZ
other_typerP   rP   rQ   __eq__5  s   



zBaseModel.__eq__Unpack[ConfigDict]c                 K  r   )a  This signature is included purely to help type-checkers check arguments to class declaration, which
            provides a way to conveniently set model_config key/value pairs.

            ```py
            from pydantic import BaseModel

            class MyModel(BaseModel, extra='allow'):
                ...
            ```

            However, this may be deceiving, since the _actual_ calls to `__init_subclass__` will not receive any
            of the config arguments, and will only receive any keyword arguments passed during class initialization
            that are _not_ expected keys in ConfigDict. (This is due to the way `ModelMetaclass.__new__` works.)

            Args:
                **kwargs: Keyword arguments passed to the class definition, which set model_config

            Note:
                You may want to override `__pydantic_init_subclass__` instead, which behaves similarly but is called
                *after* the class is fully initialized.
            NrP   r   rP   rP   rQ   __init_subclass__K  s    zBaseModel.__init_subclass__TupleGeneratorc                 c  s2    | j  E dH  | j}|r| E dH  dS dS )zSo `dict(model)` works.N)rJ   rZ   rC   )r\   rf   rP   rP   rQ   __iter__b  s   zBaseModel.__iter__c                 C  s   |    d| d dS )N(r   ))__repr_name____repr_str__r[   rP   rP   rQ   __repr__i  s   zBaseModel.__repr___repr.ReprArgsc                 #  s~     j  D ]\}} j|}|r|jr||fV  q j}|d ur.dd | D E d H   fdd j D E d H  d S )Nc                 s  s    | ]	\}}||fV  qd S r   rP   rU   rP   rP   rQ   r   s  r   z*BaseModel.__repr_args__.<locals>.<genexpr>c                 3  s(    | ]\}}|j r|t |fV  qd S r   )reprr   rU   r[   rP   rQ   r   t  s   & )rJ   rZ   r4   rn   r  rC   r]   )r\   rW   rX   rt   r   rP   r[   rQ   __repr_args__l  s   

"zBaseModel.__repr_args__c                 C  s
   |  dS )N )r  r[   rP   rP   rQ   __str__|  s   
zBaseModel.__str__EThe `__fields__` attribute is deprecated, use `model_fields` instead.)categorydict[str, FieldInfo]c                 C     t dt | jS )Nr  )r   warnDeprecationWarningr4   r[   rP   rP   rQ   
__fields__  s   zBaseModel.__fields__MThe `__fields_set__` attribute is deprecated, use `model_fields_set` instead.c                 C  r  )Nr"  )r   r  r   rE   r[   rP   rP   rQ   __fields_set__  s   zBaseModel.__fields_set__:The `dict` method is deprecated; use `model_dump` instead.r~   r   r   r   r   r   typing.Dict[str, Any]c                C  s"   t dt | j||||||dS )Nr$  r%  )r   r  r   r   )r\   r~   r   r   r   r   r   rP   rP   rQ   r     s   zBaseModel.dict?The `json` method is deprecated; use `model_dump_json` instead.)r~   r   r   r   r   r   encodermodels_as_dictr(  "typing.Callable[[Any], Any] | Noner)  dumps_kwargsc          
      K  sN   t dt |turtd|turtd|	rtd| j||||||dS )Nr'  zMThe `encoder` argument is no longer supported; use field serializers instead.zUThe `models_as_dict` argument is no longer supported; use a model serializer instead.z9`dumps_kwargs` keyword arguments are no longer supported.r%  )r   r  r   r   r   r   )
r\   r~   r   r   r   r   r   r(  r)  r+  rP   rP   rQ   json  s   zBaseModel.jsonCThe `parse_obj` method is deprecated; use `model_validate` instead.c                 C     t dt | |S )Nr-  r   r  r   r   ra   r   rP   rP   rQ   	parse_obj     
zBaseModel.parse_objThe `parse_raw` method is deprecated; if your data is JSON use `model_validate_json`, otherwise load the data then use `model_validate` instead.utf8)content_typeencodingprotoallow_picklebstr | bytesr5  
str | Noner6  r7  !_deprecated_parse.Protocol | Noner8  c             
   C  s   t dt ztj|||||d}W nB ttfyT } z4dd l}t|t	r(d}	nt||j
r1d}	n
t|tr9d}	nd}	t|	t|d|d	}
tj| j|
gd }~ww | |S )
Nr3  r7  r5  r6  r8  r   zvalue_error.unicodedecodezvalue_error.jsondecodeZvalue_errorZ
type_error)Z__root__r   )r   r  r   _deprecated_parseZload_str_bytesr   r   r,  r   UnicodeDecodeErrorJSONDecodeErrorr   ZPydanticCustomErrorr   r   r   r   r   )ra   r9  r5  r6  r7  r8  r   r   r,  Ztype_strr   rP   rP   rQ   	parse_raw  s:   



zBaseModel.parse_rawzThe `parse_file` method is deprecated; load the data from file, then if your data is JSON use `model_validate_json`, otherwise `model_validate` instead.path
str | Pathc                C  s*   t dt tj|||||d}| |S )NzThe `parse_file` method is deprecated; load the data from file, then if your data is JSON use `model_validate_json` otherwise `model_validate` instead.r=  )r   r  r   r>  Z	load_filer1  )ra   rB  r5  r6  r7  r8  r   rP   rP   rQ   
parse_file  s   
zBaseModel.parse_filezqThe `from_orm` method is deprecated; set `model_config['from_attributes']=True` and use `model_validate` instead.c                 C  s0   t dt | jdd stdd d| |S )NzqThe `from_orm` method is deprecated; set `model_config["from_attributes"]=True` and use `model_validate` instead.r   zHYou must set the config attribute `from_attributes=True` to use from_ormrH   )r   r  r   r3   rn   r   r   r0  rP   rP   rQ   from_orm"  s   
zBaseModel.from_ormDThe `construct` method is deprecated; use `model_construct` instead.c                 K  s    t dt | jdd|i|S )NrG  rc   rP   )r   r  r   rv   )ra   rc   re   rP   rP   rQ   	construct4  s   zBaseModel.constructz8The copy method is deprecated; use `model_copy` instead.)r~   r   rm   rw   +AbstractSetIntStr | MappingIntStrAny | Nonetyping.Dict[str, Any] | Nonec          
   	   C  s   t dt ttj| dd||ddfi |pi }| jdu r!d}n
dd | j D }| jdu r3d}n)| j	 }t
| jD ]}||vrH|| q=t
|D ]}|| jv r[||||< qM|rf| j| B }	nt| j}	|rs|	t|8 }	tj| ||	|||dS )a  Returns a copy of the model.

        !!! warning "Deprecated"
            This method is now deprecated; use `model_copy` instead.

        If you need `include` or `exclude`, use:

        ```py
        data = self.model_dump(include=include, exclude=exclude, round_trip=True)
        data = {**data, **(update or {})}
        copied = self.model_validate(data)
        ```

        Args:
            include: Optional set or mapping
                specifying which fields to include in the copied model.
            exclude: Optional set or mapping
                specifying which fields to exclude in the copied model.
            update: Optional dictionary of field-value pairs to override field values
                in the copied model.
            deep: If True, the values of fields that are Pydantic models will be deep copied.

        Returns:
            A copy of the model with included, excluded and updated fields as specified.
        zThe `copy` method is deprecated; use `model_copy` instead. See the docstring of `BaseModel.copy` for details about how to handle `include` and `exclude`.F)to_dictr   r~   r   r   Nc                 S  r   rP   r   rU   rP   rP   rQ   rY   o  r   z"BaseModel.copy.<locals>.<dictcomp>)rw   )r   r  r   r   _deprecated_copy_internals_iterrF   rZ   rC   r   listrj   rE   rl   rk   _copy_and_set_values)
r\   r~   r   rm   rw   re   r  rf   rW   Z
fields_setrP   rP   rQ   r   <  s>   $





zBaseModel.copyCThe `schema` method is deprecated; use `model_json_schema` instead.c                 C  s   t dt | j||dS )NrP  r   r   )r   r  r   r"   )ra   r   r   rP   rP   rQ   schema  s   zBaseModel.schemaWThe `schema_json` method is deprecated; use `model_json_schema` and json.dumps instead.rQ  c                K  s@   dd l }tdt ddlm} |j| j||dfd|i|S )Nr   rS  r	   )pydantic_encoderrQ  default)r,  r   r  r   Zdeprecated.jsonrT  dumpsr"   )ra   r   r   r+  r,  rT  rP   rP   rQ   schema_json  s   zBaseModel.schema_jsonBThe `validate` method is deprecated; use `model_validate` instead.c                 C  r.  )NrX  r/  )ra   r   rP   rP   rQ   validate  r2  zBaseModel.validateLThe `update_forward_refs` method is deprecated; use `model_rebuild` instead.localnsc                 K  s(   t dt |rtd| jdd d S )NrZ  z,`localns` arguments are not longer accepted.T)r   )r   r  r   r   r   )ra   r[  rP   rP   rQ   update_forward_refs  s   zBaseModel.update_forward_refsHThe private method `_iter` will be removed and should no longer be used.r   c                 O  $   t dt tj| g|R i |S )Nr]  )r   r  r   rL  rM  r\   r   r   rP   rP   rQ   rM    s   zBaseModel._iterzWThe private method `_copy_and_set_values` will be removed and should no longer be used.c                 O  r^  )NzXThe private method  `_copy_and_set_values` will be removed and should no longer be used.)r   r  r   rL  rO  r_  rP   rP   rQ   rO    s
   zBaseModel._copy_and_set_valueszMThe private method `_get_value` will be removed and should no longer be used.c                 O  r^  )NzNThe private method  `_get_value` will be removed and should no longer be used.)r   r  r   rL  
_get_value)ra   r   r   rP   rP   rQ   r`    s   zBaseModel._get_valueRThe private method `_calculate_keys` will be removed and should no longer be used.c                 O  r^  )Nra  )r   r  r   rL  _calculate_keysr_  rP   rP   rQ   rb    s   zBaseModel._calculate_keys)rK   r   rL   rM   )rL   rS   )rL   rB   )rL   rD   r   )ra   rb   rc   rd   re   r   rL   r.   )r\   r.   rm   rB   rw   rx   rL   r.   )r}   r   r~   r1   r   r1   r   rx   r   rx   r   rx   r   rx   r   rx   r   rx   rL   r   )r   r   r~   r1   r   r1   r   rx   r   rx   r   rx   r   rx   r   rx   r   rx   rL   r   )
r   rx   r   r   r   r   r}   r    rL   r   )r   r   rL   r   )r   r   rL   rM   )
r   rx   r   rx   r   r   r   rB   rL   r   )ra   rb   r   r   r   r   r   r   r   rB   rL   r.   )
ra   rb   r   r   r   r   r   rB   rL   r.   )r   r   r   r   rL   r&   )r   r&   r   r   rL   r!   )r   r   rL   rM   )r   r   rL   r   )r\   r.   rL   r.   )r\   r.   r   r   rL   r.   )r   r   rL   r   )rs   r   r   r   rL   rM   )rL   r  )r  r  rL   rM   )r	  r   rL   rx   )r   r  )rL   r  )rL   r   )rL   r  )rL   r  )r~   r1   r   r1   r   rx   r   rx   r   rx   r   rx   rL   r&  )r~   r1   r   r1   r   rx   r   rx   r   rx   r   rx   r(  r*  r)  rx   r+  r   rL   r   )ra   rb   r   r   rL   r.   )ra   rb   r9  r:  r5  r;  r6  r   r7  r<  r8  rx   rL   r.   )ra   rb   rB  rC  r5  r;  r6  r   r7  r<  r8  rx   rL   r.   )r\   r.   r~   rI  r   rI  rm   rJ  rw   rx   rL   r.   )r   rx   r   r   rL   r&  )r   rx   r   r   r+  r   rL   r   )ra   rb   r   r   rL   r.   )r[  r   rL   rM   )r   r   r   r   rL   r   )Yr   
__module____qualname____doc__r   TYPE_CHECKING__annotations___FieldrC   rE   rF   r4   r   ZDecoratorInfosr:   r   Z
MockValSerr@   r?   	__slots__r   r3   r8   r>   rR   Z__pydantic_base_init__r   r]   r_   r`   classmethodrv   r{   r   r   r   r   r"   r   rp   r   r   r   r   r   r   r   rz   ry   r   r  r  r  r  r  r  r  r  r  r   ZRepresentationr  r  Z
__pretty____rich_repr__r  typing_extensions
deprecatedr#   r!  r#  r   r   r,  r1  rA  rD  rF  rH  r   rR  rW  rY  r\  rM  rO  r`  rb  __classcell__rP   rP   r   rQ   r/   =   s  
 	11,7@.	-	I)	metaclass)
__config____base__rc  __validators____cls_kwargs____model_namer   rp  ConfigDict | Nonerq  rM   rc  rr   dict[str, AnyClassMethod] | Noners  rB   field_definitionsr   rL   r   c                K     d S r   rP   rt  rp  rq  rc  rr  rs  rw  rP   rP   rQ   r2        r2   )rp  rc  rr  rs  %type[Model] | tuple[type[Model], ...]rb   c                K  rx  r   rP   ry  rP   rP   rQ   r2     rz  )rp  rq  rc  rr  rs  ri  ,type[Model] | tuple[type[Model], ...] | Noneri  tuple[str, ...] | Nonec                K  s  |dur
t dt |dur!|durtdddt|ts |f}n
ttjd t	f}|p.i }i }i }	|
 D ]G\}
}t|
sJt d|
 dt t|trotd	|}z|\}}W n tyn } ztd
dd|d}~ww d|}}|rz||	|
< |||
< q7|	|d}|r|| || |rt|j|d< t|}tj| ||d\}}}||ur||d< || || ||fddi|S )a  Dynamically creates and returns a new Pydantic model, in other words, `create_model` dynamically creates a
    subclass of [`BaseModel`][pydantic.BaseModel].

    Args:
        __model_name: The name of the newly created model.
        __config__: The configuration of the new model.
        __base__: The base class for the new model.
        __module__: The name of the module that the model belongs to.
        __validators__: A dictionary of methods that validate
            fields.
        __cls_kwargs__: A dictionary of keyword arguments for class creation.
        __slots__: Deprecated. Should not be passed to `create_model`.
        **field_definitions: Attributes of the new model. They should be passed in the format:
            `<name>=(<type>, <default value>)` or `<name>=(<type>, <FieldInfo>)`.

    Returns:
        The new [model][pydantic.BaseModel].

    Raises:
        PydanticUserError: If `__base__` and `__config__` are both passed.
    Nz.__slots__ should not be passed to create_modelzFto avoid confusion `__config__` and `__base__` cannot be used togetherzcreate-model-config-baserE  r.   z3fields may not start with an underscore, ignoring "r   ztuple[str, Any]z4Field definitions should be a `(<type>, <default>)`.zcreate-model-field-definitions)rg  rc  r3   )kwds__orig_bases__Z#__pydantic_reset_parent_namespace__F)r   r  RuntimeWarningr   r   r   r   castTyper/   rZ   r   r   r   rm   r   r   Zconfig_dicttypesresolve_basesprepare_class)rt  rp  rq  rc  rr  rs  ri  rw  fieldsr   f_nameZf_defZf_annotationZf_valuee	namespaceresolved_basesmetansr~  rP   rP   rQ   r2     s^    









)rt  r   rp  ru  rq  rM   rc  r   rr  rv  rs  rB   rw  r   rL   r   )rt  r   rp  ru  rq  r{  rc  r   rr  rv  rs  rB   rw  r   rL   rb   )rt  r   rp  ru  rq  r|  rc  r   rr  rv  rs  rB   ri  r}  rw  r   rL   rb   )Tre  
__future__r   Z_annotationsr  r   r   r   r   r   r   r   rl  r   	_internalr
   r   r   r   r   r   r   r   r   r   r   Z
_migrationr   r   r   rm  r   rL  r   r>  errorsr   r   r  r   r   r   Zjson_schemar   r   r    r!   r"   r#   rf  inspectr$   pathlibr%   r&   r'   r(   r)   r*   Z_internal._utilsr+   r,   r-   rh  rj  ZAnyClassMethod	GeneratorTupler   r  TypeVarr.   r1   rg  r   __all__Zobject_setattrro   ZModelMetaclassr/   overloadr   r2   r   rP   rP   rP   rQ   <module>   s    4         1U