fL iG UdZddlmZddlZddlZddlZddlZddlm Z m Z ddl m Z m Z ddl mZddlmZmZmZmZmZmZmZmZmZmZmZddlZddlZddlmZmZdd lmZm Z m!Z!d d l"m#Z#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/m0Z0d d l1m2Z2d dl3m4Z4m5Z5d dl6m7Z7m8Z8d dl9m:Z:m;Z;d dlZ>d dl?m@Z@mAZAmBZBmCZCmDZDd dlEmFZFer4ddlGmHZHddlImJZJddlmKZKmLZLmMZMd dlNmOZOd dlPmQZQmRZRd dlSmTZUd dlVmWZWmXZXmYZYdZZe e[e\efddfZ]de^d<ee_e`e_e\e e`edeaffe e\edeafffZbde^d<e,jZdd2dZed3d!Zfd3d"Zgefd#egd$d%d&Zhd'e^d(<Gd)d e,j*Zjed+ej,Zkedddeldddd- d4d.Zmeddeldddd/ d5d0Zmdddddddd- d6d1Zme2elZny)7zLogic for creating models.) annotationsN) GeneratorMapping)copydeepcopy)cached_property) TYPE_CHECKINGAnyCallableClassVarDictGenericLiteralTypeVarUnioncastoverload)PydanticUndefinedValidationError)Self TypeAliasUnpack)PydanticDeprecatedSince20PydanticDeprecatedSince211) _config _decorators_fields _forward_ref _generics _mock_val_ser_model_construction_namespace_utils_repr _typing_extra_utils)getattr_migration) AliasChoices AliasPath)GetCoreSchemaHandlerGetJsonSchemaHandler) ConfigDict ExtraValues)PydanticUndefinedAnnotationPydanticUserError)DEFAULT_REF_TEMPLATEGenerateJsonSchemaJsonSchemaModeJsonSchemaValuemodel_json_schema)PluggableSchemaValidator) Signature)Path) CoreSchemaSchemaSerializerSchemaValidator)MappingNamespace)AbstractSetIntStrMappingIntStrAny)Protocol)ComputedFieldInfo FieldInfoModelPrivateAttr) BaseModel create_modelrTupleGeneratorIncExc|jjdrd}n*t|jj|ddrd}nyt j |j ||f|dg)Nfrozenfrozen_instanceF frozen_fieldtypelocinput) model_configgetgetattr__pydantic_fields__rfrom_exception_data__name__) model_clsnamevalue error_types S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pydantic/main.py _check_frozenrYQsj!!(+& ..2248(E J#   - -j$5QR rBcX||j|<|jj|yN)__dict____pydantic_fields_set__addmodelrUvals rX_model_field_setattr_handlerrc^s$ENN4 !!%%d+rZcjt|ddtj|di||j|<y)N__pydantic_private__)rPobject __setattr__rer`s rX_private_setattr_handlerrhcs7u,d3; 5"8"='*Et$rZc<|jj|||Sr\)__pydantic_validator__validate_assignmentr`s rXrlosE4P4P4d4dejlpru4vrZc:|jj||Sr\)r] __setitem__r`s rXrlrlqs0J0J4QT0UrZct|||Sr\)_object_setattrr`s rXrlrlrsOE4,MrZ) model_fieldrkprivater extra_knownz3Mapping[str, Callable[[BaseModel, str, Any], None]]_SIMPLE_SETATTR_HANDLERSc eZdZUdZeZded< ded< ded< ded < d Zd ed < d ed< d ed< ejZ ded< ded< dZ ded< ded< d Z d ed< ded< ded< ded< d ed!< d"ed#< e jd $Zd%ed&< e jd $Zd'ed(< e jd $Zd%ed)< es>ej(d*d+,Zej,d*d-d+.Zej,d*d/d+.Zd0Zdd1Zd2e_ej:edd3Zej:edd4Z e!dd5Z"e!dd6Z#eddd7Z$dd d8dd9Z%d:ddddd d d d d d2dd d; dd<Z&dd ddddd d d d d d2dd d= dd>Z'ed2e(e)d?fd@dA ddBZ*eddCZ+ddDZ,ed d2dEddF ddGZ-edddddddH ddIZ.eddddddJ ddKZ/eddddddJ ddLZ0eddMZ1e ddNZ2eddOZ3eddPZ4 ddQZ5ddRZ6dddSZ7esdfdT Z8ddUZ9ddVZ:ddWZ;ddXZesdd[Z?erdd\Z@dd]ZAdd^ZBdd_ZCeDjjZFeDjjZGeDjjZHeDjjZIeDjjZJdd`ZKe!eLjdadbddcZNe!eLjdddbddeZOeLjdfdbddd d d d dg ddhZPeLjdidbddd d d d eQeQdj ddkZReeLjdldbddmZSeeLjdndbddodd dp ddqZTeeLjdrdbddodd dp ddsZUeeLjdtdbdduZVeeLjdvdbdddwZWeLjdxdbdddd dy ddzZXeeLjd{dbd2e(f dd|ZYeeLjd}dbd2e(d~ ddZZeeLjddbddZ[eeLjddbddZ\eLjddbddZ]eLjddbddZ^eeLjddbddZ_eLjddbddZ`xZaS)rBa!!! abstract "Usage Documentation" [Models](../concepts/models.md) A base class for creating Pydantic models. Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized `__init__` [`Signature`][inspect.Signature] of the model. __pydantic_complete__: Whether model building is completed, or if there are still undefined fields. __pydantic_core_schema__: The core schema of the model. __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.root_model.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_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects. __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] is set to `'allow'`. __pydantic_fields_set__: The names of fields explicitly set during instantiation. __pydantic_private__: Values of private attributes set on the model instance. zClassVar[ConfigDict]rNzClassVar[set[str]]__class_vars__z%ClassVar[Dict[str, ModelPrivateAttr]]__private_attributes__zClassVar[Signature] __signature__FzClassVar[bool]__pydantic_complete__zClassVar[CoreSchema]__pydantic_core_schema____pydantic_custom_init__z$ClassVar[_decorators.DecoratorInfos]__pydantic_decorators__z+ClassVar[_generics.PydanticGenericMetadata]__pydantic_generic_metadata__NzClassVar[Dict[str, Any] | None]__pydantic_parent_namespace__z+ClassVar[None | Literal['model_post_init']]__pydantic_post_init____pydantic_root_model__zClassVar[SchemaSerializer]__pydantic_serializer__z4ClassVar[SchemaValidator | PluggableSchemaValidator]rjzClassVar[Dict[str, FieldInfo]]rQz:ClassVar[Dict[str, Callable[[BaseModel, str, Any], None]]]__pydantic_setattr_handlers__z&ClassVar[Dict[str, ComputedFieldInfo]]__pydantic_computed_fields__)initDict[str, Any] | None__pydantic_extra__set[str]r^rezXPydantic models should inherit from BaseModel, BaseModel cannot be instantiated directlyzbase-model-instantiatedcode validator) val_or_serr serializer)r]r^rrec zd}|jj||}||urtjddyy)a/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. `self` is explicitly positional-only to allow `self` as a field name. T) self_instancea*A custom validator is returning a value other than `self`. Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`. See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details. stacklevelN)rjvalidate_pythonwarningswarn)selfdata__tracebackhide__validated_selfs rX__init__zBaseModel.__init__sJ!44DDTY]D^ ~ % MML   &rZTct|diS)a6A mapping of field names to their respective [`FieldInfo`][pydantic.fields.FieldInfo] instances. !!! warning Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class. rQrPclss rX model_fieldszBaseModel.model_fieldsss1266rZct|diS)aOA mapping of computed field names to their respective [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] instances. !!! warning Accessing this attribute from a model instance is deprecated, and will not work in Pydantic V3. Instead, you should access this attribute from the model class. rrrs rXmodel_computed_fieldszBaseModel.model_computed_fieldsss:B??rZc|jS)zGet extra fields set during validation. Returns: A dictionary of extra fields, or `None` if `config.extra` is not set to `"allow"`. )rrs rX model_extrazBaseModel.model_extras&&&rZc|jS)zReturns the set of fields that have been explicitly 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. )r^rs rXmodel_fields_setzBaseModel.model_fields_set%s+++rZc ,|j|}i}t}|jjD]y\}}|j=|j|vr/|j |j||<|j |||vr|jt|jtr|jjn |jg}|D]} t| tr+| |vr'|j | ||<|j |nDt| tsO| j|} | tusi| ||<|j |n||vs'||vr'|j |||<|j |R|jrd|j!d|||<|||}|j"j%ddk(r|nd} t'|d|t'|d||j(s t'|d| |j*ra|j-dt/|d rB|j06|jD]#\} } | |j2vs| |j0| <%|S|j(s t'|d d|S) aJCreates 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. !!! note `model_construct()` generally respects the `model_config.extra` setting on the provided model. That is, if `model_config.extra == 'allow'`, then all extra passed values are added to the model instance's `__dict__` and `__pydantic_extra__` fields. If `model_config.extra == 'ignore'` (the default), then all extra passed values are ignored. Because no validation is performed with a call to `model_construct()`, having `model_config.extra == 'forbid'` does not result in an error if extra values are passed, but they will be ignored. Args: _fields_set: A set of field names that were originally explicitly set during instantiation. If provided, this is directly used for the [`model_fields_set`][pydantic.BaseModel.model_fields_set] attribute. Otherwise, the field names from the `values` argument will be used. values: Trusted or pre-validated data dictionary. Returns: A new instance of the `Model` class with validated data. NT)call_default_factoryvalidated_dataextraallowr]r^rre)__new__setrQitemsaliaspopr_validation_alias isinstancer(choicesstrr)search_dict_for_pathr is_required get_defaultrNrOrprrmodel_post_inithasattrrerw)r _fields_setvaluesm fields_values fields_setrUfieldvalidation_aliasesrrV_extrakvs rXmodel_constructzBaseModel.model_construct/s. KK (* U 2288: uKD%{{&5;;&+@&,jj&= d#t$J&U-C-C-O"%"8"8,G**22001# 0 "E!%-%6/.4jj.? d+"t,#E95 % : :6 B (9927M$/&NN40! ":%6>*0**T*:M$'NN4(**,*/*;*;QUfs*;*tM$'; u<  $K252B2B2F2Fw2OSZ2Z`d:}54kB** A3V <  % %  d #q01a6L6L6X"LLN6DAqA44445..q16 ,, A5t <rZ)updatedeepc|r|jn|j}|r|jjddk(rY|j D]E\}}||j vr||j |<$|ji|_||j|<Gn|j j||jj|j|S)a!!! abstract "Usage Documentation" [`model_copy`](../concepts/models.md#model-copy) Returns a copy of the model. !!! note The underlying instance's [`__dict__`][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]). 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. rr) __deepcopy____copy__rNrOrrQr]rrr^keys)rrrcopiedrrs rX model_copyzBaseModel.model_copys&)-""$$--/   $$W-8"LLN9DAqD444-.*!44<8:F57811!4 9&&v.  * * 1 1&++- @ rZpython) modeincludeexcludecontextby_alias exclude_unsetexclude_defaults exclude_noneexclude_computed_fields round_triprfallbackserialize_as_anyc T|jj|||||||||| | | | | S)a!!! abstract "Usage Documentation" [`model_dump`](../concepts/serialization.md#python-mode) 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 output will only contain JSON serializable types. If mode is 'python', the output may contain non-JSON-serializable Python objects. include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field's alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of `None`. exclude_computed_fields: Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated `round_trip` parameter instead. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors, "error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError]. fallback: A function to call when an unknown value is encountered. If not provided, a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised. serialize_as_any: Whether to serialize fields with duck-typing serialization behavior. Returns: A dictionary representation of the model. ) rrrrrrrrrrrrr)r to_python)rrrrrrrrrrrrrrs rX model_dumpzBaseModel.model_dumpsM\++55 '-%$;!-6  rZindent ensure_asciirrrrrrrrrrrrcr|jj|||||||||| | | | | |jS)a!!! abstract "Usage Documentation" [`model_dump_json`](../concepts/serialization.md#json-mode) 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. ensure_ascii: If `True`, the output is guaranteed to have all incoming non-ASCII characters escaped. If `False` (the default), these characters will be output as-is. include: Field(s) to include in the JSON output. exclude: Field(s) to exclude from the JSON output. context: Additional context to pass to the serializer. 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 are set to their default value. exclude_none: Whether to exclude fields that have a value of `None`. exclude_computed_fields: Whether to exclude computed fields. While this can be useful for round-tripping, it is usually recommended to use the dedicated `round_trip` parameter instead. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/"none" ignores them, True/"warn" logs errors, "error" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError]. fallback: A function to call when an unknown value is encountered. If not provided, a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised. serialize_as_any: Whether to serialize fields with duck-typing serialization behavior. Returns: A JSON string representation of the model. r)rto_jsondecode)rrrrrrrrrrrrrrrs rXmodel_dump_jsonzBaseModel.model_dump_jsonsY^++33 %'-%$;!-4 &(! rZ validationany_of) union_formatc$t||||||S)aGenerates a JSON schema for a model class. Args: by_alias: Whether to use attribute aliases or not. ref_template: The reference template. union_format: The format to use when combining schemas from unions together. Can be one of: - `'any_of'`: Use the [`anyOf`](https://json-schema.org/understanding-json-schema/reference/combining#anyOf) keyword to combine schemas (the default). - `'primitive_type_array'`: Use the [`type`](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (`string`, `boolean`, `null`, `integer` or `number`) or contains constraints/metadata, falls back to `any_of`. 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 ref_templaterschema_generatorr)r4)rrrrrrs rXr4zBaseModel.model_json_schema"s#<! %%-   rZct|ts td|Dcgc])}t|tr|nt j |+}}dj|}|jd|dScc}w)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., []) issubclassr TypeErrorrrr$display_as_typejoinrS)rparamsparam param_namesparams_components rXmodel_parametrized_namez!BaseModel.model_parametrized_nameIsz"#w'YZ Z gmm]b 5# 6uE! u !4#N7  ))99 +:  rZrrrrrcrd}|dur|dur tdd|jj||||||S)a!!! abstract "Usage Documentation" [JSON Parsing](../concepts/json.md#json-parsing) Validate the given JSON data against the Pydantic model. Args: json_data: The JSON data to validate. strict: Whether to enforce types strictly. extra: Whether to ignore, allow, or forbid extra data during model validation. See the [`extra` configuration value][pydantic.ConfigDict.extra] for details. context: Extra variables to pass to the validator. by_alias: Whether to use the field's alias when validating against the provided input data. by_name: Whether to use the field's name when validating against the provided input data. Returns: The validated Pydantic model. Raises: ValidationError: If `json_data` is not a JSON string or the object could not be validated. TFrrrr)r/rj validate_json)r json_datarrrrrrs rXmodel_validate_jsonzBaseModel.model_validate_jsons[@! u !4#N7  ))77 fE7X_f8  rZcrd}|dur|dur tdd|jj||||||S)aValidate the given object with string data against the Pydantic model. Args: obj: The object containing string data to validate. strict: Whether to enforce types strictly. extra: Whether to ignore, allow, or forbid extra data during model validation. See the [`extra` configuration value][pydantic.ConfigDict.extra] for details. context: Extra variables to pass to the validator. by_alias: Whether to use the field's alias when validating against the provided input data. by_name: Whether to use the field's name when validating against the provided input data. Returns: The validated Pydantic model. TFrrrr)r/rjvalidate_strings)rrrrrrrrs rXmodel_validate_stringsz BaseModel.model_validate_stringssZ4! u !4#N7  )):: eWxY`;  rZctjdtd|jj d}|&t |t js |jS||S)Na>The `__get_pydantic_core_schema__` method of the `BaseModel` class is deprecated. If you are calling `super().__get_pydantic_core_schema__` when overriding the method on a Pydantic model, consider using `handler(source)` instead. However, note that overriding this method on models can lead to unexpected side effects.rrrz) rrrr]rOrr!MockCoreSchemarz)rsourcehandlerschemas rX__get_pydantic_core_schema__z&BaseModel.__get_pydantic_core_schema__(s_    '  !!"<=  j9U9U&V// /vrZc||S)a_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. r)r core_schemar#s rX__get_pydantic_json_schema__z&BaseModel.__get_pydantic_json_schema__<s0{##rZc y)aThis is intended to behave just like `__init_subclass__`, but is called by `ModelMetaclass` only after basic class initialization is complete. In particular, attributes like `model_fields` will be present when this is called, but forward annotations are not guaranteed to be resolved yet, meaning that creating an instance of the class may fail. 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. Note: You may want to override [`__pydantic_on_complete__()`][pydantic.main.BaseModel.__pydantic_on_complete__] instead, which is called once the class and its fields are fully initialized and ready for validation. Nrrkwargss rX__pydantic_init_subclass__z$BaseModel.__pydantic_init_subclass__VrrZcy)a+This is called once the class and its fields are fully initialized and ready to be used. This typically happens when the class is created (just before [`__pydantic_init_subclass__()`][pydantic.main.BaseModel.__pydantic_init_subclass__] is called on the superclass), except when forward annotations are used that could not immediately be resolved. In that case, it will be called later, when the model is rebuilt automatically or explicitly using [`model_rebuild()`][pydantic.main.BaseModel.model_rebuild]. Nrrs rX__pydantic_on_complete__z"BaseModel.__pydantic_on_complete__mrrZc tj||}||S|tur tdt |dst|d|j ds t |jvrt|dt|ts|f}tj|| td jD}tj j jr r|}tj||||S|j d}|s|}nt fd|D}|j d xs|}|j!|}tt"j%tj& j}tj(||5} tj*||||}| |cdddS| | cdddS t-j.d xsi} |j1| tj4||||}tj|||||ddd|S#t2$rYFwxYw#1swYSxYw) 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 classc3 K|]}|ywr\r).0rs rX z.BaseModel.__class_getitem__..s@Qq@s argsc3JK|]}tj|ywr\)r replace_types)r3arg typevars_maps rXr4z.BaseModel.__class_getitem__..s_CY44S,G_s #originr)r)r)r get_cached_generic_type_earlyrBrrr}r __bases__rtuplemap_generic_model_argumentsrr& all_identicalrset_cached_generic_typerdictfromkeysiter_contained_typevarsgeneric_recursion_self_typeget_cached_generic_type_later%rrr.create_generic_submodel) rtypevar_valuescachedsubmodel parent_argsr5r: model_namermaybe_self_typer r9s @rX__class_getitem__zBaseModel.__class_getitem__xsq88nM  M ) _` `s,-se#jkl l00>7RUR_R_C_se#:;< <.%0,.N!<8 LPM;;FCK%_S^__66x@GCF77=J i?? @S@S@UVWF66vtD _"??^U[]ab%! _ _ #.*  _ _  !. D DRS T ZXZI(()(D %<>o44T:: *%+%<%.s9J9J5RU9VrZrrrc(j||Sr\rf)rargrbr s rXrlz,BaseModel._setattr_handler..1seS1IrZrkrr"z" object has no field "rsrq)rWrvrVrSris_valid_field_namerwrOrrtrprPrrrYpropertyrNrQ ValueErrorr)rrUrVrr r[s @@rXr`zBaseModel._setattr_handler s..Cs)))$h1#,,@EEH\\NRSTXSYYce006!$!;!;!?!?!EEIRy)4VV7 BB#D$63d+D $0/0ABB #tU +$)II!!%%&;</0EFFS444##''0G;$q6MdVST%UVV\49D++D14MBB/ >>rZc|j}||jvr<|j|}t|dr|j|y |j|=yt||d}t|trtj||St||d||jvrtj||y|j||jvr|j|=y tj||y#t $r }t |jd||d}~wwxYw#t $r$t t!|jd|wxYw)N __delete__rS)rUrV)rWrwrrnrerUrVrSrPrrrf __delattr__rYrQrrK)rrYrr[r\r s rXrozBaseModel.__delattr__BsZ..Ct222 77= 9l3((.h11$7 3d+D$0))$55 #D 5t///""4.((4AXAX9X++D1f&&tT2! h(CLL+;;TUYT\)]^dggh"&f(DJ,?,?+BB[\`[c)deefs$ C=&D)= D&D!!D&)-Ec &|j|S)N)r)r)rchangess rX __replace__zBaseModel.__replace__es??'?2 2rZc|j}|r,|jDcic]\}}|tus||}}}|j|j|j |dScc}}w)N)r]rr^re)rerrr]rr^)rrrrrs rX __getstate__zBaseModel.__getstate__hse++ (/ V11DU;Uq!tVGV "&"9"9'+'C'C$+   Ws A A ct|d|jdit|d|jdit|d|jdit|d|jdiy)Nr^rrer])rprO)rstates rX __setstate__zBaseModel.__setstate__ssg7C\^`9ab2EII>RTV4WX4eii@VXZ6[\j%))J*CDrZc>t|tr)|jdxs |j}|jdxs |j}||k(r4t |ddt |ddk(r|j |j k(sy|j |j k(ryt|jj}|j j|kr|j j|kry|rtj|nd} ||j ||j k(StS#t$rRtj|j }tj|j }||||k(cYSwxYw)Nr:reFTc"tjSr\)r& _SENTINEL)_s rXrlz"BaseModel.__eq__..s [a[k[krZ)rrBr}rWrPrr]rKrQroperator itemgetterrUr&SafeGetItemProxyNotImplemented)rother self_type other_typergetterself_fields_proxyother_fields_proxys rX__eq__zBaseModel.__eq__{st%+!>>xHZDNN "@@J]eoo +&>4JJJ&% S )/(?(? (N%)/)@)@)P&!"34?Q8RRRSs$EAFFc y)aThis 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. ```python 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. Nrr*s rX__init_subclass__zBaseModel.__init_subclass__rrZc#K|jjDcgc]\}}|jdr||fc}}Ed{|j}|r|jEd{yycc}}w727w)zSo `dict(model)` works.r{N)r]r startswithr)rrrrs rX__iter__zBaseModel.__iter__sl)-)<)<)>Xv1allSVFWQFXXX'' {{} $ $ YX %s3A>A4A4A>A:%A>-A<. A><A>cL|jd|jddS)N(r)) __repr_name__ __repr_str__rs rX__repr__zBaseModel.__repr__s+$$&'q):):4)@(ACCrZc #*K|jjDcgc] \}}|js|t||f"}}}|jjD]P\}}|j j |}|s$|js1||ur||f<||j|fR tj|d}|d|jDEd{|Ed{ycc}}w#t$rd}Y?wxYw7&7w)Nrc3*K|] \}}||f ywr\r)r3rrs rXr4z*BaseModel.__repr_args__..sB41aABs) rrreprrPr]rQrO__repr_recursion__rfrTrV)rrrcomputed_fields_repr_argsrr]s rX __repr_args__zBaseModel.__repr_args__s /3.O.O.U.U.W% &*a[\[a[aQa !% !% MM'') 8DAq,,003ED=Q$JT44Q777  8 "#44T;OPN  %B>+?+?+AB B B,,,-% " "!N " C,sdDC8C8AD D"D6C> D(D) D2D3 D> D  D D  DDc$|jdS)N )rrs rX__str__zBaseModel.__str__s  %%rZXThe `__fields__` attribute is deprecated, use the `model_fields` class property instead.)categorycftjdtdtt |diS)NrrrrrQ)rrrrPrKrs rX __fields__zBaseModel.__fields__s/  f. tDz#8"==rZMThe `__fields_set__` attribute is deprecated, use `model_fields_set` instead.cRtjdtd|jS)Nrrr)rrrr^rs rX__fields_set__zBaseModel.__fields_set__ s'  [. +++rZ:The `dict` method is deprecated; use `model_dump` instead.rrrrrrchtjdtd|j||||||S)Nrrrr)rrrr)rrrrrrrs rXrAzBaseModel.dictsC  H. '-%   rZ?The `json` method is deprecated; use `model_dump_json` instead.)rrrrrrencodermodels_as_dictc tjdtd|tur t d|tur t d| r t d|j ||||||S)NrrrzMThe `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)rrrrrr) rrrrrrrrr dumps_kwargss rXjsonzBaseModel.json0s~  M. + +kl l !2 2st t WX X##'-% $  rZCThe `parse_obj` method is deprecated; use `model_validate` instead.c\tjdtd|j|S)Nrrrrrrrrrs rX parse_objzBaseModel.parse_objRs,  Q. !!#&&rZThe `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_typeencodingproto allow_picklectjdtdddlm} |j |||||}|j%|S#t tf$r}ddl} t|trd} n.t|| jrd } nt|t rd } nd } tj| t|d |d } tjj!|j"| gd}~wwxYw)Nrrrrparserrrrrzvalue_error.unicodedecodezvalue_error.jsondecode value_error type_error)__root__rJ)rrr deprecatedrload_str_bytesrlrrrUnicodeDecodeErrorJSONDecodeError pydantic_corePydanticCustomErrorrrrRrSr) rbrrrrrrr\rtype_strerrors rX parse_rawzBaseModel.parse_raw\s   I.  & [&&)!) 'C8!!#&&+I& [ #126C!5!563C,(' &99(CHM$ 5E  //CCCLLSXRYZ Z) [sA C2BC--C2The `parse_file` method is deprecated; load the data from file, then if your data is JSON use `model_validate_json`, otherwise `model_validate` instead.ctjdtdddlm}|j |||||}|j |S)Nrrrrrr)rrrrr load_filer)rpathrrrrrrs rX parse_filezBaseModel.parse_filesT   M.  &oo %%  }}S!!rZqThe `from_orm` method is deprecated; set `model_config['from_attributes']=True` and use `model_validate` instead.ctjdtd|jj dds t dd|j |S)NrrrrzHYou must set the config attribute `from_attributes=True` to use from_ormr)rrrrNrOr/rrs rXfrom_ormzBaseModel.from_orms[   W.  ##$5t<#Zae !!#&&rZDThe `construct` method is deprecated; use `model_construct` instead.c btjdtd|jdd|i|S)Nrrrrr)rrrr)rrrs rX constructzBaseModel.constructs6  R. #s""E{EfEErZThe `copy` method is deprecated; use `model_copy` instead. See the docstring of `BaseModel.copy` for details about how to handle `include` and `exclude`.)rrrrc tjdtdddlm}t |j |dd||dfi|xsi}|jd}n6|jjD cic]\}} | tus|| }}} |jd} n}|jj} t|jD]}||vs| j|t|D]%}||jvs|j|| |<'|r|j|jz} nt!|j} |r| t!|z} |j#||| | || Scc} }w) aReturns a copy of the model. !!! warning "Deprecated" This method is now deprecated; use `model_copy` instead. If you need `include` or `exclude`, use: ```python {test="skip" lint="skip"} 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. rrrrcopy_internalsF)to_dictrrrrN)r)rrrrrrA_iterrerrrrlistrr^rr_copy_and_set_values) rrrrrrrrrrrrrs rXrzBaseModel.copysF   m.  /  eeWgej !  |    $ $ ,G(,(A(A(G(G(Ih1QVgMgq!thGh  " " *+/E++002E$112 !F?IIaL !&\ -///%zz!}E!H - 55 EJT99:J  #g, &J224UT[bf2gg/is 4E5E5CThe `schema` method is deprecated; use `model_json_schema` instead.c`tjdtd|j||S)Nrrrrr)rrrr4)rrrs rXr$zBaseModel.schemas1  Q. $$h\$RRrZWThe `schema_json` method is deprecated; use `model_json_schema` and json.dumps instead.rc tjdtdddl}ddlm}|j |j||fd|i|S) Nrrrrr)pydantic_encoderrdefault)rrrrdeprecated.jsonrdumpsr4)rrrrrrs rX schema_jsonzBaseModel.schema_json(sY  e. 5tzz  ! !8, ! O $   rZBThe `validate` method is deprecated; use `model_validate` instead.c\tjdtd|j|S)Nrrrr)rrVs rXvalidatezBaseModel.validate?s,  P. !!%((rZLThe `update_forward_refs` method is deprecated; use `model_rebuild` instead.c ztjdtd|r td|j dy)Nrrrz,`localns` arguments are not longer accepted.T)r)rrrrr)rlocalnss rXupdate_forward_refszBaseModel.update_forward_refsIs;  Z. JK K %rZHThe private method `_iter` will be removed and should no longer be used.crtjdtdddlm}|j |g|i|S)Nrrrrr)rrrrrrrr5r+rs rXrzBaseModel._iterXs;  V. /#~##D:4:6::rZWThe private method `_copy_and_set_values` will be removed and should no longer be used.crtjdtdddlm}|j |g|i|S)Nrrrrr)rrrrrrrs rXrzBaseModel._copy_and_set_valueses;  e. /2~224I$I&IIrZMThe private method `_get_value` will be removed and should no longer be used.crtjdtdddlm}|j |g|i|S)Nrrrrr)rrrrr _get_value)rr5r+rs rXrzBaseModel._get_valuess;  [. /(~((>t>v>>rZRThe private method `_calculate_keys` will be removed and should no longer be used.crtjdtdddlm}|j |g|i|S)Nrrrrr)rrrrr_calculate_keysrs rXrzBaseModel._calculate_keyss;  `. /-~--dDTDVDDrZ)rr returnNone)rzdict[str, FieldInfo])rzdict[str, ComputedFieldInfo])rdict[str, Any] | None)rrr\)rzset[str] | Nonerr rr)rzMapping[str, Any] | Nonerboolrr)rzLiteral['json', 'python'] | strr IncEx | Nonerrr Any | Noner bool | Nonerrrrrrrrrrr'bool | Literal['none', 'warn', 'error']rCallable[[Any], Any] | Nonerrrdict[str, Any])rz int | Nonerrrrrrrrrrrrrrrrrrrrrrrrrrrr) rrrrrztype[GenerateJsonSchema]rr2rz)Literal['any_of', 'primitive_type_array']rr)rztuple[type[Any], ...]rr)rr rr) rrrrrintrzMappingNamespace | Nonerr)rr rrrExtraValues | Nonerrrrrrrrrr)rzstr | bytes | bytearrayrrrrrrrrrrrr)rr rrrrrrrrrrrr)r"type[BaseModel]r#r*rr8)r'r8r#r+rr3)r+r rr)rr)rGz!type[Any] | tuple[type[Any], ...]rz3type[BaseModel] | _forward_ref.PydanticRecursiveRef)rr)rPzdict[int, Any] | Nonerr)rYrrr )rUrrVr rr)rUrrVr rz,Callable[[BaseModel, str, Any], None] | None)rqr rr)rdict[Any, Any])rvrrr)rr rr)r+zUnpack[ConfigDict])rrD)rr)rz_repr.ReprArgs)rrrrrrrrrrrrrDict[str, Any])rrrrrrrrrrrrrrrrrr rr)rr rr) rz str | bytesr str | NonerrrDeprecatedParseProtocol | Nonerrrr) rz str | Pathrrrrrrrrrr) r+AbstractSetIntStr | MappingIntStrAny | Nonerrrrrrrr)rrrrrr)rrrrrr rr)rVr rr)rr rr)r5r r+r rr )brS __module__ __qualname____doc__r,rN__annotations__ryrDecoratorInfosr|r~rr" NoInitFieldrr^rer r!r!rzrrjr __slots__r__pydantic_base_init__r&deprecated_instance_property classmethodrrrkrrrrrrr0r1r4rrrrrrr%r(r,r.rMrrr^rgr`rorrrtrwrrrrrr$Representationrrr __pretty__ __rich_repr__rtyping_extensionsrrrrArrrrrrrrr$rrrrrrr __classcell__)rWs@rXrBrBvsm D*4L&5'&@AA=&&S,1>1V22',,;E_KD^D^D`A`^$ONlFJ!#BIQGGE.3^3N77UPPX77$^]u"HHI0O0C0O0OUZ0[-[s(G(;(G(GU(SXSB2Q2E2Q2QW\2]/]A $@=#?#? f*$  ":!9!9 f"*"  #;-":": f#*#  dI('+H# ((7)7 ((@)@'',,NN`@DRW J19 $ $" $#!&"(- <@04!&= .=  =  =  = = = = = "&= = := .= = != D"" $ $" $#!&"(- <@04!&!?? ?  ?  ??????"&??:?.? !?" #?B05G+ $ CK$ $ $ 3 $  $ @$  $ $ L554 !'(48 9 9  9 "% 9 2 9  9 9 v #$('+" $#. .  . " . % . . . .  . . ` #$(" $#) *)  ) " )  ) ) )  ) ) V #$(" $## #  # " #  # # #  # # J&$$&$  $$2  ,  A>A <AF&*  j: K4 ?l fF 3  E 5 &n  ,%D-:((66M--@@''44L%%00J((66M&!!!bmq>>!!!W,  ,"!!"^imn!% $#!&"            o 0"!!"cnrs!% $#!&"/@0          -     t B!!!"grvw'x'!!! E$(04".' .'! .'  .' . .'.' .'  .'`!!! I$(04"""! "  " . "" "  "4!!! S '  '!!!"hswxFyF"!! i@D?C(, Fh=Fh= Fh & Fh  Fh Fh  FhP!!!"grvw"8LSS25S SxS!!!a "&;O  58 ad    $!!!"fquv)w)!!!V&  &"!!R]a;;"!!aJ J!!!W?  ?"!!\E ErZ) metaclassModelT)bound) __config__r __base__r __validators____cls_kwargs__r c yr\r rKrr rr rrr field_definitionss rXrCrCsrZ)rr r rrr c yr\rr s rXrCrCsrZc |tdtf}nt|ts|f}|xsi}i} i} |j D]J\} } t| tr0t | dk7rt d| dd| d| | <| d| | <F| | | <L|$tjd} | jd }| |d }|r||d <|||d <|r|j||j| |r||d <tj|}tj|||\}}}||ur||d<|j|||||fd|d|S)ao!!! abstract "Usage Documentation" [Dynamic Model Creation](../concepts/models.md#dynamic-model-creation) 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. __doc__: The docstring of the new model. __base__: The base class or classes for the new model. __module__: The name of the module that the model belongs to; if `None`, the value is taken from `sys._getframe(1)` __validators__: A dictionary of methods that validate fields. The keys are the names of the validation methods to be added to the model, and the values are the validation methods themselves. You can read more about functional validators [here](https://docs.pydantic.dev/2.9/concepts/validators/#field-validators). __cls_kwargs__: A dictionary of keyword arguments for class creation, such as `metaclass`. __qualname__: The qualified name of the newly created model. **field_definitions: Field definitions of the new model. Either: - a single element, representing the type annotation of the field. - a two-tuple, the first element being the type and the second element the assigned value (either a default or the [`Field()`][pydantic.Field] function). Returns: The new [model][pydantic.BaseModel]. Raises: PydanticUserError: If `__base__` and `__config__` are both passed. type[ModelT]rzField definition for z should a single element representing the type or a two-tuple, the first element being the type and the second element the assigned value (either a default or the `Field()` function).zcreate-model-field-definitionsrrrrS)r r r r rN)kwds__orig_bases__F)#__pydantic_reset_parent_namespace___create_model_module)rrBrr=rlenr/sys _getframe f_globalsrtypes resolve_bases prepare_class)rKrr rr rrr r!fieldsrf_namef_deff namespaceresolved_basesmetansr%s rXrCrCsX35 % (;#)rNF"$K*002 (  eU #5zQ'+F:6}}9 #((K "1XF6N"'K  ( MM! [[, 4?z ZI& )$0 .!( V$. .!((2N((^.YND"dX%'  R  -2'     rZ)rTrrUrrVr rr)rarBrUrrbr rr)rKrrConfigDict | Noner rrrr rr$dict[str, Callable[..., Any]] | Nonerrr rr!Any | tuple[str, Any]rr)rKrrr8r rrz'type[ModelT] | tuple[type[ModelT], ...]r rrr9rrr rr!r:rr$)rKrrr8r rrz.type[ModelT] | tuple[type[ModelT], ...] | Noner rrr9rrr rr!r:rr$)or  __future__r _annotationsr|r*r-rcollections.abcrrrr functoolsrtypingr r r r r rrrrrrrrrrrrrrr _internalrrrrr r!r"r#r$r%r& _migrationr'aliasesr(r)annotated_handlersr*r+configr,r-errorsr.r/ json_schemar0r1r2r3r4plugin._schema_validatorr5inspectr6pathlibr7r8r9r:_internal._namespace_utilsr;_internal._utilsr<r=deprecated.parser>DeprecatedParseProtocolr0r?r@rA__all__r=rrDr rrrrEobject_setattrrprYrcrhrtModelMetaclassrBrrSrCr^rrZrXrRs 3 .%    <55C    *,J+Buu>!KK<EEFF &&eCHotT&AB BS3s8WS% :N5N-OQXY\^cdkmqdq^rYrQsstyt%44 , +0v'UM QMXE-<<XEv0  + %);?,0#  "      9 *  /     %);?,0#  "    6  9 *  /    &%)?C!;?,0#__" _  _ = __9_*__/__D ) rZ