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

726 lines
74 KiB
Plaintext
Raw Normal View History

Ë
ðÅÙjg@ã%ó —UdZddlmZddlZddlZddlZddlZddlm Z m
Z
ddl m Z ddlm Z
ddlmZddlmZmZmZmZmZmZmZmZdd lmZddlZddlZdd
lmZmZdd lm Z m!Z!m"Z"m#Z#m$Z$dd l%m&Z&dd
l'm(Z(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6ddl7m8Z8m9Z9ddl:m;Z;m<Z<m=Z=ddl>m?Z?ddl@mAZAmBZBddlCmDZDddlmEZEer ddlFmGZGddlHmIZIdZJeZKdeLd<ejšdk\rddlZejHe$zZNdeLd<ne$ZNdeLd<Gd„d e"d!¬"«ZOGd#„d$eOd!¬"«ZPGd%„d&e"d'¬(«ZQeGd)„d*e4j¤««ZSGd+„d,e"«ZTid-d.“d/d“d0d“d1d“d2d“d3d“d4d“d5d“d6d“d7d“d8d“d9d“d:d“d;d“d<d“d=d“d>d“d'dddd?œ¥ZUieU¥ddddddddddddddd@œ¥ZVedA«ZWeeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKdBœ" d]dD„«Z eeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKdEœ! d^dF„«Z eeKeKeKeKeKeKeKeKeKeKeKeKeKeKd.eKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKdBœ" d_dG„«Z eeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKdEœ! d`dH„«Z eeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKdBœ" dadI„«Z eeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKdBœ" dbdJ„«Z efeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKeKdKœ# dcdL„Z eXej²e «j´«Z[e[j¹dC«GdM„dNe4j¤«Z]ed!dOœ dddP„«Z^ed!dOœ dedQ„«Z^ed!dOœ dfdR„«Z^efdd!dSœ dgdT„Z^ej¾dhie3jÀ¤ŽGdU„dV««ZadidW„ZbedX«ZcedjdY„«Zdedddddddddd'edZœ dkd[„«Zd dlddddddddddedZœ dmd\„Zdy)nzDefining fields on models.é)Ú annotationsN)ÚCallableÚMapping)Úcopy)ÚField)Úcached_property)Ú
TYPE_CHECKINGÚ AnnotatedÚAnyÚClassVarÚLiteralÚTypeVarÚfinalÚoverload)Úwarn)ÚMISSINGÚPydanticUndefined)ÚSelfÚ TypeAliasÚ TypedDictÚUnpackÚ
deprecated)Útyping_objects)ÚUNKNOWNÚAnnotationSourceÚForbiddenQualifierÚ QualifierÚinspect_annotationé)Útypes)Ú _decoratorsÚ_fieldsÚ _genericsÚ_internal_dataclassÚ_reprÚ
_typing_extraÚ_utils)ÚGlobalsNamespaceÚMappingNamespace)Ú AliasChoicesÚAliasGeneratorÚ AliasPath)ÚJsonDict)ÚPydanticForbiddenQualifierÚPydanticUserError)ÚPydanticJsonSchemaWarning)ÚPydanticDeprecatedSince20)Ú
ConfigWrapper)ÚReprArgs)rÚ FieldInfoÚ PrivateAttrÚcomputed_fieldr Ú_Unset)éé
rÚ
Deprecatedcóz—eZdZUdZded<ded<ded<ded <d
ed <ded <ded
<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded <ded!<ded"<ded#<d$ed%<ded&<ded'<ded(<d)ed*<d+ed,<d-ed.<d/ed0<ded1<ded2<d3ed4<ded5<ded6<ded7<ded8<ded9<y:);Ú_FromFieldInfoInputsz[This class exists solely to add type checking for the `**kwargs` in `FieldInfo.from_field`.útype[Any] | NoneÚ
annotationú:Callable[[], Any] | Callable[[dict[str, Any]], Any] | NoneÚdefault_factoryú
str | NoneÚaliasú
int | NoneÚalias_priorityú%str | AliasPath | AliasChoices | NoneÚvalidation_aliasÚserialization_aliasÚtitleú&Callable[[str, FieldInfo], str] | NoneÚfield_title_generatorÚ descriptionúlist[Any] | NoneÚexamplesú bool | NoneÚexcludeúCallable[[Any], bool] | NoneÚ
exclude_ifú!annotated_types.SupportsGt | NoneÚgtú!annotated_types.SupportsGe | NoneÚgeú!annotated_types.SupportsLt | NoneÚltú!annotated_types.SupportsLe | NoneÚleú float | NoneÚ multiple_ofÚstrictÚ
min_lengthÚ
max_lengthústr | re.Pattern[str] | NoneÚpatternÚ
allow_inf_nanÚ
max_digitsÚdecimal_placesz(Literal['smart', 'left_to_right'] | NoneÚ
union_modeú str | types.Discriminator | NoneÚ
discriminatorúDeprecated | str | bool | Nonerú,JsonDict | Callable[[JsonDict], None] | NoneÚjson_schema_extraÚfrozenÚvalidate_defaultÚboolÚreprÚinitÚinit_varÚkw_onlyÚcoerce_numbers_to_strÚ fail_fastN©Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú__annotations__©óúSC:\Users\30997\AppData\Local\Temp\pip-target-6g32zz5s\lib\python\pydantic/fields.pyr<r<2sÞ…Ùeð!Ó ØOÓOØ ÓØÓØ;Ó;Ø#Ó#Ø ÓØAÓAØÓØÓØ
ÓØ,Ó,Ø)Ó)Ø)Ó)Ø)Ó)Ø)Ó)ØÓØ ÓØÓØÓØ
)Ó)ØÓØÓØÓØ8Ó8Ø3Ó3Ø.Ó.ØCÓCØ ÓØ!Ó!Ø
ƒJØ
ÓØÓØ
ÓØ&Ó&ØÔrzr<F)Útotalcó—eZdZUdZded<y)Ú_FieldInfoInputszYThis class exists solely to add type checking for the `**kwargs` in `FieldInfo.__init__`.r ÚdefaultNrsryrzr{r~r~\s
…Ùcà
„Lrzr~có,—eZdZUded<ded<ded<y)Ú_FieldInfoAsDictr r>ú list[Any]Úmetadataúdict[str, Any]Ú
attributesN)rtrurvrxryrzr{r�r�bs…àƒOØÓØÔrzr�T)ÚclosedcóŠ—eZdZUdZded<ded<ded<ded <d
ed <d ed
<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded <d!ed"<ded#<ded$<ded%<d&ed'<d(Zejejejejejejejejd)d)d)d)d)d)ej d*œZd+ed,<dHd-„ZeefdId.„«Zeej.d/œdJd0„«Zeej.d/œ dKd1„«ZedLd2„«Zeej:d3d)¬4«dMd5„««ZedNd6„«ZedOd7„«Z e!dPd8„«Z"e!dQd9„«Z#e$d)d:œ dRd;„«Z%e$d<d=œdSd>„«Z%d?d)d@œdTdA„Z%dUdB„Z&dVdC„Z' dW dXdD„Z(dYdE„Z)dZdF„Z*d[dG„Z+y))\r4a¬ This class holds information about a field.
`FieldInfo` is used for any field definition regardless of whether the [`Field()`][pydantic.fields.Field]
function is explicitly used.
!!! warning
The `FieldInfo` class is meant to expose information about a field in a Pydantic model or dataclass.
`FieldInfo` instances shouldn't be instantiated directly, nor mutated.
If you need to derive a new model from another one and are willing to alter `FieldInfo` instances,
refer to this [dynamic model example](../examples/dynamic_models.md).
Attributes:
annotation: The type annotation of the field.
default: The default value of the field.
default_factory: A callable to generate the default value. The callable can either take 0 arguments
(in which case it is called as is) or a single argument containing the already validated data.
alias: The alias name of the field.
alias_priority: The priority of the field's alias.
validation_alias: The validation alias of the field.
serialization_alias: The serialization alias of the field.
title: The title of the field.
field_title_generator: A callable that takes a field name and returns title for it.
description: The description of the field.
examples: List of examples of the field.
exclude: Whether to exclude the field from the model serialization.
exclude_if: A callable that determines whether to exclude a field during serialization based on its value.
discriminator: Field name or Discriminator for discriminating the type in a tagged union.
deprecated: A deprecation message, an instance of `warnings.deprecated` or the `typing_extensions.deprecated` backport,
or a boolean. If `True`, a default deprecation message will be emitted when accessing the field.
json_schema_extra: A dict or callable to provide extra JSON schema properties.
frozen: Whether the field is frozen.
validate_default: Whether to validate the default value of the field.
repr: Whether to include the field in representation of the model.
init: Whether the field should be included in the constructor of the dataclass.
init_var: Whether the field should _only_ be included in the constructor of the dataclass, and not stored.
kw_only: Whether the field should be a keyword-only argument in the constructor of the dataclass.
metadata: The metadata list. Contains all the data that isn't expressed as direct `FieldInfo` attributes, including:
* Type-specific constraints, such as `gt` or `min_length` (these are converted to metadata classes such as `annotated_types.Gt`).
* Any other arbitrary object used within [`Annotated`][typing.Annotated] metadata
(e.g. [custom types handlers](../concepts/types.md#as-an-annotation) or any object not recognized by Pydantic).
r=r>r rr?r@rArBrCrDrErFrGrHrIrJrKrLrMrNrOrPrQrerfrgrrhrirjrkrlrmrnrorpr‚rƒ)r>rr@rBrDrFrGrHrJrKrMrOrQrfrrirjrkrmrnrorprƒÚ_attributes_setÚ _qualifiersÚ _completeÚ_original_assignmentÚ_original_annotationÚ_finalN)r\rSrUrWrYr[r]r^r`rarbrcrdrqrrz0ClassVar[dict[str, Callable[[Any], Any] | None]]Úmetadata_lookupc óì—|j«D��cic] \}}|tusŒ||jvsŒ||“Œ"c}}|_|j«D��cic]%\}}||turtj |«n|“Œ'}}}|j d«|_|jdt«}|tur(t|_
|jjdd«n||_
|jdd«|_ |jtur|j� td«‚|jdd«|_
|jdd«|_|jdd«|_t!d „|j|j|jfD««}|r|jd
d«xsd nd|_|jd d«|_|jd
d«|_|jdd«|_|jdd«|_|jdd«|_|jdd«|_|jdd«|_|jdt3|dd««|_|jdd«|_|jdd«|_|jdd«|_|jdd«|_|jdd«|_|jdd«|_ |jdd«|_!|jE|«|_#tI«|_%d|_&t|_'t|_(d|_)ycc}}wcc}}w)aThis class should generally not be initialized directly; instead, use the `pydantic.fields.Field` function
or one of the constructor classmethods.
See the signature of `pydantic.fields.Field` for more details about the expected arguments.
r>rNr@ú/cannot specify both default and default_factoryrBrFrGc3ó$K—|]}|du–—Œ
y­w©Nry)Ú.0rBs r{Ú <genexpr>z%FieldInfo.__init__.<locals>.<genexpr>sèø€ÐxÑ:w°˜5¨Ô,Ñ:wùs‚rDérHrJrKrMrOrQrfrrmTrirkrjrnrorpF)*Úitemsr7rŽrˆÚ_DefaultValuesÚgetr>ÚpoprÚEllipsisrr@Ú TypeErrorrBrFrGÚanyrDrHrJrKrMrOrQrfÚgetattrrrmrirkrjrnrorpÚ_collect_metadatarƒÚsetr‰rŠrŒr‹r�)ÚselfÚkwargsÚkÚvrÚ alias_is_sets r{Ú__init__zFieldInfo.__init__äsâ€ð28·±´Ôu±©¨¨AÀ1ÌFÂ?ÐWXÐ`d×`tÑ`tÒWt  1¡°ÒuˆÔØMSÏ\É\Ì^Ô\É^ÁTÀQÈ�!¨a´6©k”^×'Ñ'¨Ô*¸qÑ@È^ˆÑ\Ø Ÿ*™* \Ó2ˆŒð—*‘*˜YÔ(9Ó:ˆØ ”hÑ Ü,ˆDŒLØ × Ñ × $Ñ $ Y°Õ 5à"ˆDŒLà%Ÿz™zÐ*;¸TÓBˆÔà �<‰<Ô0Ñ 0°T×5IÑ5IÐ5UÜÐMÓNÐ Nà—Z‘Z ¨Ó.ˆŒ
Ø &§
¡
Ð+=¸tÓ DˆÔØ#)§:¡:Ð.CÀTÓ#JˆÔ ÜÑx¸4¿:¹:Àt×G\ÑG\Ð^b×^vÑ^vÑ:wÓxÓxˆ ÙIU˜fŸj™jÐ)9¸4Ó@ÒEÁAÐ[_ˆÔØ—Z‘Z ¨Ó.ˆŒ
Ø%+§Z¡ZÐ0GÈÓ%NˆÔ"Ø!Ÿ:™: m°TÓ:ˆÔØŸ
™
 :¨tÓ4ˆŒ
Ø—z‘z )¨TÓ2ˆŒ Ø Ÿ*™* \°4Ó8ˆŒØ#ŸZ™Z¨¸Ó>ˆÔà Ÿ*™* \´7¸4ÀÈtÓ3TÓUˆŒØ—J‘J˜v tÓ,ˆŒ Ø!'§¡Ð,?ÀÓ!FˆÔØ &§
¡
Ð+=¸tÓ DˆÔØ—j‘j ¨4Ó0ˆŒ à—J‘J˜v tÓ,ˆŒ ØŸ
™
 :¨tÓ4ˆŒ
