Files
cms-website/.deps_siteforge_v812/pydantic/__pycache__/dataclasses.cpython-312.pyc
T

140 lines
17 KiB
Plaintext
Raw Normal View History

Ë
ðÅÙjJã
óF—dZddlmZddlZddlZddlZddlZddlm Z m
Z
m Z m Z m
Z
mZmZmZddlmZddlmZmZddlmZmZmZmZmZdd lmZdd
lmZdd l m!Z!dd l"m#Z#dd
l$m%Z%m&Z&m'Z'e r ddl(m)Z)ddl*m+Z+dZ,ed«Z-ej\dk\r‰eej^e%e'f¬«edddddddddddœ
d%d„««Z0eej^e%e'f¬«edddddddddddœ
d&d„««Z0n|eej^e%e'f¬«edddddddddœ d'd„««Z0eej^e%e'f¬«edddddddddœ d(d„««Z0eej^e%e'f¬« d)dddddddddddœ
d*d„«Z0d+d„Z1ee2«Z3ej\dkrd,d „Z4e4ejj_6ddd!dd"œ d-d#„Z7d.d$„Z8y)/z7Provide an enhanced dataclass that performs validation.é)Ú annotationsN)Ú
TYPE_CHECKINGÚAnyÚCallableÚGenericÚLiteralÚNoReturnÚTypeVarÚoverload)Úwarn)Ú TypeGuardÚdataclass_transformé)Ú_configÚ _decoratorsÚ
_mock_val_serÚ_namespace_utilsÚ
_typing_extra)Ú _dataclasses)Úgetattr_migration)Ú
ConfigDict)ÚPydanticUserError)ÚFieldÚ FieldInfoÚ PrivateAttr)ÚPydanticDataclass)ÚMappingNamespace)Ú dataclassÚrebuild_dataclassÚ_T©éé
)Úfield_specifiersFT.©
ÚinitÚreprÚeqÚorderÚ unsafe_hashÚfrozenÚconfigÚvalidate_on_initÚkw_onlyÚslotsc
ó—y©N©r%s
úXC:\Users\30997\AppData\Local\Temp\pip-target-6g32zz5s\lib\python\pydantic/dataclasses.pyrrs€ð óc
ó—yr1r2) Ú_clsr&r'r(r)r*r+r,r-r.r/s r3rr0s€ð#&r4©r&r'r(r)r*r+r,r-có—yr1r2r7s r3rrCs€ð r4có—yr1r2) r6r&r'r(r)r*r+r,r-s r3rrRs€ð#&r4c
󦇇‡‡‡‡‡
‡ —|dusJd«‚|dusJd«‚tjdk\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 óz•‡‡—ddlm}||«rtd|j›d�d¬«‚|}t d„|j
D««}|s.‰�,t
|d «r td
|j›d �td ¬
«‰�‰n t|d d«}tj|«}tjj|d¬«}|j|«|j }t#j$|«rNd}|f}t'|t(«rt(|j*} || fz}t-j.|j|«}‰�/‰Š|j0r1td|j›d�td ¬
«n|j0xsdŠt3j4|«}
|
D]@} t|| d«} t7| t8«sŒ!t;|| t#j<| ««ŒBt#j>|«5tAjB|fd‰‰‰‰‰dœ‰¤Ž}ddd«|jDrp|jFŠtIjJ|jF«dˆˆfd„ «}
|
jMd|«|_#‰r"t
|d«sdd„}dd„}||_'||_(d|_)||_*||_t|dd«}|jV|_+tXjZdk\r|�||_.||_.|j^|_/tatb«|_2d|_3t#jh||d¬«|S#1swY�Œ"xYw)zÃCreate 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)Úcodec3óFK—|]}tj|«–—Œy­wr1)Ú dataclassesÚ is_dataclass)Ú.0Úbases r3Ú <genexpr>z6dataclass.<locals>.create_dataclass.<locals>.<genexpr>®sèø€Ð ZÉMÀD¤×!9Ñ!9¸$×!?ÉMùs‚!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Ú
stacklevelT)Úreplace_wrapped_methodszN`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.F)r&r'r(r)r*r+có<•—‰r
‰|||«St|«}t||d«}t|t«r|j ||«yt|t
j «r|jj||«y|jj|||«yr1) ÚtypeÚgetattrÚ
isinstanceÚpropertyÚ__set__Ú functoolsÚcached_propertyÚ__dict__Ú __setitem__Ú__pydantic_validator__Úvalidate_assignment)ÚinstanceÚnameÚvalueÚinst_clsÚattrÚfrozen_Úoriginal_setattrs €€r3Úvalidated_setattrz>dataclass.<locals>.create_dataclass.<locals>.validated_setattrþs„ø€áÙ+¨H°d¸EÓBÐBÜ ›>�ܘx¨¨tÓ4�ä˜d¤HÔ-Ø—L‘L ¨5Õ1Ü ¤i×&?Ñ&?Ô@Ø×%Ñ%×1Ñ1°$¸Õ>à×3Ñ3×GÑGÈÐRVÐX]Õ^r4Ú __setstate__cóz—tj|«D�cgc]}t||j«‘Œc}Scc}wr1)r?ÚfieldsrKrV)ÚselfÚfs r3Ú_dataclass_getstatez@dataclass.<locals>.create_dataclass.<locals>._dataclass_getstates2€Ü;F×;MÑ;MÈdÔ;SÓTÑ;S°aœG D¨!¯&©&Õ1Ð;SÑTÐTùÒTs˜8có”—ttj|«|«D]&\}}tj ||j
|«Œ(yr1)Úzipr?r_ÚobjectÚ __setattr__rV)r`ÚstateÚfieldrWs r3Ú_dataclass_setstatez@dataclass.<locals>.create_dataclass.<locals>._dataclass_setstates9€Ü(+¬K×,>Ñ,>¸tÓ,DÀeÖ(L™ ˜˜uÜ×*Ñ*¨4°·±¸UÕCñ)Mr4Ú__firstlineno__)r"é
)Ú raise_errors)rUrrVÚstrrWrÚreturnÚNone)r`rrnú list[Any])r`rrgrprnro)5Ú_internal._utilsr<rÚ__name__ÚanyÚ __bases__Úhasattrr Ú UserWarningrKrÚ
ConfigWrapperrÚDecoratorInfosÚbuildÚupdate_from_configÚ__doc__Ú_pydantic_dataclassesÚis_stdlib_dataclassÚ
issubclassrÚ__parameters__ÚtypesÚ new_classr+rÚsafe_get_annotationsrLrÚsetattrÚas_dataclass_fieldÚpatch_base_fieldsr?rrTrfrOÚwrapsÚ__get__Ú __getstate__r]Ú__is_pydantic_dataclass__Ú__pydantic_decorators__Ú
__module__ÚsysÚ version_inforjÚ __qualname__Ú classmethodÚ_pydantic_fields_completeÚ__pydantic_fields_complete__Ú__pydantic_complete__Úcomplete_dataclass)Úclsr<Ú original_clsÚhas_dataclass_baseÚ config_dictÚconfig_wrapperÚ
decoratorsÚ original_docÚbasesÚ generic_baseÚcls_annsÚ
field_nameÚ field_valuer\rbriÚ firstlinenorZr[r,r(r+Úkwargsr)r'r/r*s @@€€€€€€€€r3Úcreate_dataclassz#dataclass.<locals>.create_dataclass™sEú€õ 5á ˜#Ô Ü#Ø:¸3¿<¹<¸.ÐHjÐkØ)ôð
ð
ˆ ô!Ñ ZÈCÏMÊMÓ ZÓZÐÙ! fÐ&8¼WÀSÐJ_Ô=`Ü ØmÐnq×nzÑnzÐm{ð|\ð]ä$Øõ 
ð!'Ð 2‘f¼ÀÐEZÐ\`Ó8aˆ Ü ×.Ñ.¨{Ó;ˆÜ ×/Ñ/×5Ñ5°cÐSWÐ5ÓXˆ
Ø×%Ñ% nÔ5ð
—{‘{ˆ ä × 4Ñ 4°SÔ 9ð ˆLð
�FˆEܘ#œwÔ'Ü& s×'9Ñ'9Ñ:� Ø  Ñ/�Ü—/‘/ #§,¡,°Ó6ˆCð Р؈GØ×$Ò$äØdÐeh×eqÑeqÐdtðumðmä(Ø ö ð%×+Ñ+Ò4¨uˆGô!×5Ñ5°cÓ:ˆÛ"ˆJô" # z°4Ó8ˆKܘ+¤yÕ1ܘ˜ZÔ)>×)QÑ)QÐR]Ó)^Õ_ð #ô#×
4Ñ
4°SÕ
9Ü×'Ñ'Øð
ðØØØØ'Øñ
ðñ
ˆC÷:ð × -Ò -Ø"Ÿ™Ð ä
�_‰_˜SŸ_™_Ó
-õ
_ó.ð
_ð0×7Ñ7¸¸cÓBˆCŒOáœW S¨.Ô9óUóDð$7�Ô Ø#6�Ô ð)-ˆÔ%Ø&0ˆÔ#Ø"ˆŒ ä˜lÐ,=¸tÓDˆ Ø%×0Ñ0ˆŒÜ × Ñ ˜wÒ &¨;Ð+Bð,7ˆLÔ (Ø"-ˆCÔ Ø'×4Ñ4ˆÔÜ+6Ô7PÓ+QˆÔ(Ø$)ˆÔ!ô ×0Ñ0°°nÐSXÕY؈
÷S:Ñ
9ús Ç2L0Ì0L:)r”ú type[Any]rnútype[PydanticDataclass])rŒr�)
r6r&r'r(r)r*r+r,r-r.r/r¢r¡s
`````` ` @r3rrbsnÿ€ð^ �5‰=ÐSÐSÓSˆ=Ø  5Ñ (ÐYÐ*YÓYÐ (ä
×ј7Ò"Ø$¨uÑ5‰àˆ÷^ô^ð@ $˜|Ð ÐGÑ1AÀ$Ó1GÐGr4cóV—td„|jj«D««S)z®Return whether the fields were successfully collected (i.e. type hints were successfully resolved).
This is a private helper, not meant to be used outside Pydantic.
c3ó4K—|]}|j–—Œy­wr1)Ú _complete)rAÚ
field_infos r3rCz,_pydantic_fields_complete.<locals>.<genexpr>Asèø€ÐWÑ6V¨
ˆz×#Õ#Ñ6Vùs‚)ÚallÚ__pydantic_fields__Úvalues)r”s r3r�r�<s$€ô
ÑW°c×6MÑ6M×6TÑ6TÔ6VÓWÓ WÐWr4)r"é có—td«‚)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[<parameter>]`.
z 'InitVar' object is not callable)Ú TypeError)Úargsr¡s r3Ú
_call_initvarr°Js€ô
Ð:Ó;Ð;r4rE)ÚforcerlÚ_parent_namespace_depthÚ_types_namespacecóª—|s
|jrydD]B}||jvsŒtt||«tj
«rŒ7t
||«ŒDd|_|�|}n#|dkDrtj|d¬«xsi}ni}tj|¬«}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__rSÚ__pydantic_serializer__FrT)Ú parent_depthr±)Úparent_namespace)Úcheck)rlÚ ns_resolverÚ _force_build)r’rQrLrKrÚ
MockValSerÚdelattrrÚparent_frame_namespacerÚ
NsResolverr|r“rrwrD)r”r±rlr²r³rYÚ
rebuild_nsrºs r3rrTsÓ€ñ4 �S×.Ò.ØãaˆØ �3—<‘<Ò ¬