U nf2@sdZddlmZddlZddlmZmZddlmZddl m Z ddl m Z m Z dd lmZmZejrdd lmZdd lmZmZmZdd lmZdd lmZedeefdGddde jZne jZdZedZ Gdddeej!e edZ"dS)z%RootModel class and type definitions.) annotationsN)copydeepcopy)PydanticUndefined)PydanticUserError)_model_construction_repr) BaseModel_object_setattr)Any)LiteralSelfdataclass_transform)Field) PrivateAttrF)kw_only_defaultfield_specifiersc@s eZdZdS)_RootModelMetaclassN)__name__ __module__ __qualname__rrA/opt/hc_python/lib/python3.8/site-packages/pydantic/root_model.pyrsr) RootModelRootModelRootTypecseZdZUdZdZdZdZded<fddZe fddd d d Z de _ e d/dd d dfdd Z ddddZdddddZd dddZd0dd dddZejrdddddddddddd d!d"d"d#d$d$d$d$d$d%d$d"d& d'd(Zd"d$d)fd*d+ Zd,dd-d.ZZS)1raUsage docs: https://docs.pydantic.dev/2.8/concepts/models/#rootmodel-and-custom-root-types A Pydantic `BaseModel` for the root object of the model. Attributes: root: The root object of the model. __pydantic_root_model__: Whether the model is a RootModel. __pydantic_private__: Private fields in the model. __pydantic_extra__: Extra fields in the model. TNrrootc s2|jd}|dk r tdddtjf|dS)Nextraz<`RootModel` does not support setting `model_config['extra']`zroot-model-extra)code)Z model_configgetrsuper__init_subclass__)clskwargsr __class__rrr!6s zRootModel.__init_subclass__None)rreturncKs0d}|r|tk rtd|}|jj||ddS)NTz_"RootModel.__init__" accepts either a single positional argument or arbitrary keyword arguments)Z self_instance)r ValueErrorZ__pydantic_validator__Zvalidate_python)selfrdataZ__tracebackhide__rrr__init__>szRootModel.__init__zset[str] | Noner)r _fields_setr'cstj||dS)aSCreate a new model using the provided root object and update fields set. Args: root: The root object of the model. _fields_set: The set of fields to be updated. Returns: The new model. Raises: NotImplemented: If the model is not a subclass of `RootModel`. )rr,)r model_construct)r"rr,r$rrr-JszRootModel.model_constructzdict[Any, Any])r'cCs|j|jdS)N__dict____pydantic_fields_set__r.r)rrr __getstate__ZszRootModel.__getstate__)stater'cCs$t|d|dt|d|ddS)Nr0r/)r )r)r3rrr __setstate__`szRootModel.__setstate__cCs:t|}||}t|dt|jt|dt|j|S)z$Returns a shallow copy of the model.r/r0)type__new__r rr/r0)r)r"mrrr__copy__ds  zRootModel.__copy__zdict[int, Any] | None)memor'cCs>t|}||}t|dt|j|dt|dt|j|S)z!Returns a deep copy of the model.r/)r9r0)r5r6r rr/rr0)r)r9r"r7rrr __deepcopy__ls  zRootModel.__deepcopy__pythonF) modeincludeexcludecontextby_alias exclude_unsetexclude_defaults exclude_none round_tripwarningsserialize_as_anyz!Literal[('json', 'python')] | strr zdict[str, Any] | Noneboolz)bool | Literal[('none', 'warn', 'error')]) r<r=r>r?r@rArBrCrDrErFr'c CsdS)aThis method is included just to get a more accurate return type for type checkers. It is included in this `if TYPE_CHECKING:` block since no override is actually necessary. See the documentation of `BaseModel.model_dump` for more details about the arguments. Generally, this method will have a return type of `RootModelRootType`, assuming that `RootModelRootType` is not a `BaseModel` subclass. If `RootModelRootType` is a `BaseModel` subclass, then the return type will likely be `dict[str, Any]`, as `model_dump` calls are recursive. The return type could even be something different, in the case of a custom serializer. Thus, `Any` is used here to catch all of these cases. Nr) r)r<r=r>r?r@rArBrCrDrErFrrr model_dumpxszRootModel.model_dump)otherr'cs2t|tstS|jdj|jdjko0t|SNr) isinstancerNotImplementedZ model_fields annotationr __eq__)r)rIr$rrrNs zRootModel.__eq__z_repr.ReprArgsccsd|jfVdSrJ)rr1rrr __repr_args__szRootModel.__repr_args__)N)N)rrr__doc__Z__pydantic_root_model__Z__pydantic_private__Z__pydantic_extra____annotations__r!rr+Z__pydantic_base_init__ classmethodr-r2r4r8r:typing TYPE_CHECKINGrHrNrO __classcell__rrr$rr#s:     (r) metaclass)#rP __future__rZ _annotationsrSrrZ pydantic_corerr _internalrr mainr r rTr typing_extensionsr rrfieldsrZPydanticModelFieldrZPydanticModelPrivateAttrZModelMetaclassr__all__TypeVarrGenericrrrrrs$