Ø—z‘z )¨TÓ2ˆŒ à×.Ñ.¨vÓ6ˆŒ
ô,/«5ˆÔàˆŒÜ):ˆÔ!Ü):ˆÔ!ðˆ� ùóg vùÛ\s”M*¥M*´M*Á*M0c ó:—d|vr td«‚tdd|i|¤ŽS)a~Create a new `FieldInfo` object with the `Field` function.
Args:
default: The default value for the field. Defaults to Undefined.
**kwargs: Additional arguments dictionary.
Raises:
TypeError: If 'annotation' is passed as a keyword argument.
Returns:
A new FieldInfo object with the given parameters.
Example:
This is how you can create a field with default value like this:
```python
import pydantic
class MyModel(pydantic.BaseModel):
foo: int = pydantic.Field(4)
```
r>z9"annotation" is not permitted as a Field keyword argumentrry)r›r4)rr¡s r{Ú
from_fieldzFieldInfo.from_field"s+€ð0 ˜6Ñ !ÜÐWÓXÐ XÜÑ3 Ð3¨FÑ3Ð3rz)Ú_sourcecó`— t||d¬«}|jt
urt n |j}d|jv}|j}d|i}|rd|d<tj|fi|¤Ž}|j|_ d|_ |S#t$r}t|j|«‚d}~wwxYw)a†Creates a `FieldInfo` instance from a bare annotation.
This function is used internally to create a `FieldInfo` from a bare annotation like this:
```python
import pydantic
class MyModel(pydantic.BaseModel):
foo: int # <-- like this
```
We also account for the case where the annotation can be an instance of `Annotated` and where
one of the (not first) arguments in `Annotated` is an instance of `FieldInfo`, e.g.:
```python
from typing import Annotated
import annotated_types
import pydantic
class MyModel(pydantic.BaseModel):
foo: Annotated[int, annotated_types.Gt(42)]
bar: Annotated[int, pydantic.Field(gt=42)]
```
Args:
annotation: An annotation object.
Returns:
An instance of the field metadata.
Úskip©Úannotation_sourceÚunpack_type_aliasesNrr>Trj)
rrr.Ú qualifierÚtyperr Ú
qualifiersrƒr4Ú
_constructr‰r�) r>r¨Ú
inspected_annÚeÚ type_exprrrƒÚattr_overridesÚ
field_infos r{Úfrom_annotationzFieldInfo.from_annotation>sÀ€ðD FÜ.ØØ")Ø$*ôˆMð!.× 2Ñ 2´gÑ =�À=×CUÑCUˆ ؘ=×3Ñ3Ð3ˆØ ×)Ñ)ˆà&¨ Ð2ˆÙ Ø'+ˆN˜8Ñ $Ü×)Ñ)¨(ÑE°nÑEˆ
Ø!.×!9Ñ!9ˆ
ÔØ ˆ
ÔØÐøô%"ò FÜ,¨Q¯[©[¸*ÓEÐ Eûð Fús‚B Â B-ÂB(Â(B-có:—|tur||ur
tdd¬«‚ t||d¬«}|j turtn |j }d|jv}|j}d}d|i} |rd | d
<|sst|t«rct
|«turR|j«}
|
jj| «| j!«D]\} } t#|
| | «Œ|
St|t«r=|j«}
|
j}g|
_
||
gz}d |jvr�d | d <n‰t|t$j&«rjtj)|«}|j}g|_
||gz}d |jvrd | d <t+|d d«x}�|| d <t+|d
d«x}� || d
<n|| d<tj,|�||zn|fi| ¤Ž}
|j|
_d |
_|
S#t$r}t |j
|«‚d}~wwxYw)a¡Create `FieldInfo` from an annotation with a default value.
This is used in cases like the following:
```python
from typing import Annotated
import annotated_types
import pydantic
class MyModel(pydantic.BaseModel):
foo: int = 4 # <-- like this
bar: Annotated[int, annotated_types.Gt(4)] = 4 # <-- or this
spam: Annotated[int, pydantic.Field(gt=4)] = 4 # <-- or this
```
Args:
annotation: The type annotation of the field.
default: The default value of the field.
Returns:
A field object with the passed values.
z€Error when building FieldInfo from annotated attribute. Make sure you don't have any field name clashing with a type annotation.zunevaluable-type-annotation©Úcoderªr«Nrr>Trjrornrpr)rr/rrr.r®r¯rr r°rƒÚ
isinstancer4Ú_copyrˆÚupdater–ÚsetattrÚ dataclassesrÚ_from_dataclass_fieldr�r±r‰r�)r>rr¨r²r³r´rrƒÚprepend_metadatarµr¶r¢r£Ú default_copyr§rnrps r{Úfrom_annotated_attributez"FieldInfo.from_annotated_attributezsU€ð8 œWÑ $¨°wÑ)>Ü#ð[à2ôð
ð  FÜ.ØØ")Ø$*ôˆMð!.× 2Ñ 2´gÑ =�À=×CUÑCUˆ ؘ=×3Ñ3Ð3ˆØ ×)Ñ)ˆð
.2ÐØ&¨ Ð2ˆÙ Ø'+ˆN˜8Ñ $ñ
œJ w´ Ô:¼tÀG»}ÔT]Ñ?]Ø Ÿ™›ˆJØ × &Ñ &× -Ñ -¨nÔ =Ø&×,Ñ,Ö.‘��1ܘ
 A qÕ)ð/àÐ ä �gœyÔ )Ø"Ÿ=™=›?ˆLØ+×4Ñ4Ð Ø$&ˆLÔ !Ø < .Ñ0ˆHؘ]×5Ñ5Ñ5ð.2�˜zÒ*Ü
