fL ijdZddlmZddlZddlmZddlmZddlm Z m Z ddl m Z ddl mZmZdd lmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0dd l1m2Z2dd l3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9dd l:m;Z;dd lm?Z?ddl@mAZAddlBmCZCddlDmEZEddlFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPddlQmRZRddlSmTZTddlUmVZWddlXmYZYddlZm[Z[dZ\dZ]dZ^dZ_dZ`dZadZbdZcd Zdhd!Zeeed"hz Zfe[eWZgd#Zhd$ZVdKd%ZiGd&d'e7ZjGd(d)ZkdLd*ZlGd+d,ZmGd-d.ZnGd/d0ZoGd1d2eCZpGd3d4ZqdMd5Zre d6d7d8Zse d9d:d8Zte d;dd8Zve d?d@d8Zwe d?dAd8Zxe d?dBd8ZydNdCZzdOdDZ{dPdEZ| dQdFZ}dPdGZ~dRdHZ dS dTdIZdUdJZy)Vz^This module includes classes and functions designed specifically for use with the mypy plugin.) annotationsN)Iterator) ConfigParser)AnyCallable) ErrorCode) expand_typeexpand_type_by_instance) ARG_NAMED ARG_NAMED_OPTARG_OPTARG_POS ARG_STAR2 INVARIANTMDEFArgumentAssignmentStmtBlockCallExprClassDefContext DecoratorDictExpr EllipsisExpr ExpressionFuncDefIfStmtJsonDict MemberExprNameExprPassStmtPlaceholderNodeRefExpr StatementStrExprSymbolTableNodeTempNode TypeAliasTypeInfoVar)Options)CheckerPluginInterfaceClassDefContext MethodContextPluginReportConfigContextSemanticAnalyzerPluginInterface)deserialize_and_fixup_type)set_callable_name)make_wildcard_trigger)state)TypeTranslator)map_type_from_supertype) AnyType CallableTypeInstanceNoneTypeType TypeOfAnyTypeType TypeVarType UnionTypeget_proper_type) fill_typevars)get_unique_redefinition_name) __version__)_fields)parse_mypy_version pydantic-mypyzpydantic-mypy-metadatazpydantic.main.BaseModelz#pydantic_settings.main.BaseSettingszpydantic.root_model.RootModelz5pydantic._internal._model_construction.ModelMetaclasszpydantic.fields.Fieldzpydantic.dataclasses.dataclass.pydantic.functional_validators.model_validator>*pydantic.functional_serializers.serializer.pydantic.deprecated.class_validators.validator.pydantic.functional_validators.field_validator3pydantic.deprecated.class_validators.root_validatorrH0pydantic.functional_serializers.model_serializerrMbuiltinsctS)a!`version` is the mypy version string. We might want to use this to print a warning if the mypy version being used is newer, or especially older, than we expect (or need). Args: version: The mypy version string. Return: The Pydantic mypy plugin type. )PydanticPlugin)versions S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pydantic/mypy.pypluginrTms  cTeZdZdZd fd Zd dZd dZd dZd dZd dZ d dZ xZ S)rQzThe Pydantic mypy plugin.ct||_|jj|_t||yN)PydanticPluginConfig plugin_configto_data _plugin_datasuper__init__)selfoptions __class__s rSr^zPydanticPlugin.__init__s41': ..668 !rUc|j|}|rEt|jtr+|jj t r |j Sy)zUpdate Pydantic model class.N)lookup_fully_qualified isinstancenoder)has_baseBASEMODEL_FULLNAME$_pydantic_model_class_maker_callback)r_fullnamesyms rSget_base_class_hookz"PydanticPlugin.get_base_class_hooksD))(3 :chh1xx  !34@@@rUc.|tk(r |jSy)z,Update Pydantic `ModelMetaclass` definition.N)MODEL_METACLASS_FULLNAME)_pydantic_model_metaclass_marker_callbackr_ris rSget_metaclass_hookz!PydanticPlugin.get_metaclass_hooks / /AA ArUc2|jdrtSy)z-Adjust return type of `from_orm` method call.z .from_ormN)endswithfrom_attributes_callbackros rSget_method_hookzPydanticPlugin.get_method_hooks   [ )+ +rUc|jS)zjReturn all plugin config data. Used by mypy to determine if cache needs to be discarded. )r\)r_ctxs rSreport_config_dataz!PydanticPlugin.report_config_datas    rUct|j|j|j|j}|j yrX)PydanticModelTransformerclsreasonapirZ transform)r_rv transformers rSrhz3PydanticPlugin._pydantic_model_class_maker_callbacks0.sww CGGTM_M_` rUc|jjry|jjj}|sJdt |j ddrd|j _yy)zReset dataclass_transform_spec attribute of ModelMetaclass. Let the plugin handle it. This behavior can be disabled if 'debug_dataclass_transform' is set to True', for testing purposes. Nz-callback not passed from 'get_metaclass_hook'dataclass_transform_spec)rZdebug_dataclass_transformrzinfodeclared_metaclassgetattrtyper)r_rvinfo_metaclasss rSrnz8PydanticPlugin._pydantic_model_metaclass_marker_callbacks^    7 7 88NNN~ >&&(BD I;?N   8 JrUr`r+returnNone)ristrrz(Callable[[ClassDefContext], None] | None)rirrz&Callable[[MethodContext], Type] | None)rvr0rdict[str, Any])rvr-rr) __name__ __module__ __qualname____doc__r^rkrprtrwrhrn __classcell__ras@rSrQrQ|s*#"   !  @rUrQcNeZdZUdZdZded<ded<ded<ded<d dZd d Zy ) rYaA Pydantic mypy plugin config holder. Attributes: init_forbid_extra: Whether to add a `**kwargs` at the end of the generated `__init__` signature. init_typed: Whether to annotate fields in the generated `__init__`. warn_required_dynamic_aliases: Whether to raise required dynamic aliases error. debug_dataclass_transform: Whether to not reset `dataclass_transform_spec` attribute of `ModelMetaclass` for testing purposes. )init_forbid_extra init_typedwarn_required_dynamic_aliasesrboolrrrrc|jyt|j}|q|jdijdi}|jD]?}|j|d}t |t st d|t|||Ayt}|j|j|jD]'}|jt|d}t|||)y)NtoolrGFz/Configuration value must be a boolean for key: )fallback) config_file parse_tomlget __slots__rdr ValueErrorsetattrrread getbooleanCONFIGFILE_KEY)r_r` toml_configconfigkeysettingrZs rSr^zPydanticPluginConfig.__init__s    &  !4!45  " __VR044_bIF~~ , **S%0!'40$'VWZV[%\]]c7+  , )NM   w22 3~~ ,'22>3QV2Wc7+ ,rUcV|jDcic]}|t||c}Scc}w)z/Returns a dict of config names to their values.)rr)r_rs rSr[zPydanticPluginConfig.to_datas&37>>BCWT3''BBBs&Nrrr)rrrrr__annotations__r^r[rUrSrYrYs3I #''##,&CrUrYc |j}t|tr |j}t|tr't|j t r |j }n]t|t r|}nJd|d|jjd}t||j|j|jS|jjjt}| |jS|jj!t"s |jS|jdijd}|dur5t%|jj&|j|j|jS)z1Raise an error if from_attributes is not enabled.z ctx.type: z (of type )rfrom_attributesT)rrdr>itemr9ret_typer:rarerror_unexpected_behaviorr|contextdefault_return_typemetadatar METADATA_KEYrfrgerror_from_attributesname)rvctx_type model_typedetailpydantic_metadatars rSrsrss0xxH(H%==(L)j9J9JH.U&& Hh ' hZz(2D2D2M2M1NaP!&#''3;;?&&&"0044\B &&& ?? # #$6 7&&&'++Hb9==>OPOd"joo22CGGS[[I  " ""rUceZdZdZ d dZ d dZ d d dZ d ddZddZe ddZ ddZ y )PydanticModelFieldz5Based on mypy.plugins.dataclasses.DataclassAttribute.c ||_||_||_||_||_||_||_||_| |_| |_ yrX) ralias is_frozenhas_dynamic_alias has_defaultstrictlinecolumnrr) r_rrrrrrrrrrs rSr^zPydanticModelField.__init__sL  "!2&     rUc 4|j||||} |j|n |j} |s| r|j||d} nttj } t | | d|r tS|s |jr tStS)zABased on mypy.plugins.dataclasses.DataclassAttribute.to_argument.NT)include_root_type)variabletype_annotation initializerkind) to_varrr r8r=explicitrr rr r ) r_ current_infotyped model_strictforce_optional use_aliasr|force_typevars_invariantis_root_model_rootrrrs rS to_argumentzPydanticModelField.to_arguments;;|S)=UV!%!4$++ F"..|STX.YO%i&8&89O+!   $2T5E5E-   LU   rUcZ|rFt|jtr,|jj}t|_||_|j4|j jtj|jj5t|}t|tsJ|r-|jD]}t|tst|_ t|j|j jj |i}|rdt|trTt#|jr?|jdj} | |cdddSt%| |} t'|| g}|cdddS|jS#1swY|jSxYw)zABased on mypy.plugins.dataclasses.DataclassAttribute.expand_type.Nroot)rdrr? copy_modifiedrvariancer self_typer5strict_optional_setr`strict_optionalrBr:argsr id is_root_modelr r@) r_rr|rr modified_typefilled_with_typevarsarg expanded_type root_typeexpanded_root_types rSr zPydanticModelField.expand_type2sn $ $))[1 $ 7 7 9 )2 &) 99 TYY%8%8%D **3;;+F+FG %'4\'B$!"6AAA+3885%c;7+4CL5!,DII 8K8K8N8NPd7e f $M8)LQ^_l_q_qQr!. 2 26 : ? ?I (,! % %"*AM)Z&$-}>P.Q$RM$' % %(yy) %(yys?FBF&FF*c|r|j |j}n |j}t||j|||S)zextrafrozenralias_generatorrpopulate_by_namevalidate_by_namevalidate_by_aliaszset[str]tracked_config_fieldsc<||_||_||_||_yrX)_cls_reason_apirZ)r_rzr{r|rZs rSr^z!PydanticModelTransformer.__init__s!   *rUc|jj}t|}|j}|j ||\}}||y|D]}|j y|j t}|j|||||j|||||j||j|jdu|j|Dcic]}|j|jc}|Dcic]}|j|jc}|j!d|j"t$<ycc}wcc}w)aConfigures the BaseModel subclass according to the plugin settings. In particular: * determines the model config and fields, * adds a fields-aware signature for the initializer and construct methods * freezes the class if frozen = True * stores the fields, config, and if the class is settings in the mypy metadata for access by subclasses FT)r)fields class_varsr)r rrcollect_configcollect_fields_and_class_varsrrfBASESETTINGS_FULLNAMEadd_initializeradd_model_construct_method set_frozenr radjust_decorator_signaturesrrget_values_dictrr) r_ris_a_root_modelrr rfield is_settings class_vars rSr}z"PydanticModelTransformer.transforms9yy~~'-$$&!??X >Z/ Ezz! mm$9:  VV[/J '' _U  &--42GH ((*CIIuzz5??#44IR\]Y9>>9+>+>+@@],,.'  l#  J]s "E "Ec&|jjjjD]}t |j t s|j jdt tsHt jtscjjtvsjjtk(r(tfdtj Drd|j j"_y)aWhen we decorate a function `f` with `pydantic.validator(...)`, `pydantic.field_validator` or `pydantic.serializer(...)`, mypy sees `f` as a regular method taking a `self` instance, even though pydantic internally wraps `f` with `classmethod` if necessary. Teach mypy this by marking any function whose outermost decorator is a `validator()`, `field_validator()` or `serializer()` call as a `classmethod`. rc3K|]<\}}j|dk(xr!t|txr|jdk(>yw)modeafterN) arg_namesrdr%value).0ir first_decs rS zGPydanticModelTransformer.adjust_decorator_signatures..sO  &3&//2f<rCQXAYr^a^g^gkr^rr sAATN)r rnamesvaluesrdreroriginal_decoratorsrcalleer ri(IMPLICIT_CLASSMETHOD_DECORATOR_FULLNAMESMODEL_VALIDATOR_FULLNAMEany enumeraterfuncis_class)r_rjr#s @rSrz4PydanticModelTransformer.adjust_decorator_signaturess99>>''..0 2C#((I.HH88; y(3"9#3#3X>!((115]]"((115MM *3INN*C .2CHHMM*# 2rUc |j}t}d}d}|jjD]-\}}|j ||}|sd}|j |/d}|j jD]}t|ttfst|tr"|jd} t| tr| jdk7r[t|jtrdt!|jj"|jj$D]+\} } |  |j |j | | d-nt|jt&r|jjD]A\} } t| t(s|j |j | j*| Cnt|tr|jdk7ro|j jD]h}t|ts|jd} t| ts4|j |j | j|jj|r|j,j/d|nd}|s|rR|rP|j0rD|j2s8|j4s,|j6j8rt;|j,||j<j>d dD]}t@|jBvr|j,jEtG|jH|jBt@d jD]\}}|jK|||S) zhCollects the values of the config attributes that are used by the plugin, accounting for parent classes.FTNr model_config) lax_extraConfigzYSpecifying config in two places is ambiguous, use either Config attribute or class kwargsr)&r ModelConfigDatakeywordsitemsget_config_updateupdatedefsbodyrdrrlvaluesr rrvaluerziprrrr%r r failhas_alias_generatorrrrZrerror_required_dynamic_aliasesrmrorradd_plugin_dependencyr4ri setdefault)r_rzrhas_config_kwargshas_config_from_namespacerexpr config_datastmtlhsarg_namerkey_expr value_exprsubstmtrr s rSrz'PydanticModelTransformer.collect_configsii "!$)!,,,,. +JD$00t?$/ll1o!#x0CHH4Ndkk84),T[[-B-BDKKDTDT)U] ##+$ d&<& !//!,C%c84 MM$"8"87>>"RS T! o(, %M& -P  9..00F4K4K&&DD.tyy$?HHLL$ /D4==0 II + +,A$--,P Q#}}\:8DJJL / e!!$. /  / rUc|j}i}i}t|jjddD]v}t|j vr|j jt|j|j tdjD]\}}tj|||j } | j|j|j | ||<|jjj|} | sz| j st#| j t$r|j j'd| j |j tdjD]\}}t(j|||<yt+} t+} |j-|j.D]} |j1| ||}|| j2d}t#|t4sJt#|trS|r&|j6dk7rt9|j | r| j;|j6|||j6<t#|t(s| j;|j6|||j6<t=|j?t=|j?fS)zACollects the fields for the model, accounting for parent classes.r3r z7BaseModel field may only be overridden by another fieldrrr) r reversedrrArrr rBr4rir6rrrr%rrerdr*r>rset%_get_assignment_statements_from_blockr9$collect_field_or_class_var_from_stmtr;r r error_extra_fields_on_root_modeladdlistr&)r_r0rrz found_fieldsfound_class_varsrrrrsym_nodecurrent_field_namescurrent_class_vars_namesrH maybe_fieldrIs rSrz6PydanticModelTransformer.collect_fields_and_class_varsPsiii79 =?SXX\\!B/0 QD4==0 II + +,A$--,P Q"mmL9(CIIK  d*66tT499M 11#((DIIF%* T"88>>--d3 jPS6TIINNQ   #mmL9,GMMO Q d)>)J)J4)P & Q5 Q<),-0U >>sxxH 9DCCD,XhiK",,q/Cc8, ,,+'9: SXX%74TYYE'++CHH5-8L*K)>?(,,SXX6-8 * 9"L'')*D1A1H1H1J,KKKrUc#K|jD](}|jr|j|Ed{*|j;|jjs$|j|jEd{yyy7N7 wrX)r:is_unreachablerR else_body)r_rHr:s rS,_get_assignment_statements_from_if_statementzEPydanticModelTransformer._get_assignment_statements_from_if_statements{II LD&&EEdKKK L >> %dnn.K.KAA$..Q Q Q/L %L Qs'BBBAB:B;BBc#K|jD]A}t|tr|t|ts)|j |Ed{Cy7wrX)r:rdrrr`)r_blockrHs rSrRz>PydanticModelTransformer._get_assignment_statements_from_blocksNJJ SD$/ D&)LLTRRR  SSs5AA A Ac 4|j}|jd}t|tr.t j |j r|j dk(ry|jst|jtrt|jjtr_t|jjjtr1|jjjjtvry|j |vryt|j|y|jd}t|tsyt j |j r|j dk(ry|jj j#|j }|y|j$}t|t&ryt|t(r|jj+d|yt|t,sy|j.rt1|j St3|j4}t|t6r5|j4jdk(r|jj+d||j9|} |j;|} |j4|j<rw|j>rk|jjA|jd} | r| |_n:|jj+d |tCtDjF|_|j<r| rt1|j S|jI|\} } | rD|jJs8|jLs,|jNjPrtS|j||jU|}|jW||j |}tY|j | | | | ||jZ|j\||j S) a^Get pydantic model field from statement. Args: stmt: The statement. model_config: Configuration settings for the model. class_vars: ClassVars already known to be defined on the model. Returns: A pydantic model field if it could find the field in statement. Otherwise, `None`. rr0NzFType aliases inside BaseModel definitions are not supported at runtimezdataclasses.InitVarz%InitVar is not supported in BaseModelT)is_finalzGNeed type argument for Final[...] with non-literal default in BaseModel) rrrrrrrrrr)/r r;rdr rEis_valid_field_namer new_syntaxr<rr(riDECORATOR_FULLNAMESerror_untyped_fieldsr rr%rrer"r(r>r* is_classvarrrArr:get_has_default get_strictrd is_inferredanalyze_simple_literal_typer8r= from_errorget_alias_inforrrZrr@is_field_frozen_infer_dataclass_attr_init_typerrr)r_rHr0rrzrIrjre node_typerrrrrr init_types rSrSz=PydanticModelTransformer.collect_field_or_class_var_from_stmts%iill1o#x(0K0KCHH0UY\YaYaesYs4;;1t{{118<t{{1188(CKK&&--66:MM xx:% !D 1ll1o#x(**3884N8Rhhnn  * ;xx dO ,  dI & IINNX $$    (2 2$DII. i *y~~/F/FJ_/_ IINN7  **40 & 88  $2B2B))77 d7SC  ]$I$8$89 ==[(2 2#'#6#6t#<  !22l6S6S""@@ *499d ;((. 88chhM !/#;;  rUc8|j}|jr|St|j}t|ts|S|jj d}|r:t|j tr|jjd}|sJ|jr+tt|j|j|}nttjSt|tr7|jtttgk(rt!|j"d|S|j$j'd|jj(d||S|j$j'd|jj(d||S)zvInfer __init__ argument type for an attribute. In particular, possibly use the signature of __set__. __set__rOz(Unsupported signature for "__set__" in ""zUnsupported "__set__" in ")rimplicitrArdr:rrerget_containing_type_infor7r8r= unannotatedr9 arg_kindsrr arg_typesr r>r) r_rjrrdefaulttsetter super_info setter_types rSrqz8PydanticModelTransformer._infer_dataclass_attr_init_type+sG (( <<N CHH % !X&NI& &++w/VV< 3;3H3H3KQOOIINN%Maffkk]Z[#\^ef !;AFFKK=JGTrUc d|jjjvr.|jjjdjsy|jj }t |j}|jxs |j xr|jdu}t |jxr |j }|j|||||||d} |rg|jjtj } t#| t$sJd| jvr| jdj } t#| t&sJ| | j(| j(} t#| t*sJt-| j.D]\} }|"|j1ds|j1ds+|jj3| j4| }|-|dk(r(|j7t9t:j<}t?||}| jAtC||dtD|jG||sCt?d }| jAtC|tIt:jJdtLtO|j|jd| tQ y) zAdds a fields-aware `__init__` method to the class. The added `__init__` will be annotated with types vs. all `Any` depending on the plugin settings. r^NFT)rrrequires_dynamic_aliasesrrrr____cli_settings_sourcekwargs)r return_type))r rr%plugin_generatedrZrrrrrrr?get_field_argumentsr rcrrerdr)rrr9r,r startswith anal_typer{acceptChangeExplicitTypeOfAnyr=from_omitted_genericsr*appendrr should_init_forbid_extrar8rr add_methodr;)r_r rrrrrrrrbase_settings_nodebase_settings_init_node func_typearg_idxrJanalyzed_variable_typervars rSrz(PydanticModelTransformer.add_initializerQsz -- -diinn6J6J:6V6g6g ""--FMM* 00KF4K4KLvQWQiQiqvQv #'(B(B(b6KbKbGb#c '' %%=#'%)(   !%!A!ABW!X!]!] 0(; ;;/555*<*B*B:*N*S*S'!"97CCC*6;R;W;W;c 7 < >>-6y7J7J-K _)#+x/B/B4/HPXPcPcdgPh$151D1DYEXEXY`Ea1b.1=(NdBd6L5R5R 7 8W8W X62$'x1G#H HX7MtU\$]^ _,,VV<h-C KKgi.@.@&A4S T499dii$HJWrUc |jjtd|jjtdg}t|t g}t t d||dt}tj|jjj5|j|dt|jdd||}ddd|j||sCt d} j!t | t#t$j&dt(|r|gzn|gz}t+|j|j,d |t/|j,j0d y#1swYxYw) zAdds a fully typed `model_construct` classmethod to the class. Similar to the fields-aware __init__ method, but always uses the field names (not aliases), and does not treat settings fields as optional. z.setz.str _fields_setNTF)rrrrrrrmodel_construct)rris_classmethod)r  named_type BUILTINS_NAMEr@r;rr*r r5rr`rrrrrrr8r=rrrr rBr) r_r rrrset_stroptional_set_strfields_set_argumentrrs rSrz3PydanticModelTransformer.add_model_construct_methodsY))&&-'= @T@TXeWffjUk@l?mn$gxz%:;&s=:J'KM]_celm  & &tyy'8'8'H'H I ++!&--0).'+,D ,,VV<h-C KKgi.@.@&A4S T/W>WIIOO% ll4l>"( $  3chh > '6tS'A 388$# BrUc||jvry|dk(rft|tr|jdk(}n:t|tr|j dk(}n|st ||j|yt|S|dk(r/d}t|tr|jdk(rd}t| St|tr(|jd vrtd i||jd k(iSt ||j|y) zDetermines the config update due to a single kwarg in the ConfigDict definition. Warns if a tracked config attribute is set to a value the plugin doesn't know how to interpret (e.g., an int) Nrforbid) forbid_extrarT builtins.NoneF)r?) builtins.Truebuiltins.Falserr) rrdr%r rrerror_invalid_config_valuer r4r ri)r_rrr1rr?s rSr7z*PydanticModelTransformer.get_config_updates t11 1 7?#w'"yyH4 C,"xx83  /tTYYD" = = $ $"& #x(S\\_-L&+#"7JK K c8 $9\)\"MdCLLO,K%LM M"4C8rUc|j}t|tryt|trt|jt r|jj tk(rmt|j|jD]I\}}||dk(r|jtucS|dk(s't|txr|j dk( cSyt|t S)zUReturns a boolean indicating whether the field defined in `stmt` is a required field.Fr|default_factoryr)r<rdr'rr(r#riFIELD_FULLNAMEr=rrrarr rHrFrrs rSrjz(PydanticModelTransformer.get_has_defaults{{ dH % dH %*T[['*Jt{{OcOcguOu !DNN; _ T<49#4== <<,, *3 9 ]cllo>]^^  _ dL111rUcl|j}t|trt|jtr~|jj t k(rat|j|jD]>\}}|dk7r t|tr"|j dk(ry|j dk(ryyy)zEReturns a the `strict` value of a field if defined, otherwise `None`.rrTrFN) r<rdrr(r#rirr=rrr rs rSrkz#PydanticModelTransformer.get_stricts{{ dH %*T[['*Jt{{OcOcguOu DNN;  T8#c8,||6#)99$ rUc|j}t|tryt|tr7t|jt r|jj tk(syd|jvr)|j|jjd}n8d|jvr)|j|jjd}nyt|tr|jdfSy)aReturns a pair (alias, has_dynamic_alias), extracted from the declaration of the field defined in `stmt`. `has_dynamic_alias` is True if and only if an alias is provided, but not as a string literal. If `has_dynamic_alias` is True, `alias` will be None. )NFvalidation_aliasrF)NT) r<rdr'rr(r#rirrrindexr%r )rHrFrs rSroz'PydanticModelTransformer.get_alias_infos{{ dH % tX &:dkk7+KPTP[P[PdPdhvPv  /))DNN001CDEC  &))DNN009:C c7 #99e# #rUcv|j}t|tryt|tr7t|jt r|jj tk(syt|jD]<\}}|dk(s |j|}t|txr|j dk(cSy)alReturns whether the field is frozen, extracted from the declaration of the field defined in `stmt`. Note that this is only whether the field was declared to be frozen in a ` = Field(frozen=True)` sense; this does not determine whether the field is frozen because the entire model is frozen; that is handled separately. Frr) r<rdr'rr(r#rirr,rrr )rHrFr"rJrs rSrpz(PydanticModelTransformer.is_field_frozen/s{{ dH % tX &:dkk7+KPTP[P[PdPdhvPv$T^^4 UKAx8#iil!#x0TS\\_5TT UrUc |jj} |D cgc]H} |r | js8| j| |||xs|||j||xr| j dk(J} } | Scc} w)zHelper function used during the construction of the `__init__` and `model_construct` method signatures. Returns a list of mypy Argument instances for use in the generated signatures. r)rrrrr|rr)r rrrr r) r_r rrrrrrrrr argumentss rSrz,PydanticModelTransformer.get_field_argumentsHsyy~~   %"9"9   )7F;#II)A#0#IUZZ65I       sA A,c|js2|js&|j|t|jry|j ry|j jS)a@Indicates whether the generated `__init__` should get a `**kwargs` at the end of its signature. We disallow arbitrary kwargs if the extra config setting is "forbid", or if the plugin config says to, *unless* a required dynamic alias is present (since then we can't determine a valid signature). FT)rris_dynamic_alias_presentrr?rrZr)r_r rs rSrz1PydanticModelTransformer.should_init_forbid_extrahsQ ''6+B+B,,VT&:T:T5UV   !!333rUc\|D]}|jsy|r|D]}|jyy)zReturns whether any fields on the model have a "dynamic alias", i.e., an alias that cannot be determined during static analysis. TF)rr)r r?rs rSrz1PydanticModelTransformer.is_dynamic_alias_presentusE  E&&   ;;& rUN) rzrr{zExpression | Statementr|r1rZrYrr)rr)rr)rr4)r0r4rrrzJtuple[list[PydanticModelField] | None, list[PydanticModelClassVar] | None])rHrrIterator[AssignmentStmt])rbrrr)rHrr0r4rz dict[str, PydanticModelClassVar]rz1PydanticModelField | PydanticModelClassVar | None)rjr&rrrrrr) r list[PydanticModelField]rr4rrrrrr)r rr|r1rrrrr)rrrrr1rrModelConfigData | None)rHrrr)rHrrr)rHrrztuple[str | None, bool])r rrrrrrrrrrrrrrrrlist[Argument])r rrr4rr)r rr?rrr)rrrrrrr^r}rrrr`rRrSrqrrrr7 staticmethodrjrkrorprrrrrUrSryrys '8  +  +' +- + , +  +"H26JXBL+BL<@BL SBLHRSG "G 2AG OoG :G R$L4X.4X8G4XVZ4Xko4X 4Xl& (&  &  &  &  & PB2!F22*  :B*/(    #' #' @ 4  rUryc,eZdZdZdfd ZddZxZS)rz **,224 DAq D!Q  rUc8t||t|||yy)zFSet default value for Pydantic model config if config value is `None`.N)rr)r_rr s rSrCzModelConfigData.setdefaults 4  % D#u % &rU)NNNNNNNN)rrrrrrrrrrrrr?rrrr)rrrr)rrr rrr)rrrrr^rr8rCrrUrSr4r4s2%)"'+(,)-(,+/"!%  &  ' &)(I &rUr4c,|jtS)zXReturn whether the type info is a root model subclass (or the `RootModel` class itself).)rfROOT_MODEL_FULLNAME)rs rSrrs ==, --rUz pydantic-ormzInvalid from_attributes callPydanticzpydantic-configzInvalid config valuezpydantic-aliaszDynamic alias disallowedzpydantic-unexpectedzUnexpected behaviorzpydantic-fieldzUntyped field disallowedzInvalid Field defaultsz!Extra field on RootModel subclassc<|jd|d|ty)zCEmits an error when the model does not have `from_attributes=True`.rvz$" does not have from_attributes=TruecodeN)r> ERROR_ORM) model_namer|rs rSrrsHHq @ A7QZH[rUc<|jd|d|ty)z0Emits an error when the config value is invalid.zInvalid value for "Config.rvrN)r> ERROR_CONFIG)rr|rs rSrrsHH)$q 17HNrUc4|jd|ty)znEmits required dynamic aliases error. This will be called when `warn_required_dynamic_aliases=True`. z#Required dynamic aliases disallowedrN)r> ERROR_ALIASr|rs rSr@r@s HH 2G+HNrUcVd}d|d}|d|dz }|j||ty)z Emits unexpected behavior error.z6https://github.com/pydantic/pydantic/issues/new/choosez7The pydantic mypy plugin ran into unexpected behavior:  z&Please consider reporting this bug at z so we can try to fix it!rN)r>ERROR_UNEXPECTED)rr|rlink full_messages rSrrsA DDLVHTVWL ERROR_UNTYPEDrs rSrhrhsHH (' HFrUc4|jd|ty)z]Emits an error when there is more than just a root field defined for a subclass of RootModel.z2Only `root` is allowed as a field of a `RootModel`rN)r>ERROR_EXTRA_FIELD_ROOT_MODELrs rSrTrTsHH A7QmHnrUc>|j}||jvrd|j|} | jrIt| jt r/|j jj| jt|tr|jd} n|jdg} |r6|xstt|}ttd|dt dg} n+|xs t|}ttd|dt g} | |z}ggg}} } |D]p}|j"sJd| j%|j"| j%|j&j(|j%|j*rt-| || || |r|gnd}t ||t/t1g}||_t3|||_||_|j8dz|z|_|j<|_||jvr2t?||j}|j||j|<|rud|_ t||j4}||_|j:|_d|_!tE|tGd g|}|j<|_tItJ|} ntItJ|} d| _| |j|<|jLj jj%|y) zhVery closely related to `mypy.plugins.common.add_method_to_class`, with a few pydantic-specific changes.zbuiltins.functionr NT__pydantic_self__z"All arguments must be fully typed.) variablesrr)'rr%rrdrerr9r:remover1rnamed_generic_typer>rBrr*rrrrrrr9rr!r3rr.rirrrC is_decoratedrrr r&rdefn)r|rzrrrrtvar_defrrrj function_typefirstr{rrzr signaturer-r_namerdecs rSrrs 88D tzzjj   Jsxx$A HHMM  *#67':; ../BBG >-*=!> #f+y$FG4t!4 #12ItWMN 4r?r@rA mypy.typevarsrB mypy.utilrC mypy.versionrD mypy_versionpydantic._internalrEpydantic.versionrFrrrgrrrmrDATACLASS_FULLNAMEr*rgr)MYPY_VERSION_TUPLErrTrQrYrsrrryrr4rrrrrrERROR_FIELD_DEFAULTSrrrr@rrhrTrrrrUrSrsd" $% %@!!!!!!!!!D!+5,0   (24&/ ' .=5R(5K,?BtAu+u(( 5   3@V3@l+C+C\#4PTPTf  2[ [ | n (&(&V. n&Dj Q *,BJO (*DjQ 24I:V*,F S  !13KZX()9;^`jk\ O O; ;N;Y`; ;G o"#' U% AU% U% U%  U%  U%  U%!U%U% U%prU