fL if3UdZddlmZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZmZmZmZmZddlmZmZmZmZdd lmZmZd d lmZd d lmZd d l m!Z!m"Z"d dlm#Z#ddl$m%Z%m&Z&ddl'm(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5erddl6m7Z8d dl9m:Z:Gdde8eZ; d& d'dZd*d"Z?e@eAejefZCd#eDd$<e d+d%ZEy),z0Private logic for creating pydantic dataclasses.) annotationsN) Generator)contextmanager)partial) TYPE_CHECKINGAnyClassVarProtocolcast) ArgsKwargsSchemaSerializerSchemaValidator core_schema) TypeAliasTypeIs)PydanticUndefinedAnnotation) FieldInfo)PluggableSchemaValidatorcreate_schema_validator)PydanticDeprecatedSince20)_config _decorators)collect_dataclass_fields)GenerateSchemaInvalidSchemaError)get_standard_typevars_map)set_dataclass_mocks) NsResolver)generate_pydantic_signature)LazyClassAttribute)DataclassInstance) ConfigDictcjeZdZUdZded<ded<ded<ded <d ed <d ed <ded<eddZy)PydanticDataclassaiA protocol containing attributes only available once a class has been decorated as a Pydantic dataclass. Attributes: __pydantic_config__: Pydantic-specific configuration settings for the dataclass. __pydantic_complete__: Whether dataclass 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_decorators__: Metadata containing the decorators defined on the dataclass. __pydantic_fields__: Metadata about the fields defined on the dataclass. __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the dataclass. __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the dataclass. zClassVar[ConfigDict]__pydantic_config__zClassVar[bool]__pydantic_complete__z ClassVar[core_schema.CoreSchema]__pydantic_core_schema__z$ClassVar[_decorators.DecoratorInfos]__pydantic_decorators__zClassVar[dict[str, FieldInfo]]__pydantic_fields__zClassVar[SchemaSerializer]__pydantic_serializer__z4ClassVar[SchemaValidator | PluggableSchemaValidator]__pydantic_validator__cyNclss e/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pydantic/_internal/_dataclasses.py__pydantic_fields_complete__z.PydanticDataclass.__pydantic_fields_complete__=s7:N)returnbool)__name__ __module__ __qualname____doc____annotations__ classmethodr4r0r5r3r&r&(sA 21--"BB!EE;;!;; TT : :r5r&cFt|}t||||}||_y)zCollect and set `cls.__pydantic_fields__`. Args: cls: The class. config_wrapper: The config wrapper instance. ns_resolver: Namespace resolver to use when getting dataclass annotations. ) ns_resolver typevars_mapconfig_wrapperN)rrr+)r2rAr?r@fieldss r3set_dataclass_fieldsrCAs,-S1L % |_ tC| | |_"d |_#y #t*$r'} |rt |d | j,d Yd } ~ yd } ~ wwxYw#t4$rt |YywxYw)aFinish building a pydantic dataclass. This logic is called on a class which has already been wrapped in `dataclasses.dataclass()`. This is somewhat analogous to `pydantic._internal._model_construction.complete_model_class`. Args: cls: The class. config_wrapper: The config wrapper instance. raise_errors: Whether to raise errors, defaults to `True`. ns_resolver: The namespace resolver instance to use when collecting dataclass fields and during schema building. _force_build: Whether to force building the dataclass, no matter if [`defer_build`][pydantic.config.ConfigDict.defer_build] is set. Returns: `True` if building a pydantic dataclass is successfully completed, `False` otherwise. Raises: PydanticUndefinedAnnotation: If `raise_error` is `True` and there is an undefined annotations. cZd}|}|jjt|||y)NT) self_instance)r-validate_pythonr )__dataclass_self__argskwargs__tracebackhide__ss r3__init__z$complete_dataclass..__init__vs.     00D&1IYZ0[r5z .__init__)rAr?F__post_init_post_parse__zVSupport for `__post_init_post_parse__` has been dropped, the method will not be called)r?r@ __signature__T)initrBvalidate_by_nameextra is_dataclass`N)titleztype[PydanticDataclass] dataclass)rJr&rKrrLrr6None)$rOr: config_dictr'rC defer_buildrhasattrwarningswarnrrrr"rr!r+rSrTrQgenerate_schemarname core_configr8 clean_schemarr r)rr9plugin_settingsr-r r,r() r2rArDr?rE original_initrOr@ gen_schemaschemaeras r3complete_dataclassrhUs:LLM\ #//0 :HCL,88C^U N66C s./ d % -S1L!J+ '**+<< &&  C++C0!,,3<<,@K((0 (# .C#)C !8S^^S%5%5{KQ_QoQo"C#36;"GC $C 1 '  C1QVVHA/  C s*'FF9 F6F11F69GGc<d|jvxr t|d S)afReturns `True` if the class is a stdlib dataclass and *not* a Pydantic dataclass. Unlike the stdlib `dataclasses.is_dataclass()` function, this does *not* include subclasses of a dataclass that are themselves not dataclasses. Args: cls: The class. Returns: `True` if the class is a stdlib dataclass, `False` otherwise. __dataclass_fields__r-)__dict__r\r1s r3is_stdlib_dataclassrls# "S\\ 1 `'#G_:`6``r5cd|i}tjdk\r|j|j|d<tjdk\r|jrd|d<|jdur|j|d<t j di|S) Ndefault)docro Tkw_onlyreprr0)sys version_info descriptionrtru dataclassesfield)pydantic_field field_argss r3as_dataclass_fieldr}s"+^! dataclass.Field(default=FieldInfo(repr=False), repr=True, ...) @pydantic_dc.dataclass class B(A): b: int = pydantic.Field(repr=False) ``` When passing `B` to the stdlib `@dataclass` decorator, it will look for fields in the parent classes and reuse them directly. When this context manager is active, `A` will be temporarily patched to be equivalent to: ```python {test="skip" lint="skip"} @stdlib_dc.dataclass class A: a: int = stdlib_dc.field(default=Field(repr=False), repr=False) ``` !!! note This is only applied to the bases of `cls`, and not `cls` itself. The reason is that the Pydantic dataclass decorator "owns" `cls` (in the previous example, `B`). As such, we instead modify the fields directly (in the previous example, we simply do `setattr(B, 'b', as_dataclass_field(pydantic_field))`). !!! note This approach is far from ideal, and can probably be the source of unwanted side effects/race conditions. The previous implemented approach was mutating the `__annotations__` dict of `cls`, which is no longer a safe operation in Python 3.14+, and resulted in unexpected behavior with field ordering anyway. rNrjTrr)__mro__rkgetitems isinstancernrrxrtruappendr copyrvrw) r2original_fields_listbase dc_fields field_namerz&dc_fields_with_pydantic_field_defaultsrn new_dc_fieldrBoriginal_fieldsoriginal_fields r3patch_base_fieldsrsn=? AB57;}}7H7HI_ac7d &/__%62 ! E%--3**6%--:O:OSXS`S`SeSemqSq  2 .2  2 ' '4Z([ \%K%Q%Q%S 5! Ey%--8 $yy/ ##w.7??+/L(<A+F 2F>8B'F> F$.F>)F;;F>r/)r2ztype[StandardDataclass]rA_config.ConfigWrapperr?NsResolver | Noner6rY) r2 type[Any]rArrDr7r?rrEr7r6r7)r2rr6zTypeIs[type[StandardDataclass]])r{rr6zdataclasses.Field[Any])r2rr6zGenerator[None])Fr; __future__r _annotationsrryrvr]collections.abcr contextlibr functoolsrtypingrrr r r pydantic_corer r rrtyping_extensionsrrerrorsrrBrplugin._schema_validatorrrrrr_fieldsr_generate_schemarr _genericsr _mock_val_serr_namespace_utilsr _signaturer!_utilsr" _typeshedr#StandardDataclassconfigr$r&rCrhrlr}dictstrFieldr~r<rr0r5r3rs162  %%?? 00X0"-@0.(3&@#;-x;8&*% %)%#% %0%) i i)i i # i  i iX a+$3 1 1# 667)7U4U4r5