˜¤×!2Ñ!2Ô
3Ü"×8Ñ8¸ÓAˆJØ)×2Ñ2Ð Ø"$ˆJÔ Ø : ,Ñ.ˆHؘ]×5Ñ5Ñ5Ø-1�˜zÑ*Ü ¨°Ó6Ð6�ÐCØ)-�˜vÑ&Ü" 7¨I°tÓ<Ð<�ÐIØ,3�˜yÒ)ð)0ˆN˜9Ñ %ä×)Ñ)Ø+;Ð+GÐ ˜xÒ 'ÈXñ
ØYgñ
ˆ
ð"/×!9Ñ!9ˆ
ÔØ ˆ
ÔØÐøôu"ò FÜ,¨Q¯[©[¸*ÓEÐ Eûð Fús›G6Ç6 HÇ?HÈHc óì—g}i}|D�]D}t|t«�r|j|j«d}|j}|�wd|vrs|d}t|t
«r3t|t
«ri|¥|¥}nGt
|«r<tdt«n+t
|«r t|t
«rtdt«|jr/|jtD� cic]} | t|| «“Œc} «n|j|j«|€�Œ||d<�Œtj|«r||d<�Œ4|j!|«�ŒG|j|«|di|¤Ž}
||
_|
Scc} w)aÊConstruct the final `FieldInfo` instance, by merging the possibly existing `FieldInfo` instances from the metadata.
With the following example:
```python {test="skip" lint="skip"}
class Model(BaseModel):
f: Annotated[int, Gt(1), Field(description='desc', lt=2)]
```
`metadata` refers to the metadata elements of the `Annotated` form. This metadata is iterated over from left to right:
- If the element is a `Field()` function (which is itself a `FieldInfo` instance), the field attributes (such as
`description`) are saved to be set on the final `FieldInfo` instance.
On the other hand, some kwargs (such as `lt`) are stored as `metadata` (see `FieldInfo.__init__()`, calling
`FieldInfo._collect_metadata()`). In this case, the final metadata list is extended with the one from this instance.
- Else, the element is considered as a single metadata object, and is appended to the final metadata list.
Args:
metadata: The list of metadata elements to merge together. If the `FieldInfo` instance to be constructed is for
a field with an assigned `Field()`, this `Field()` assignment should be added as the last element of the
provided metadata.
**attr_overrides: Extra attributes that should be set on the final merged `FieldInfo` instance.
Returns:
The final merged `FieldInfo` instance.
Nriz»Composing `dict` and `callable` type `json_schema_extra` is not supported. The `callable` type is being ignored. If you'd like support for this behavior, please open an issue on pydantic.rry)r»r4ÚextendrƒriÚdictÚcallablerÚ UserWarningr�r½Ú_Attrsr�rˆrÚ
is_deprecatedÚappend) ÚclsrƒrµÚmerged_metadataÚ
merged_kwargsÚmetaÚ new_js_extraÚcurrent_js_extraÚexisting_js_extraÚattrÚmerged_field_infos r{r±zFieldInfo._constructßsˆ€ð8&(ˆØ(*ˆ
äˆDܘ$¤ Õ*Ø×&Ñ& t§}¡}Ô5à04� Ø#'×#9Ñ#9Ð Ø#Ð/Ð4GÈ=Ñ4Xà(5Ð6IÑ(JÐ%Ü!Ð"3´TÔ:Ü%Ð&6¼Ô=ð,Ø"3ð,à"2ð,™Lô&Ð&6Ô7Ü ð!mô!,õ ô "Ð"3Ô4¼ÐDTÔVZÔ9[Üðiô(ô ð*—;’;Ø!×(Ñ(ÕPVÓ)WÑPVȨ$´¸¸dÓ0CÑ*CÐPVÑ)WÕXà!×(Ñ(¨×)=Ñ)=Ô>àÒ+Ø9E�MÐ"5Ó6Ü×-Ñ-¨dÔ3Ø.2�
˜lÓ+à×&Ñ& tÖ,ðmðp ×ј^Ô,ÙÑ0 -Ñ0ÐØ%4ÐÔ"Ø Ð ùò*XsÃE1
z©The 'merge_field_infos()' method is deprecated and will be removed in a future version. If you relied on this method, please open an issue in the Pydantic issue tracker.)ÚcategorycóŽ—t|«dk(rˆ|dj«}|jj|«|j dt
«}|t urt
}|t
ur||_|j«D]\}}t|||«Œ|Si}i}|D]Ü}|jj«} |j d«} |jd«}
|
€| |d<t|
t«r5t| t«r i|
¥| ¥|d<t| «r!tdt «nt| «r| |d<|j|«|j$D]!} t| t&«rŒ| |t)| «<Œ#ŒÞ|j|«t'di|¤Ž}t+|j-««|_|S#t"$rYŒŠwxYw)zÎMerge `FieldInfo` instances keeping only explicitly set attributes.
Later `FieldInfo` instances override earlier ones.
Returns:
FieldInfo: A merged FieldInfo instance.
rrrriz¹Composing `dict` and `callable` type `json_schema_extra` is not supported.The `callable` type is being ignored.If you'd like support for this behavior, please open an issue on pydantic.ry)Úlenr¼rˆr½r™rršrr–r¾rr˜r»rÆrÇrr0ÚKeyErrorrƒr4r¯ÚlistÚvalues) Ú field_infosÚ overridesr¶Údefault_overrider¢r£Úmerged_field_info_kwargsrƒÚattributes_setriÚexisting_json_schema_extraÚxs r{Úmerge_field_infoszFieldInfo.merge_field_infos;sä€ô ˆ{Ó ˜qÒ à$ Q™×-Ñ-Ó/ˆJØ × &Ñ &× -Ñ -¨iÔ 8à(Ÿ}™}¨YÔ8IÓJРؤ8Ñ+Ü#4Ð ØÔ'8Ñ8Ø%5�
Ô"à!Ÿ™Ö)‘��1ܘ
 A qÕ)ð*àÐ à35Р؈Û%ˆJØ'×7Ñ7×<Ñ<Ó>ˆNð
