fL iI BdZddlmZddlZddlZddlZddlZddlm Z m Z m Z m Z m Z mZmZmZddlmZddlmZmZddlmZmZmZmZdd lmZdd lmZdd lm Z dd l!m"Z"dd l#m$Z$m%Z%m&Z&e r ddl'm(Z(ddl)m*Z*dZ+edZ,ejZdk\reej\e$e&feddddddddddd d%dZ/eej\e$e&feddddddddddd d&dZ/n|eej\e$e&feddddddddd d'dZ/eej\e$e&feddddddddd d(dZ/eej\e$e&f d)ddddddddddd d*dZ/d+dZ0ee1Z2ejZdkrd,d Z3e3ejh_5ddd!dd" d-d#Z6d.d$Z7y)/z7Provide an enhanced dataclass that performs validation.) annotationsN) TYPE_CHECKINGAnyCallableGenericLiteralNoReturnTypeVaroverload)warn) TypeGuarddataclass_transform)_config _decorators_namespace_utils _typing_extra) _dataclasses)getattr_migration) ConfigDict)PydanticUserError)Field FieldInfo PrivateAttr)PydanticDataclass)MappingNamespace) dataclassrebuild_dataclass_T )field_specifiersFT. initrepreqorder unsafe_hashfrozenconfigvalidate_on_initkw_onlyslotsc yNr$s Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pydantic/dataclasses.pyrrs c yr0r1) _clsr%r&r'r(r)r*r+r,r-r.s r2rr0s#&r3r%r&r'r(r)r*r+r,cyr0r1r6s r2rrCs r3cyr0r1) r5r%r&r'r(r)r*r+r,s r2rrRs#&r3c  |dusJd|dusJdtjdk\r| d ni d  fd } || S| |S)a!!! abstract "Usage Documentation" [`dataclasses`](../concepts/dataclasses.md) A decorator used to create a Pydantic-enhanced dataclass, similar to the standard Python `dataclass`, but with added validation. This function should be used similarly to `dataclasses.dataclass`. Args: _cls: The target `dataclass`. init: Included for signature compatibility with `dataclasses.dataclass`, and is passed through to `dataclasses.dataclass` when appropriate. If specified, must be set to `False`, as pydantic inserts its own `__init__` function. repr: A boolean indicating whether to include the field in the `__repr__` output. eq: Determines if a `__eq__` method should be generated for the class. order: Determines if comparison magic methods should be generated, such as `__lt__`, but not `__eq__`. unsafe_hash: Determines if a `__hash__` method should be included in the class, as in `dataclasses.dataclass`. frozen: Determines if the generated class should be a 'frozen' `dataclass`, which does not allow its attributes to be modified after it has been initialized. If not set, the value from the provided `config` argument will be used (and will default to `False` otherwise). config: The Pydantic config to use for the `dataclass`. validate_on_init: A deprecated parameter included for backwards compatibility; in V2, all Pydantic dataclasses are validated on init. kw_only: Determines if `__init__` method parameters must be specified by keyword only. Defaults to `False`. slots: Determines if the generated class should be a 'slots' `dataclass`, which does not allow the addition of new attributes after instantiation. Returns: A decorator that accepts a class as its argument and returns a Pydantic `dataclass`. Raises: AssertionError: Raised if `init` is not `False` or `validate_on_init` is `False`. Fz7pydantic.dataclasses.dataclass only supports init=Falsez-validate_on_init=False is no longer supportedr )r-r.c vddlm}||rtd|jdd|}t d|j D}|s.,t |d r td |jd td n t|d d}tj|}tjj|}|j||j }t#j$|rNd}|f}t'|t(rt(|j*} || fz}t-j.|j|}/|j0r1td|jdtd n|j0xsdt3j4|} | D]@} t|| d} t7| t8s!t;|| t#j<| Bt#j>|5tAjB|fdd}ddd|jDrp|jFtIjJ|jFdfd } | jMd||_#r"t |dsdd}dd}||_'||_(d|_)||_*||_t|dd}|jV|_+tXjZdk\r|||_.||_.|j^|_/tatb|_2d|_3t#jh||d|S#1swY"xYw)zCreate a Pydantic dataclass from a regular dataclass. Args: cls: The class to create the Pydantic dataclass from. Returns: A Pydantic dataclass. r)is_model_classz(Cannot create a Pydantic dataclass from z" as it is already a Pydantic modelzdataclass-on-model)codec3FK|]}tj|ywr0) dataclasses is_dataclass).0bases r2 z6dataclass..create_dataclass..s ZD!9!9$!? Zs!N__pydantic_config__z[`config` is set via both the `dataclass` decorator and `__pydantic_config__` for dataclass zK. The `config` specification from `dataclass` decorator will take priority.)category stacklevelzN`frozen` is set via both the `dataclass` decorator and `config` for dataclass zW.This is not recommended. The `frozen` specification on `dataclass` will take priority.FT)r%r&r'r(r)r*c<r |||St|}t||d}t|tr|j ||yt|t j r|jj||y|jj|||yr0) typegetattr isinstanceproperty__set__ functoolscached_property__dict__ __setitem____pydantic_validator__validate_assignment)instancenamevalueinst_clsattrfrozen_original_setattrs r2validated_setattrz>dataclass..create_dataclass..validated_setattrs+HdEBB>xt4dH-LL51i&?&?@%%11$>33GGRVX]^r3 __setstate__cztj|Dcgc]}t||jc}Scc}wr0)r>fieldsrIrT)selffs r2_dataclass_getstatez@dataclass..create_dataclass.._dataclass_getstates,;F;M;Md;STaGD!&&1TTTs8cttj||D]&\}}tj ||j |(yr0)zipr>r]object __setattr__rT)r^statefieldrUs r2_dataclass_setstatez@dataclass..create_dataclass.._dataclass_setstates?(+K,>,>t,De(LD u**4UCDr3__firstlineno__)r! ) raise_errors)rSrrTstrrUrreturnNone)r^rrl list[Any])r^rrernrlrm)5_internal._utilsr;r__name__any __bases__hasattrr UserWarningrIr ConfigWrapperrDecoratorInfosbuildupdate_from_config__doc___pydantic_dataclassesis_stdlib_dataclass issubclassr__parameters__types new_classr*rsafe_get_annotationsrJrsetattras_dataclass_fieldpatch_base_fieldsr>rrRrdrMwraps__get__ __getstate__r[__is_pydantic_dataclass____pydantic_decorators__ __module__sys version_inforh __qualname__ classmethod_pydantic_fields_complete__pydantic_fields_complete____pydantic_complete__complete_dataclass)clsr; original_clshas_dataclass_base config_dictconfig_wrapper decorators original_docbases generic_basecls_anns field_name field_valuerZr`rg firstlinenorXrYr+r'r*kwargsr(r&r.r)s @@r2create_dataclassz#dataclass..create_dataclasssM 5 # #:3<<.Hjk)   ! ZCMM ZZ!f&8WSJ_=` mnqnznzm{|\]$  !' 2fEZ\`8a  ..{; //55c: %%n5 {{ 4 4S 9 L FE#w'&s'9'9: ///#,,6C  G$$deheqeqdtumm( %++4uG!55c:" `J"#z48K+y1Z)>)Q)QR])^_  `# 4 4S 9 '' '  C   - -"  __S__ - _. _077cBCOWS.9UD$7 #6 )-%&0#" l,=tD %00   w &;+B,7L ("-C '44+67P+Q($)! 00nSXY S  s 0L..L8)r type[Any]rltype[PydanticDataclass])rr) r5r%r&r'r(r)r*r+r,r-r.rrs `````` ` @r2rrbsn^ 5=SSS= 5 (Y*YY ( 7"$u5^^@ $| G1A$1GGr3cVtd|jjDS)zReturn whether the fields where successfully collected (i.e. type hints were successfully resolves). This is a private property, not meant to be used outside Pydantic. c34K|]}|jywr0) _complete)r@ field_infos r2rBz,_pydantic_fields_complete..AsW z##Ws)all__pydantic_fields__values)rs r2rr<s$ Wc6M6M6T6T6VW WWr3)r! ctd)a9This function does nothing but raise an error that is as similar as possible to what you'd get if you were to try calling `InitVar[int]()` without this monkeypatch. The whole purpose is just to ensure typing._type_check does not error if the type hint evaluates to `InitVar[]`. z 'InitVar' object is not callable) TypeError)argsrs r2 _call_initvarrJs :;;r3rD)forcerj_parent_namespace_depth_types_namespacec`|s |jrydD]}||jvst||d|_||}n#|dkDrtj|dxsi}ni}t j |}tj|tj|jd||d S) axTry to rebuild the pydantic-core schema for the dataclass. 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. This is analogous to `BaseModel.model_rebuild`. Args: cls: The class to rebuild the pydantic-core schema for. force: Whether to force the rebuilding of the 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`. N)__pydantic_core_schema__rQ__pydantic_serializer__FrT) parent_depthr)parent_namespace)check)rj ns_resolver _force_build) rrOdelattrrparent_frame_namespacer NsResolverrzrrrurC)rrrjrrrW rebuild_nsrs r2rrTs4 S..a 3<<  C   !&C#% 1 $"99G^fjkqoq  "--#K ! 3 3 c55UC!   r3cl d|jvxrtj|S#t$rYywxYw)zWhether a class is a pydantic dataclass. Args: class_: The class. Returns: `True` if the class is a pydantic dataclass, `False` otherwise. rF)rOr>r?AttributeError)class_s r2is_pydantic_dataclassrs9*foo=b+BZBZ[aBbb s $' 33)r%Literal[False]r&boolr'rr(rr)rr*rr+ ConfigDict | type[object] | Noner, bool | Noner-rr.rrl-Callable[[type[_T]], type[PydanticDataclass]])r5type[_T]r%rr&rr'rr(rr)rr*rr+rr,rr-rr.rrlr)r%rr&rr'rr(rr)rr*rr+rr,rrlr)r5rr%rr&rr'rr(rr)rr*rr+rr,rrlrr0)r5ztype[_T] | Noner%rr&rr'rr(rr)rr*rr+rr,rr-rr.rrlzGCallable[[type[_T]], type[PydanticDataclass]] | type[PydanticDataclass])rrrlr)rrrrrlr ) rrrrrjrrintrzMappingNamespace | Nonerlr)rrrlz"TypeGuard[type[PydanticDataclass]])8ry __future__r _annotationsr>rMrr~typingrrrrrr r r warningsr typing_extensionsr r _internalrrrrrrz _migrationrr+rerrorsrr]rrr_internal._dataclassesr_internal._namespace_utilsr__all__rrrfrrrp __getattr__rInitVar__call__rrr1r3r2rs=2 ^^^<LL<)%119< * T]w;+<+