Ø$2×$6Ñ$6Ð7JÓ$KÐ!Ø-E×-IÑ-IÐJ]Ó-^Ð*à-Ð5ØDUÐ,Ð-@ÑAÜÐ8¼$Ô?Ü!Ð"3´TÔ:ðIØ8ðIà/ðIÐ0Ð1DÑEô Ð 1Ô2Üðiô6õ ô Ð/Ô0àDUÐ,Ð-@ÑAð
%× +Ñ +¨NÔ ;à×(Ô(�Ü! !¤YÕ/Ø()�HœT !›WÒ%ñ)ð?&ðF !×'Ñ'¨ Ô2ÜÑ:Ð!9Ñ:ˆ
Ü" 8§?¡?Ó#4Ó5ˆ
ÔØÐøôò
Ùð
úsÂ;A>F8Æ8 GÇGcó®—|j}|tjurt}|jtjurt}n |j}|j
j
«D��cic]\}}|tvsŒ||“Œ}}}tjdk\r|j�|j|d<td|||jdœ|¤ŽScc}}w)a]Return a new `FieldInfo` instance from a `dataclasses.Field` instance.
Args:
dc_field: The `dataclasses.Field` instance to convert.
Returns:
The corresponding `FieldInfo` instance.
Raises:
TypeError: If any of the `FieldInfo` kwargs does not match the `dataclass.Field` kwargs.
)r8érK)rr@rmry)
rr¿rr7r@rƒr–Ú_FIELD_ARG_NAMESÚsysÚ version_infoÚdocrrm)Údc_fieldrr@r¢r£Údc_field_metadatas r{rÀzFieldInfo._from_dataclass_field‚sÆ€ð×"Ñ"ˆØ ”k×)Ñ)Ñ )܈Gà × #Ñ #¤{×':Ñ':Ñ :Ü$‰Oà&×6Ñ6ˆOð/7×.?Ñ.?×.EÑ.EÔ.GÔaÑ.G¡d a¨È1ÔP`ÒK`˜Q ™TÐ.GÐÑaÜ × Ñ ˜wÒ &¨8¯<©<Ð+CØ/7¯|©|Ð ˜mÑ ,ÜÐo˜W°oÈHÏMÉMÑoÐ]nÑoÐoùóbs Á1CÂCcó,—g}i}t|j««D]>\}} tj|}||=|€Œ |€|||<Œ(|j ||««Œ@|r$|j t
jdi|¤Ž«|S#t$rYŒtwxYw)a Collect annotations from kwargs.
Args:
kwargs: Keyword arguments passed to the function.
Returns:
A list of metadata objects - a combination of `annotated_types.BaseMetadata` and
`PydanticMetadata`.
ry)rÙr–r4rŽrØrËr"Úpydantic_general_metadata)r¡rƒÚgeneral_metadataÚkeyÚvalueÚmarkers r{ržzFieldInfo._collect_metadatažs¥€ð!ˆØÐܘvŸ|™|›~Ö.‰JˆC�ð
Ü"×2Ñ2°3Ñ7�ð�s� ØÑ Ø�>Ø,1Ð$ SÒ)à—O‘O¡F¨5£MÕ2ð/ñ Ø �O‰OœG×=Ñ=ÑQÐ@PÑQÔ R؈øôò
Ùð
ús¥B BÂBcóè—|j€yt|jt«r|jrdSdSt|jt«r |jS|jjS©z<The deprecation message to be emitted, or `None` if not set.Nr©rr»rlÚstrÚmessage©r s r{Údeprecation_messagezFieldInfo.deprecation_message»óV€ð �?‰?Ð "ØÜ �d—o‘o¤tÔ ,Ø#'§?¢?�<Ð <¸Ð <Ü",¨T¯_©_¼cÔ"Bˆt�‰Ð_ÈÏÉ×H_ÑH_Ð_rzcóZ—|j�tj|j«Sy©zŒWhether the provided default factory callable has a validated data parameter.
Returns `None` if no default factory is set.
N©r@r"Útakes_validated_data_argumentrös r{Ú$default_factory_takes_validated_dataz.FieldInfo.default_factory_takes_validated_dataÄó,€ð × Ñ Ð +Ü×8Ñ8¸×9MÑ9MÓNÐ Nð ,rz©Úvalidated_datacó—yr’ry©r Úcall_default_factoryrs r{Ú get_defaultzFieldInfo.get_defaultÍó€ðrz.©rcó—yr’ry©r rs r{rzFieldInfo.get_defaultÒó€ØQTrzF©rrcó\—tj|j|j||¬«S)amGet the default value.
We expose an option for whether to call the default_factory (if present), as calling it may
result in side effects that we want to avoid. However, there are times when it really should
be called (namely, when instantiating a model via `model_construct`).
Args:
call_default_factory: Whether to call the default factory or not.
validated_data: The already validated data to be passed to the default factory.
Returns:
The default value, calling the default factory if requested or `PydanticUndefined` if not set.
©rr@rr©r"Úresolve_default_valuerr@rs r{rzFieldInfo.get_defaultÕó-€ô×,Ñ,Ø—L‘LØ ×0Ñ0Ø)Ø!5ô 
ð
rzcóF—|jtuxr|jduS)z«Check if the field is required (i.e., does not have a default value or factory).
Returns:
`True` if the field is required, `False` otherwise.
N)rrr@rös r{Ú is_requiredzFieldInfo.is_requiredês$€ð �|‰|Ô0Ð0ÒQ°T×5IÑ5IÈTÐ5QÐQrzcót—|js |jSt|jg|j¢­S)a(Attempts to rebuild the original annotation for use in function signatures.
If metadata is present, it adds it to the original annotation using
`Annotated`. Otherwise, it returns the original annotation as-is.
Note that because the metadata has been flattened, the original annotation
may not be reconstructed exactly as originally provided, e.g. if the original
type had unrecognized annotations, or was annotated with a call to `pydantic.Field`.
Returns:
The rebuilt annotation.
)rƒr>r
rös r{Úrebuild_annotationzFieldInfo.rebuild_annotationòs2€ð�}Š}Ø—?‘?Ð "ô˜dŸo™oÐ>°·
±
Ñ>Ñ?Ð ?rzcó¼—tj|j|«}tj|||«\}}||_|sd|_|j|_yy)aœApply a `typevars_map` to the annotation.
This method is used when analyzing parametrized generic types to replace typevars with their concrete types.
This method applies the `typevars_map` to the annotation in place.
Args:
typevars_map: A dictionary mapping type variables to their concrete types.
globalns: The globals namespace to use during type annotation evaluation.
localns: The locals namespace to use during type annotation evaluation.
See Also:
pydantic._internal._generics.replace_types is used for replacing the typevars with
their concrete types.
FN)r#Ú
replace_typesr>r&Ú
try_eval_typerŠrŒ)r Ú typevars_mapÚglobalnsÚlocalnsr>Ú evaluateds r{Úapply_typevars_mapzFieldInfo.apply_typevars_mapsV€ô*×,Ñ,¨T¯_©_¸lÓKˆ
Ü -× ;Ñ ;¸JÈÐRYÓ Zш
�IØ$ˆŒÙØ"ˆDŒNØ(,¯©ˆDÕ %ðrzc
óz—|j|jtD�cic]}|t||«“Œc}dœScc}w)a]Return a dictionary representation of the `FieldInfo` instance.
The returned value is a dictionary with three items:
* `annotation`: The type annotation of the field.
* `metadata`: The metadata list.
* `attributes`: A mapping of the remaining `FieldInfo` attributes to their values (e.g. `alias`, `title`).
)r>rƒr…)r>rƒrÉr�)r rÓs r{ÚasdictzFieldInfo.asdict!s@€ðŸ/™/ØŸ
™
ÝAGÓHÁ¸˜4¤¨¨tÓ!4Ñ4ÀÑHñ
ð
ùòIsŸ8c ó"—t|«turFtjt«}tjD]}t ||t ||««Œn t
|«}dD]'}t ||t ||«j
««Œ)|S)z*Return a copy of the `FieldInfo` instance.)rƒrˆr‰)r¯r4Ú__new__Ú __slots__r¾r�r)r ÚcopiedÚ attr_names r{r¼zFieldInfo._copy0s|€ô
�‹:œÑ "ä×&Ñ&¤yÓ1ˆFÜ&×0Ô0� ܘ  ¬7°4¸Ó+CÕDñ1ô˜$“ZˆFãGˆIä �F˜I¤w¨v°yÓ'A×'FÑ'FÓ'HÕ IðHðˆ
rzc#óàK—dtjtj|j««f–—d|j «f–—|j
D�]}|dvrŒ |dk(r
|j sŒ|dk(r|jdurŒ/|dk(r|jdurŒC|d k(r|j|jk(rŒb|d
k(r|j|jk(rŒ�|d k(r#|jturd |jf–—Œ©|d k(rC|j�7d tjtj|j««f–—Œñt||«}|€�Œ|tus�Œ ||f–—�Œy­w)
Nr>Úrequired)r>rˆr‰rŠr‹rŒr�rƒrmTrjFrFrGrr@)r%Ú PlainReprÚdisplay_as_typer>rr rƒrmrjrFrBrGrrr@r�)r Úsrïs r{Ú
__repr_args__zFieldInfo.__repr_args__CsQèø€ØœEŸO™O¬E×,AÑ,AÀ$Ç/Á/Ó,RÓSÐSÒSؘ$×*Ñ*Ó,Ð,Ò,à—•ˆAððñðØ�j’¨¯ªØØ�f’ §¡¨dÑ!2ØØ�HŠ} §¡°Ñ!5ØØÐ&Ò&¨4×+@Ñ+@ÀDÇJÁJÒ+NØØÐ)Ò)¨d×.FÑ.FÈ$Ï*É*Ò.TØØ�IŠ~ $§,¡,Ô6GÑ"GØ §¡Ð-Ó-ØÐ'Ò'¨D×,@Ñ,@Ð,LØ'¬¯©¼×9NÑ9NÈt×OcÑOcÓ9dÓ)eÐeÓeä  aÓ(�ØÒ$¨Ô6GÓ)GؘU˜(”Nñ= ùs‚EE.ÅE.Å$
E.)r¡zUnpack[_FieldInfoInputs]ÚreturnÚNone)rr r¡zUnpack[_FromFieldInfoInputs]r)r4)r>ú type[Any]r¨rr)r4)r>r+rr r¨rr)r4)rƒr‚rµr r)r)rÛr4rÜr r)r4)rézDataclassField[Any]r)r4)r¡r„r)r‚©r)rA©r)rN©rú
Literal[True]rúdict[str, Any] | Noner)r ©rúLiteral[False]r)r ©rrlrr0r)r )r)rl)r)r )NN)rzMapping[TypeVar, Any] | NonerzGlobalsNamespace | NonerzMappingNamespace | Noner)r*)r)r�©r)r)r)r3),rtrurvrwrxr r ÚStrictÚannotated_typesÚGtÚGeÚLtÚLeÚ
MultipleOfÚMinLenÚMaxLenÚFailFastrŽr¥Ú staticmethodrr§rÚANYr·rÃÚ classmethodr±Útyping_extensionsrrârÀržÚpropertyr÷rýrrrrrrr¼r(ryrzr{r4r4isÆ…ñ*ðZ!Ó Ø
ƒLØOÓOØ ÓØÓØ;Ó;Ø#Ó#Ø ÓØAÓAØÓØÓØ
ÓØ,Ó,Ø3Ó3Ø.Ó.ØCÓCØ ÓØ!Ó!Ø
ƒJØ
ÓØÓØ
ÓØÓð€IðF—,‘,Ø× Ñ Ø× Ñ Ø× Ñ Ø× Ñ Ø&×1Ñ1Ø%×,Ñ,Ø%×,Ñ,ØØØØØØ!%Ø—^‘^ñI€OÐEóó$<ð|Ø"3ó4óð4ð6ØN^×NbÑNbô9óð9ðvàL\×L`ÑL`ñbØðbØ(+ðbØ9Iðbà òbóðbðHòY!óðY!ðvØ!Ð×!Ñ!ð \àôò
?ó óð ?ðBòpóðpð6òóðð8ò`óð`ðòOóðOðà^bñØ'4ðØF[ðà òóððØDGÔTóØTà:?Ðimõ
ó*Ró@ð,-1Ø+/ð 8à2ð8ð*ð8ð)ð 8ð
ó 8ó8

óô&"#rzr4có—eZdZdZy)Ú _EmptyKwargsz_This class exists solely to ensure that type checking warns about passing `**extra` in `Field`.N)rtrurvrwryrzr{rErEhs„ÚirzrEr.r@rBrDrFrGrHrJrKrMrOrQrfrrirjrk)rmrnrorp)rpr`r\rSrUrWrYr[rarbrcr]r^rqÚ_T)"rBrDrFrGrHrJrKrMrOrQrfrrirjrkrmrnrorpr`r\rqrSrUrWrYr[rarbrcr]r^rdrrÚextrac" ó—yr’ry©$rrBrDrFrGrHrJrKrMrOrQrfrrirjrkrmrnrorpr`r\rqrSrUrWrYr[rarbrcr]r^rdrrrGs$ r{rrœó€ðN rz)!rBrDrFrGrHrJrKrMrOrQrfrrirjrmrnrorpr`r\rqrSrUrWrYr[rarbrcr]r^rdrrc" ó—yr’ryrIs$ r{rrÄrJrzc" ó—yr’ryrIs$ r{rrìó€ðT
rzc# ó—yr’ry©$r@rBrDrFrGrHrJrKrMrOrQrfrrirjrkrmrnrorpr`r\rqrSrUrWrYr[rarbrcr]r^rdrrrGs$ r{rrrJrzc# ó—yr’ryrOs$ r{rr?rMrzc" ó—yr’ry)#rBrDrFrGrHrJrKrMrOrQrfrrirjrkrmrnrorpr`r\rqrSrUrWrYr[rarbrcr]r^rdrrrGs# r{rrjs€ðL rz)#r@rBrDrFrGrHrJrKrMrOrQrfrrirjrkrmrnrorpr`r\rqrSrUrWrYr[rarbrcr]r^rdrrc# ón—|$jdd«}%|%�
tdd¬«‚|$jdd«}&|&�tdtd¬ «| dtfvr|&} |$jd
d«}'|'�td td¬ «|!dtfvr|'}!|$jd d«}(|(�
td
d¬«‚|$jdd«})|)�tdtd¬ «|)durd}|$jdd«}*|*�
tdd¬«‚|$rFtddj d„|$j
«D««›d�td¬ «|r|tur|$}|r.|tur&t|tttf«s td«‚|tdfvrt|t«r|}|tdfvr|}|$jdd«}+|+�tdtd¬ «tj|fid|“d|“d|“d|“d|“d |“d!|“d"|“d#| “d$|
“d%| “d&| “d'|
“d(|“d)|“d*|“d+|“d,|“d-|“d.|“d/|“d0|“d1|“d2|“d3|“d4|“d5|“d6|“d7| “d8|!“d9|“d:|“d;|“d<|"“d=|#“ŽS)>a‚!!! abstract "Usage Documentation"
[Fields](../concepts/fields.md)
Create a field for objects that can be configured.
Used to provide extra information about a field, either for the model schema or complex validation. Some arguments
apply only to number fields (`int`, `float`, `Decimal`) and some apply only to `str`.
Note:
- Any `_Unset` objects will be replaced by the corresponding value defined in the `_DefaultValues` dictionary. If a key for the `_Unset` object is not found in the `_DefaultValues` dictionary, it will default to `None`
Args:
default: Default value if the field is not set.
default_factory: A callable to generate the default value. The callable can either take 0 arguments
(in which case it is called as is) or a single argument containing the already validated data.
alias: The name to use for the attribute when validating or serializing by alias.
This is often used for things like converting between snake and camel case.
alias_priority: Priority of the alias. This affects whether an alias generator is used.
validation_alias: Like `alias`, but only affects validation, not serialization.
serialization_alias: Like `alias`, but only affects serialization, not validation.
title: Human-readable title.
field_title_generator: A callable that takes a field name and returns title for it.
description: Human-readable description.
examples: Example values for this field.
exclude: Whether to exclude the field from the model serialization.
exclude_if: A callable that determines whether to exclude a field during serialization based on its value.
discriminator: Field name or Discriminator for discriminating the type in a tagged union.
deprecated: A deprecation message, an instance of `warnings.deprecated` or the `typing_extensions.deprecated` backport,
or a boolean. If `True`, a default deprecation message will be emitted when accessing the field.
json_schema_extra: A dict or callable to provide extra JSON schema properties.
frozen: Whether the field is frozen. If true, attempts to change the value on an instance will raise an error.
validate_default: If `True`, apply validation to the default value every time you create an instance.
Otherwise, for performance reasons, the default value of the field is trusted and not validated.
repr: A boolean indicating whether to include the field in the `__repr__` output.
init: Whether the field should be included in the constructor of the dataclass.
(Only applies to dataclasses.)
init_var: Whether the field should _only_ be included in the constructor of the dataclass.
(Only applies to dataclasses.)
kw_only: Whether the field should be a keyword-only argument in the constructor of the dataclass.
(Only applies to dataclasses.)
coerce_numbers_to_str: Whether to enable coercion of any `Number` type to `str` (not applicable in `strict` mode).
strict: If `True`, strict validation is applied to the field.
See [Strict Mode](../concepts/strict_mode.md) for details.
gt: Greater than. If set, value must be greater than this. Only applicable to numbers.
ge: Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers.
lt: Less than. If set, value must be less than this. Only applicable to numbers.
le: Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers.
multiple_of: Value must be a multiple of this. Only applicable to numbers.
min_length: Minimum length for iterables.
max_length: Maximum length for iterables.
pattern: Pattern for strings (a regular expression).
allow_inf_nan: Allow `inf`, `-inf`, `nan`. Only applicable to float and [`Decimal`][decimal.Decimal] numbers.
max_digits: Maximum number of allow digits for strings.
decimal_places: Maximum number of decimal places allowed for numbers.
union_mode: The strategy to apply when validating a union. Can be `smart` (the default), or `left_to_right`.
See [Union Mode](../concepts/unions.md#union-modes) for details.
fail_fast: If `True`, validation will stop on the first error. If `False`, all validation errors will be collected.
This option can be applied only to iterable types (list, tuple, set, and frozenset).
extra: (Deprecated) Extra fields that will be included in the JSON schema.
!!! warning Deprecated
The `extra` kwargs is deprecated. Use `json_schema_extra` instead.
Returns:
A new [`FieldInfo`][pydantic.fields.FieldInfo]. The return annotation is `Any` so `Field` can be used on
type-annotated fields without causing a type error.
ÚconstNz)`const` is removed, use `Literal` insteadzremoved-kwargsr¹Ú min_itemszG`min_items` is deprecated and will be removed, use `min_length` insteadr•)Ú
stacklevelÚ max_itemszG`max_items` is deprecated and will be removed, use `max_length` insteadÚ unique_itemsz`unique_items` is removed, use `Set` instead(this feature is discussed in https://github.com/pydantic/pydantic-core/issues/296)Úallow_mutationzH`allow_mutation` is deprecated and will be removed. use `frozen` insteadFTÚregexz)`regex` is removed. use `pattern` insteadzzUsing extra keyword arguments on `Field` is deprecated and will be removed. Use `json_schema_extra` instead. (Extra keys: z, c3ó<K—|]}|j«–—Œy­wr’)Ú__repr__)r“r¢s r{r”zField.<locals>.<genexpr>1sèø€Ð&J¹\¸ q§z¡z§|¹\ùs‚Ú)zSInvalid `validation_alias` type. it should be `str`, `AliasChoices`, or `AliasPath`ÚincludezS`include` is deprecated and does nothing. It will be removed, use `exclude` insteadr@rBrDrFrGrHrJrKrMrOrQrfrrirjr`rkrmrnrorprqr\rSrUrWrYr[r]r^rarbrcrdrr)r™r/rr1r7ÚjoinÚkeysr»rôr*r,r›r4r§),rr@rBrDrFrGrHrJrKrMrOrQrfrrirjrkrmrnrorpr`r\rqrSrUrWrYr[rarbrcr]r^rdrrrGrSrTrVrWrXrYr]s, r{rr‘su€ðX
�I‰I�g˜tÓ $€EØ ÐÜÐ KÐRbÔcÐcà— ‘ ˜+ tÓ,€IØÐÜ Ø UÜ %Øõ
ð
˜$¤˜Ñ 'Ø"ˆJà— ‘ ˜+ tÓ,€IØÐÜ Ø UÜ %Øõ
ð
˜$¤˜Ñ 'Ø"ˆJà—9‘9˜^¨TÓ2€LØÐÜðfð"ô 
ð
ð—Y‘YÐ/°Ó6€NØÐ!Ü Ø VÜ %Øõ
ð
˜UÑ "؈Fà �I‰I�g˜tÓ $€EØ ÐÜÐ KÐRbÔcÐcá Ü ð
à!ŸY™YÑ&J¸U¿Z¹Z¼\Ó&JÓJÐKÈ1ð
Nô
&Øõ 
ñ!Ð$5¼Ñ$?Ø %Ð ñ Ø ¤FÑ *ÜÐ+¬c´<ÄÐ-KÔLäÐmÓnÐnàœv t˜nÑ,´¸EÄ3Ô1GØ#ÐàœF D˜>Ñ)Ø Ðà�i‰i˜  4Ó(€GØÐÜ Ø aÜ %Øõ
ô × Ñ Øò% á'ð% ñð% ñ&ð % ñ
*ð % ñ 0ð
% ñð% ñ4ð% ñ ð% ñð% ñð% ñð% ñ$ð% ñð% ñ,ð% ñ ð!% ñ"ð#% ñ$*ð%% ñ&ð'% ñ(ð)% ñ*ð+% ñ,ð-% ñ.4ð/% ñ0ð1% ñ2 ð3% ñ4 ð5% ñ6 ð7% ñ8 ð9% ñ: ð;% ñ<ð=% ñ>ð?% ñ@$ðA% ñBðC% ñD&ðE% ñFðG% ñHðI% ð%rzcó¨—eZdZdZdZefddœ dd„Zesdd„Zdd„Z e
dd„«Z e dd œ dd
„«Z
e d d œdd
„«Z
dddœdd„Z
dd„Zy)ÚModelPrivateAttraŠA descriptor for private attributes in class models.
!!! warning
You generally shouldn't be creating `ModelPrivateAttr` instances directly, instead use
`pydantic.fields.PrivateAttr`. (This is similar to `FieldInfo` vs. `Field`.)
Attributes:
default: The default value of the attribute if not provided.
default_factory: A callable to generate the default value. The callable can either take 0 arguments
(in which case it is called as is) or a single argument containing the validated data (the model's
[`__dict__`][object.__dict__]) and the already initialized private attributes.
)rr@N©r@cóV—|turt|_||_y||_||_yr’)ršrrr@)r rr@s r{r¥zModelPrivateAttr.__init__‰s.€ð ”hÑ Ü,ˆDŒLð /ˆÕð#ˆDŒLØ.ˆÕrzcó¨—|dvr,t|j|«rt|j|«Stt |«j
›d|›�«‚)z¿This function improves compatibility with custom descriptors by ensuring delegation happens
as expected when the default value of a private attribute is a descriptor.
>Ú__get__Ú__set__Ú
__delete__z object has no attribute )Úhasattrrr�ÚAttributeErrorr¯rt)r Úitems r{Ú __getattr__zModelPrivateAttr.__getattr__˜sP€ðÐ;Ñ;ܘ4Ÿ<™<¨Ô.Ü" 4§<¡<°Ó6Ð6Ü ¤D¨£J×$7Ñ$7Ð#:Ð:SÐTXÐS[Ð!\Ó]Ð ]rzcór—|j}|turyt|dd«}t|«r
|||«yy)zMPreserve `__set_name__` protocol defined in https://peps.python.org/pep-0487.NÚ __set_name__)rrr�rÇ)r rÌÚnamerÚset_names r{rmzModelPrivateAttr.__set_name__¡s<€à—,‘,ˆØ Ô'Ñ 'Ø Ü˜7 N°DÓ9ˆÜ �HÔ Ù �S˜$Õ ð rzcóZ—|j�tj|j«Syrúrûrös r{rýz5ModelPrivateAttr.default_factory_takes_validated_dataªrþrzrÿcó—yr’ryrs r{rzModelPrivateAttr.get_default³rrz.rcó—yr’ryrs r{rzModelPrivateAttr.get_default¸r rzFr
có\—tj|j|j||¬«S)a`Get the default value.
We expose an option for whether to call the default_factory (if present), as calling it may
result in side effects that we want to avoid. However, there are times when it really should
be called (namely, when instantiating a model via `model_construct`).
Args:
call_default_factory: Whether to call the default factory or not.
validated_data: The already validated data to be passed to the default factory.
Returns:
The default value, calling the default factory if requested or `None` if not set.
r r
rs r{rzModelPrivateAttr.get_default»rrzcó”—t||j«xr1|j|jf|j|jfk(Sr’)r»Ú __class__rr@)r Úothers r{Ú__eq__zModelPrivateAttr.__eq__ÐsF€Ü˜% §¡Ó0ò
°d·l±lÀD×DXÑDXÐ5YØ �M‰MØ × !Ñ !ð^
ñ6
ð
rz)rr r@r?r)r*)rjrôr)r )rÌr+rnrôr)r*r-r.r1r3)rvr r)rl)rtrurvrwr rr¥r rkrmrCrýrrrwryrzr{rarays¹„ñ ð/€Ið)ð
/ðW[ñ
/àð
/ðTð
/ð
ó
/ñ ó ^ó ðòOóðOðà^bñØ'4ðØF[ðà òóððØDGÔTóØTà:?Ðimõ
ô*
rzra©rncó—yr’ry)rrns r{r5r5Ùó€ð
rzcó—yr’ry©r@rns r{r5r5ßrzrzcó—yr’ryrxs r{r5r5ås€ð rzr|cóF—|tur
|� td«‚t||¬«S)a³!!! abstract "Usage Documentation"
[Private Model Attributes](../concepts/models.md#private-model-attributes)
Indicates that an attribute is intended for private use and not handled during normal validation/serialization.
Private attributes are not validated by Pydantic, so it's up to you to ensure they are used in a type-safe manner.
Private attributes are stored in `__private_attributes__` on the model.
Args:
default: The attribute's default value. Defaults to Undefined.
default_factory: A callable to generate the default value. The callable can either take 0 arguments
(in which case it is called as is) or a single argument containing the validated data (the model's
[`__dict__`][object.__dict__]) and the already initialized private attributes.
If both `default` and `default_factory` are set, an error will be raised.
init: Whether the attribute should be included in the constructor of the dataclass. Always `False`.
Returns:
An instance of [`ModelPrivateAttr`][pydantic.fields.ModelPrivateAttr] class.
Raises:
ValueError: If both `default` and `default_factory` are set.
r�rb)rr›ra)rr@rns r{r5r5ês1€ð:Ô'Ñ'¨OÐ,GÜÐIÓJÐJä ØØ'ô ðrzcó—eZdZUdZdZded<ded<ded<d ed
<d ed <d
ed<d ed<ded<d ed<ded<ded<ded<ded<d d„Zed!d„«Zd"d„Z d#d„Z
y)$ÚComputedFieldInfoa4A container for data from `@computed_field` so that we can access it while building the pydantic-core schema.
Attributes:
decorator_repr: A class variable representing the decorator string, '@computed_field'.
wrapped_property: The wrapped computed field property.
return_type: The type of the computed field property's return value.
alias: The alias of the property to be used during serialization.
alias_priority: The priority of the alias. This affects whether an alias generator is used.
title: Title of the computed field to include in the serialization JSON schema.
field_title_generator: A callable that takes a field name and returns title for it.
description: Description of the computed field to include in the serialization JSON schema.
deprecated: A deprecation message, an instance of `warnings.deprecated` or the `typing_extensions.deprecated` backport,
or a boolean. If `True`, a default deprecation message will be emitted when accessing the field.
examples: Example values of the computed field to include in the serialization JSON schema.
json_schema_extra: A dict or callable to provide extra JSON schema properties.
repr: A boolean indicating whether to include the field in the __repr__ output.
z@computed_fieldz
ClassVar[str]Údecorator_reprrCÚwrapped_propertyr Ú return_typerArBrCrDrPrQrHú.Callable[[str, ComputedFieldInfo], str] | NonerJrKrgrrLrMrhrirlrmcóü—t|«|j|j|j|j|j
|j |j|j|jt|jt«r|jj«n |jt|jt«r|jj«n |j|j ¬« S)N) r‚rƒrBrDrQrHrJrKrrMrirm)r¯r‚rƒrBrDrQrHrJrKrr»rMrÙrrirÆrmrös r{Ú__copy__zComputedFieldInfo.__copy__3s¸€ØŒt�D‹zØ!×2Ñ2Ø×(Ñ(Ø—*‘*Ø×.Ñ.Ø—‘Ø—*‘*Ø"&×"<Ñ"<Ø×(Ñ(Ø—‘Ü-7¸¿
¹
ÄtÔ-L�T—]‘]×'Ñ'Ô)ÐRV×R_ÑR_ä˜$×0Ñ0´$Ô7ð#×4Ñ4×9Ñ9Ô;à×'Ñ'Ø—‘ô
ð
rzcóè—|j€yt|jt«r|jrdSdSt|jt«r |jS|jjSròrórös r{r÷z%ComputedFieldInfo.deprecation_messageErørzcó—|jxs |j}|�|j€|||«|_|j�|j|j|«yy)z[Update the instance from the configuration set on the class this computed field belongs to.N)rJrHÚalias_generatorÚ_apply_alias_generator)r Úconfig_wrapperrnÚtitle_generators r{Ú_update_from_configz%ComputedFieldInfo._update_from_configNs\€à×4Ñ4Ò\¸×8\Ñ8\ˆØ Ð &¨4¯:©:Ð+=Ù(¨¨tÓ4ˆDŒJØ × )Ñ )Ð 5Ø × 'Ñ '¨×(FÑ(FÈÕ Mð 6rzcól—|j�|jdks |j€�d\}}}t|t«r|j |«\}}}nt |«r||«}|j�|jdkrd|_|jdk(rt
j||«|_yyy)aApply an alias generator to aliases if appropriate.
Args:
alias_generator: A callable that takes a string and returns a string, or an `AliasGenerator` instance.
name: The name of the computed field from which to generate the alias.
Nr)NNN)rDrBr»r+Úgenerate_aliasesrÇr'Úget_first_not_none)r r‰rnrBÚ_rGs r{rŠz(ComputedFieldInfo._apply_alias_generatorVs¼€ð × Ñ Ð &¨$×*=Ñ*=ÀÒ*BÀdÇjÁjÐFXØ,<Ñ )ˆE�1Ð)ä˜/¬>Ô:Ø0?×0PÑ0PÐQUÓ0VÑ-��qÑ-ܘ/Ô*Ù'¨Ó-�ð
×"Ñ"Ð*¨d×.AÑ.AÀQÒ.FØ&'�Ô#ð
×"Ñ" aÒ'Ü#×6Ñ6Ð7JÈEÓR�•
ð(ð#GYrzNr4r,)r‹r2rnrôr)r*)r‰z%Callable[[str], str] | AliasGeneratorrnrôr)r*) rtrurvrwr�rxr†rCr÷r�rŠryrzr{r€r€s�…ñð$%6€N�MÓ5ØÓØÓØ ÓØÓØ,Ó,Ø ÓØIÓIØÓØ.Ó.ØÓØCÓCØ
ƒJó
ð$ò`óð`óNôSrzr€cóî—d}t|t«rt|jdd«}n't|t«rt|j
dd«}|j
d«xr|j
d« S)z>Returns true if provided property is private, False otherwise.Úrtr‘Ú__)r»rCr�ÚfgetrÚfuncÚ
startswith)Ú property_Ú wrapped_names r{Ú_wrapped_property_is_privateršvsc€à€Lä�)œXÔ&ܘyŸ~™~¨z¸2Ó>‰ Ü �IœÔ /ܘyŸ~™~¨z¸2Ó>ˆ à × "Ñ " 3Ó 'Ò M° ×0GÑ0GÈÓ0MÐ,MÐMrzÚ PropertyTcó—yr’ry)r–s r{r6r6‡s€Ø58rz© rBrDrQrHrJrKrrMrirmrƒc ó—yr’ryr�s r{r6r6‹s€ð(+rzc óP‡‡‡‡‡‡‡‡‡ ‡
‡ —dˆˆˆˆˆˆˆˆ ˆ
ˆ ˆf d„ } |€| S| |«S)a$!!! abstract "Usage Documentation"
[The `computed_field` decorator](../concepts/fields.md#the-computed_field-decorator)
Decorator to include `property` and `cached_property` when serializing models or dataclasses.
This is useful for fields that are computed from other fields, or for fields that are expensive to compute and should be cached.
```python
from pydantic import BaseModel, computed_field
class Rectangle(BaseModel):
width: int
length: int
@computed_field
@property
def area(self) -> int:
return self.width * self.length
print(Rectangle(width=3, length=2).model_dump())
#> {'width': 3, 'length': 2, 'area': 6}
```
If applied to functions not yet decorated with `@property` or `@cached_property`, the function is
automatically wrapped with `property`. Although this is more concise, you will lose IntelliSense in your IDE,
and confuse static type checkers, thus explicit use of `@property` is recommended.
!!! warning "Mypy Warning"
Even with the `@property` or `@cached_property` applied to your function before `@computed_field`,
mypy may throw a `Decorated property not supported` error.
See [mypy issue #1362](https://github.com/python/mypy/issues/1362), for more information.
To avoid this error message, add `# type: ignore[prop-decorator]` to the `@computed_field` line.
[pyright](https://github.com/microsoft/pyright) supports `@computed_field` without error.
```python
import random
from pydantic import BaseModel, computed_field
class Square(BaseModel):
width: float
@computed_field
def area(self) -> float: # converted to a `property` by `computed_field`
return round(self.width**2, 2)
@area.setter
def area(self, new_area: float) -> None:
self.width = new_area**0.5
@computed_field(alias='the magic number', repr=False)
def random_number(self) -> int:
return random.randint(0, 1_000)
square = Square(width=1.3)
# `random_number` does not appear in representation
print(repr(square))
#> Square(width=1.3, area=1.69)
print(square.random_number)
#> 3
square.area = 4
print(square.model_dump_json(by_alias=True))
#> {"width":2.0,"area":4.0,"the magic number":3}
```
!!! warning "Overriding with `computed_field`"
You can't override a field from a parent class with a `computed_field` in the child class.
`mypy` complains about this behavior if allowed, and `dataclasses` doesn't allow this pattern either.
See the example below:
```python
from pydantic import BaseModel, computed_field
class Parent(BaseModel):
a: str
try:
class Child(Parent):
@computed_field
@property
def a(self) -> str:
return 'new a'
except TypeError as e:
print(e)
'''
Field 'a' of class 'Child' overrides symbol of same name in a parent class. This override with a computed_field is incompatible.
'''
```
Private properties decorated with `@computed_field` have `repr=False` by default.
```python
from functools import cached_property
from pydantic import BaseModel, computed_field
class Model(BaseModel):
foo: int
@computed_field
@cached_property
def _private_cached_property(self) -> int:
return -self.foo
@computed_field
@property
def _private_property(self) -> int:
return -self.foo
m = Model(foo=1)
print(repr(m))
#> Model(foo=1)
```
Args:
func: the function to wrap.
alias: alias to use when serializing this computed field, only used when `by_alias=True`
alias_priority: priority of the alias. This affects whether an alias generator is used
exclude_if: A callable that determines whether to exclude this computed field during serialization based on its value.