;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$ZVdmd)ZiGd*d+e7ZjGd,d-Zkdnd1ZlGd2d3ZmGd4d5ZnGd6d7ZoGd8d9eCZpGd:d;Zqdod?Zre d@dAdBZse dCdDdBZte dEdFdBZue dGdHdBZve dIdJdBZwe dIdKdBZxe dIdLdBZydpdSZzdqdVZ{drdWZ|dsdZZ}drd[Z~dtd\Z dudvdiZdwdlZdS)xz^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_serializerrMbuiltinsversionstrreturn type[Plugin]ctS)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)rPs AC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pydantic/mypy.pypluginrWms  cTeZdZdZdfd Zdd Zdd Zdd ZddZddZ ddZ xZ S)rUzThe Pydantic mypy plugin.optionsr+rRNonect||_|j|_t |dSN)PydanticPluginConfig plugin_configto_data _plugin_datasuper__init__)selfrZ __class__s rVrczPydanticPlugin.__init__sH1':: .6688 !!!!!rXfullnamerQ(Callable[[ClassDefContext], None] | Nonec||}|r@t|jtr&|jt r|jSdS)zUpdate Pydantic model class.N)lookup_fully_qualified isinstancenoder)has_baseBASEMODEL_FULLNAME$_pydantic_model_class_maker_callback)rdrfsyms rVget_base_class_hookz"PydanticPlugin.get_base_class_hooksZ))(33  A:ch11 Ax  !344 A@@trXc*|tkr|jSdS)z,Update Pydantic `ModelMetaclass` definition.N)MODEL_METACLASS_FULLNAME)_pydantic_model_metaclass_marker_callbackrdrfs rVget_metaclass_hookz!PydanticPlugin.get_metaclass_hooks / / /A AtrX&Callable[[MethodContext], Type] | Nonec>|drtSdS)z-Adjust return type of `from_orm` method call.z .from_ormN)endswithfrom_attributes_callbackrts rVget_method_hookzPydanticPlugin.get_method_hooks#   [ ) ) ,+ +trXctxr0dict[str, Any]c|jS)zjReturn all plugin config data. Used by mypy to determine if cache needs to be discarded. )ra)rdr{s rVreport_config_dataz!PydanticPlugin.report_config_datas   rXr-czt|j|j|j|j}|dSr])PydanticModelTransformerclsreasonapir_ transform)rdr{ transformers rVrnz3PydanticPlugin._pydantic_model_class_maker_callbacks6.sw CGTM_`` rXc|jjrdS|jjj}|s Jdt |jddrd|j_dSdS)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)r_debug_dataclass_transformrinfodeclared_metaclassgetattrtyper)rdr{info_metaclasss rVrsz8PydanticPlugin._pydantic_model_metaclass_marker_callbacksm   7  F8NNNNN~ >&(BD I I @;?N  8 8 8 @ @rXrZr+rRr[)rfrQrRrg)rfrQrRrv)r{r0rRr|)r{r-rRr[) __name__ __module__ __qualname____doc__rcrprurzr~rnrs __classcell__res@rVrUrU|s##""""""   !!!!     @ @ @ @ @ @ @ @rXrUcPeZdZUdZdZded<ded<ded<ded<dd ZddZdS)r^aA 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_aliasesrboolrrrrrZr+rRr[c |jdSt|j}||didi}|jD]P}||d}t |t st d|t|||QdSt}| |j|jD]0}| t|d}t|||1dS)NtoolrGFz/Configuration value must be a boolean for key: )fallback) config_file parse_tomlget __slots__rjr ValueErrorsetattrrread getbooleanCONFIGFILE_KEY)rdrZ toml_configconfigkeysettingr_s rVrczPydanticPluginConfig.__init__s$   & F !455  " __VR0044_bIIF~ , , **S%00!'400^$%\WZ%\%\]]]c7++++  , , )NNM   w2 3 3 3~ , ,'22>3QV2WWc7++++ , ,rXr|c*fdjDS)z/Returns a dict of config names to their values.c2i|]}|t|S)r).0rrds rV z0PydanticPluginConfig.to_data..s%BBBCWT3''BBBrX)rrds`rVr`zPydanticPluginConfig.to_datasBBBB4>BBBBrXNrrRr|)rrrrr__annotations__rcr`rrXrVr^r^sI ''''####,,,,&CCCCCCrXr^r{r.r<c|j}t|tr|j}t|tr"t|jt r|j}nMt|t r|}n5d|d|jjd}t||j |j |j S|jj t}||j S|jt"s|j S|did}|dur%t%|jj|j |j |j S)z1Raise an error if from_attributes is not enabled.z ctx.type: z (of type )Nrfrom_attributesT)rrjr>itemr9ret_typer:rererror_unexpected_behaviorrcontextdefault_return_typemetadatar METADATA_KEYrlrmerror_from_attributesname)r{ctx_type model_typedetailpydantic_metadatars rVryrysGxH(H%%!=(L))'j9JH.U.U'& Hh ' '' PhPP(2D2MPPP!&#'3;???&&"044\BB && ? # #$6 7 7'&&'++Hb99==>OPPOd""jo2CGS[III  ""rXcdeZdZdZd-dZd.dZ d/d0d"Z d1d2d$Zd3d&Ze d4d(Z d5d+Z d,S)6PydanticModelFieldz5Based on mypy.plugins.dataclasses.DataclassAttribute.rrQalias str | None is_frozenrhas_dynamic_alias has_defaultstrict bool | Nonelineintcolumnr Type | Nonerr)c ||_||_||_||_||_||_||_||_| |_| |_ dSr]) rrrrrrrrrr) rdrrrrrrrrrrs rVrczPydanticModelField.__init__sP  "!2&     rX current_infotyped model_strictforce_optional use_aliasrr1force_typevars_invariantis_root_model_rootrRrc  |||||} |j|n|j} |s| r|||d} nttj} t | | d|rtn|s|jrtntS)zABased on mypy.plugins.dataclasses.DataclassAttribute.to_argument.NT)include_root_type)variabletype_annotation initializerkind) to_varrr r8r=explicitrr rr r ) rdrrrrrrrrrrrs rV to_argumentzPydanticModelField.to_arguments;;|S)=UVV!%!4$+  :F :"..|STX.YYOO%i&899O+!V#1TT5ET--9     rXFrc|rFt|jtr,|j}t|_||_|j,|jjtj |j j 5t|}t|tsJ|r+|jD]#}t|tr t|_$t|j|jjj|i}|rlt|trWt#|jrC|jdj} | |cdddSt%| |} t'|| g}|cdddS#1swxYwY|jS)zABased on mypy.plugins.dataclasses.DataclassAttribute.expand_type.Nroot)rjrr? copy_modifiedrvariancer self_typer5strict_optional_setrZstrict_optionalrBr:argsr id is_root_modelr r@) rdrrrr modified_typefilled_with_typevarsarg expanded_type root_typeexpanded_root_types rVr zPydanticModelField.expand_type2s $ * $)[11 * $ 7 7 9 9 )2 &) 9 TY%8%D *3;+FGG % %'4\'B'B$!"6AAAAA+53855%c;775+4CL +DI 8K8NPd7e f f $SM8)L)LSQ^_l_qQrQrS!. 26 : ?I (,! % % % % % % % %"*AM)Z)Z&$-}>P.Q$R$RM$' % % % % % % % % % % % % % % % %(ysextrafrozenralias_generatorrpopulate_by_namevalidate_by_namevalidate_by_aliaszset[str]tracked_config_fieldsrrrExpression | Statementrr1r_r^rRr[c>||_||_||_||_dSr])_cls_reason_apir_)rdrrrr_s rVrcz!PydanticModelTransformer.__init__s'   *rXrc6|jj}t|}|}|||\}}||dS|D] }|jdS |t}|||||| ||||| ||j |j du| d|Dd|D|d|jt <dS)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 NFT)r cBi|]}|j|Srrr)rfields rVrz6PydanticModelTransformer.transform..s&IIIuz5??#4#4IIIrXcBi|]}|j|Srr)r class_vars rVrz6PydanticModelTransformer.transform..s(]]]Y9>9+>+>+@+@]]]rX)fields class_varsr)rrrcollect_configcollect_fields_and_class_varsrrlBASESETTINGS_FULLNAMEadd_initializeradd_model_construct_method set_frozenrr adjust_decorator_signaturesget_values_dictrr)rdris_a_root_modelrrrr is_settingss rVrz"PydanticModelTransformer.transformsAy~'--$$&&!??XX >Z/5  Ez!uu"mm$9::  VV[/JJJ '' _UUU  &-42GHHH ((***JI&III]]R\]]],,..' '  l# trXc|jjjD]}t |jt r|jjdt trt j trfj j tvrSj j tkr-tfdtjDsd|jj_dS)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|]8\}}j|dkot|to |jdkV9dS)modeafterN) arg_namesrjr%value)rir first_decs rV zGPydanticModelTransformer.adjust_decorator_signatures..sg   &3&/2f<rCQXAYAYr^a^gkr^r      rXTN)rrnamesvaluesrjrkroriginal_decoratorsrcalleer rf(IMPLICIT_CLASSMETHOD_DECORATOR_FULLNAMESMODEL_VALIDATOR_FULLNAMEany enumeraterfuncis_class)rdror-s @rVr"z4PydanticModelTransformer.adjust_decorator_signaturess9>'..00 2 2C#(I.. 2H8; y(332"9#3X>>2"(15]]]"(15MMM    *3IN*C*C   N.2CHM*# 2 2rXModelConfigDatac |j}t}d}d}|jD]4\}}|||}|rd}||5d}|jjD]}t|ttfs t|tr|j d} t| tr | j dkrdt|jtrZt!|jj|jjD]3\} } | ||| | d4nt|jt&rV|jjD]I\} } t| t(s||| j| Jnt|tr|j dkrk|jjD]n}t|ts|j d} t| ts;||| j |jo|r|jd|nd} |s|r8|r6|jr/|js(|js!|jjrt;|j||jjd dD]}t@|j!vr|j"tG|j$|j!t@d D]\}}|%|||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)&rr9keywordsitemsget_config_updateupdatedefsbodyrjrrlvaluesr rrvaluerzipr*rrr%r+rfailhas_alias_generatorr r r_rerror_required_dynamic_aliasesrmrorradd_plugin_dependencyr4rf setdefault)rdrrhas_config_kwargshas_config_from_namespacerexpr config_datastmtlhsarg_namerkey_expr value_exprsubstmtrr+s rVrz'PydanticModelTransformer.collect_configsi ""!$)!,,,.. + +JD$00t<?? $// Tl1o!#x00CH4N4Ndk844 Z),T[-BDKDT)U)U]] ##+$ d&<&>! !/!,C%c844! MM$"8"87>"R"RSSSS   o(, % %  @ 9 @ @. @ 0 @5;4K @&D  @ /ty$???HL$ / /D4=00 I + +,A$-,P,P Q Q Q#}\:8DJJLL / / e!!$.... / rXr;rJtuple[list[PydanticModelField] | None, list[PydanticModelClassVar] | None]c|j}i}i}t|jjddD]c}t|jvr|jt|j |jtd D]\}}t |||j} | |j|j| ||<|jj|} | rA| jr:t#| jt$s |jd| j|jtd D]"\}}t( |||<#et+} t+} ||jD]} || ||}|| jd}t#|t4sJt#|trH|r!|jdkrt9|j| x| |j|||j<t#|t(r$| |j|||j<t=|t=|fS) zACollects the fields for the model, accounting for parent classes.r>rz7BaseModel field may only be overridden by another fieldrNrr) rreversedrrKrrrrLr4rfr@rrrr/rrkrjr*rHrset%_get_assignment_statements_from_blockrC$collect_field_or_class_var_from_stmtrEr r error_extra_fields_on_root_modeladdlistr0)rdr;rr found_fieldsfound_class_varsrrrrsym_nodecurrent_field_namescurrent_class_vars_namesrR maybe_fieldrSs rVrz6PydanticModelTransformer.collect_fields_and_class_varsPsi79 =?SX\!B$/00 Q QD4=00 I + +,A$-,P,P Q Q Q"mL9(CIIKK   d*66tT49MM 11#(DIFFF%* T"8>--d33 jPS6T6TINNQ  #mL9,GMMOO Q Q d)>)J)J4)P)P && Q),-0UU >>sxHH 9 9DCCD,XhiiK",q/Cc8,, , ,,+'9:: 9 9SX%7%74TYEEEE'++CH555-8L**K)>?? 9(,,SX666-8 *L''))**D1A1H1H1J1J,K,KKKrXrRrIterator[AssignmentStmt]c#K|jD]$}|js||Ed{V%|j.|jjs$||jEd{VdSdSdSr])rDis_unreachabler] else_body)rdrRrDs rV,_get_assignment_statements_from_if_statementzEPydanticModelTransformer._get_assignment_statements_from_if_statementsI L LD& LEEdKKKKKKKKK > %dn.K %AA$.QQ Q Q Q Q Q Q Q Q Q & % % %rXblockrc#K|jD]L}t|tr|Vt|tr||Ed{VMdSr])rDrjrrrl)rdrmrRs rVr]z>PydanticModelTransformer._get_assignment_statements_from_blocks}J S SD$// S D&)) SLLTRRRRRRRRR  S SrXrr dict[str, PydanticModelClassVar]1PydanticModelField | PydanticModelClassVar | Nonec H|j}|jd}t|tr$t j|jr |jdkrdS|jst|jtrbt|jj trCt|jj j tr|jj j j tvrdS|j|vrdSt|j|dS|jd}t|tsdSt j|jr |jdkrdS|jj|j}|dS|j}t|t&rdSt|t(r|jd|dSt|t,sdS|jrt1|jSt3|j}t|t6r+|jj dkr|jd|||} ||} |jr|jrk|jrd|j |jd} | r| |_n9|jd |tCtDj#|_|jr| rt1|jS|$|\} } | r/|j%s(|j&s!|j'j(rtS|j||*|}|+||j|}tY|j| | | | ||j-|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`. rr;NzFType 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)/rrErjr rEis_valid_field_namer new_syntaxrFrr2rfDECORATOR_FULLNAMESerror_untyped_fieldsrrr/rrkr"r(rHr* is_classvarrrArr:get_has_default get_strictrr is_inferredanalyze_simple_literal_typer8r= from_errorget_alias_infor r r_rrJis_field_frozen_infer_dataclass_attr_init_typerrr)rdrRr;rrrSrork node_typerrrrrr init_types rVr^z=PydanticModelTransformer.collect_field_or_class_var_from_stmtsil1o#x(( 0KCH0U0U Y\YaesYsYs4 4;11 t{18<< t{18(CC K&-6:MMM tx:%%t !D 1 1 14l1o#x(( 4*3844 N8R8R4hn  ** ;4x dO , ,  4 dI & &  INNX   4$$$  4   3(22 2$DI.. i * * y~/FJ_/_/_ INN7    **400 && 8  $2B )77 d7SSC :  ]$I$899 = 3[ 3(22 2#'#6#6t#<#<   <!2 <6B6S <"@ < +49d ; ; ;((.. 88chMM !/#;    rXror&rrQrrrc|j}|jr|St|j}t|ts|S|jd}|r!t|jtr|jd}|sJ|jr)tt|j|j|}nttj St|tr8|jtttgkrt!|jd|S|jd|jjd|n)|jd|jjd||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 ")rimplicitrArjr:rrkrget_containing_type_infor7r8r= unannotatedr9 arg_kindsrr arg_typesrrHr) rdrorrdefaulttsetter super_info setter_types rVrz8PydanticModelTransformer._infer_dataclass_attr_init_type+sq ( < N CH % % !X&& NI&&  U&+w// UV<> 3;3H3KQOOOINN#\afk#\#\#\^effff JAFKJJJGTTTrXrlist[PydanticModelField]rr%c Nd|jjjvr|jjjdjsdS|jj}t |j}|jp|j o|j du}t |j o|j }| |||||||d} |ro|j tj} t#| t$sJd| jvr*| jdj} t#| t&sJ| | j| j} t#| t*sJt-| jD]\} }|*|ds|ds2|j | j| }|2|dkr,|t9t:j}t?||}| tC||dtD|#||sPt?d }| tC|tIt:j%dtLtO|j |jd| tQ dS) 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. rcNFT)rrrequires_dynamic_aliasesrr%rr____cli_settings_sourcekwargs)r return_type))rrr/plugin_generatedr_rrrr r r rIget_field_argumentsrrirrkrjr)rrr9r6r* startswith anal_typeracceptChangeExplicitTypeOfAnyr=from_omitted_genericsr*appendrr should_init_forbid_extrar8rr add_methodr;)rdrrr%rrrrrrbase_settings_nodebase_settings_init_node func_typearg_idxrTanalyzed_variable_typervars rVrz(PydanticModelTransformer.add_initializerQs - - -din6J:6V6g - F"-FM** 0KF4KLvQWQiqvQv #'(B(b6KbGb#c#c '' %%=#'%)(     _!%!A!ABW!X!X!] 0(;; ; ;;/555*<*B:*N*S'!"97CCCCC*6;R;W;c 7 >>>>-6y7J-K-K _ _)#+x/B/B4/H/H+PXPcPcdgPhPh+$151D1DYEXY`Ea1b1b.1=(NdBdBd6L5R5R 7 8W X X662$'x1G#H#H HX7MtU\$]$]^^^^,,VV<< Uh--C KKgi.@&A&A4SS T T T49di$HJJWWWWWWrXc 8|jtd|jtdg}t|t g}t t d||dt}tj |jj j 5| |dt|jdd||}dddn #1swxYwY|||sPt d} |t | t#t$jdt(|r||gzn|g|z}t+|j|jd |t/|jjd dS) 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)rrrrr%rrmodel_construct)rris_classmethod)r named_type BUILTINS_NAMEr@r;rr*r r5rrZrrrrrrr8r=rrrrrBr) rdrrr%rset_stroptional_set_strfields_set_argumentrrs rVr z3PydanticModelTransformer.add_model_construct_methods)&&-'='='= @T@TXeUkUkUk@l@l?mnn$gxzz%:;;&s=:J'K'KM]_celmm  &ty'8'H I I  ++!&-00).'+,D               ,,VV<< Uh--C KKgi.@&A&A4SS T T T/<^t*+++CVBWZ^B^ I I %din55       s*/C%%C),C)r c|jj}|D]}|j|j}|f|j}t |tr|p|j|_ Nt |tr%|j j s|j |||d}||_||_ |jdz|jz|_t#t$||j|j<dS)zMarks all fields as properties so that attempts to set them trigger mypy errors. This is the same approach used by the attrs and dataclasses plugins. NF)r.)rrr/rrrkrjr*r is_propertyr"rfinal_iterationdeferrrf _fullnamer&r)rdrrr rrrdrs rVr!z#PydanticModelTransformer.set_frozens y~ B BEz~~ej11H#mc3''&&,&?COO_55&di>W&IOO%%% ll4l>>"( $  3ch > '6tS'A'A 38$$# B BrXFrrr<ModelConfigData | Nonec ||jvrdS|dkrlt|tr |jdk}n;t|tr |jdk}n|st ||j|dSt|S|dkr4d}t|tr |j dkrd}t| St|tr |j d vrtd i||j d kiSt ||j|dS) 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_extrar T builtins.NoneF)rI) builtins.Truebuiltins.Falserr) rrjr%r+rrerror_invalid_config_valuerr9r rf)rdrrr<rrIs rVrAz*PydanticModelTransformer.get_config_updates6 t1 1 14 7??#w'' "yH4 C,, "x83  E/tTYDDDt" === = $ $ $"& #x(( ,S\_-L-L&+#"7JKKK K c8 $ $ N9\)\)\"MMdCLO,K%LMM M"4C888trXc|j}t|trdSt|trt|jt rx|jjtkrct|j |j D]F\}}||dkr|j tucS|dkr#t|to |jdk cSGdSt|t S)zUReturns a boolean indicating whether the field defined in `stmt` is a required field.FNrdefault_factoryr)rFrjr'rr2r#rfFIELD_FULLNAMErGrr*rerr rRrPrrs rVrxz(PydanticModelTransformer.get_has_defaults{ dH % % 5 dH % % *T['*J*J t{OcguOuOu !DN;; _ _ T<49#4#4= <<<<,,, *3 9 9 ]clo>]^^^^-5dL1111rXrcP|j}t|trt|jtro|jjt krZt|j|j D]?\}}|dkr t|tr|jdkrdS|jdkrdSdSdS)zEReturns a the `strict` value of a field if defined, otherwise `None`.rrTrFN) rFrjrr2r#rfrrGrr*r rs rVryz#PydanticModelTransformer.get_stricts{ dH % % *T['*J*J t{OcguOuOu DN;;   T8##c8,,%|66#tt)999$uutttrXtuple[str | None, bool]c|j}t|trdSt|tr/t|jt r|jjtksdSd|jvr&|j |j d}n1d|jvr&|j |j d}ndSt|tr |j dfSdS)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) rFrjr'rr2r#rfrr*rindexr%r+)rRrPrs rVr}z'PydanticModelTransformer.get_alias_infos{ dH % % ; tX & & +5dk7+K+K PTP[PdhvPvPv;  / /)DN001CDDECC  & &)DN0099:CC; c7 # # 9e# #:rXcl|j}t|trdSt|tr/t|jt r|jjtksdSt|j D]:\}}|dkr/|j |}t|to |jdkcS;dS)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. Fr r) rFrjr'rr2r#rfrr6r*rr )rRrPr,rTrs rVr~z(PydanticModelTransformer.is_field_frozen/s{ dH % % 5 tX & & +5dk7+K+K PTP[PdhvPvPv5$T^44 U UKAx8##il!#x00TS\_5TTTT$urXrrrrrlist[Argument]c \ jj  f d|D} | S)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. c  g|]:} r|j | p jo |jdk;S)r)rrrrrrr)rrrr) rrrrrr%rrrdrrs rV z@PydanticModelTransformer.get_field_arguments..Xs~      #("9    )7F;#I)A#0#IUZ65I       rX)rr) rdrrrrrr%rr argumentsrs ` ``````` @rVrz,PydanticModelTransformer.get_field_argumentsHspy~                  rXc|js1|js*||t|jrdS|jrdS|jjS)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)r r is_dynamic_alias_presentrrIrr_r)rdrrs rVrz1PydanticModelTransformer.should_init_forbid_extrahs] ' 6+B ,,VT&:T5U5UVV u   4!33rXrIcF|D] }|jrdS |r|D] }|jdS dS)zReturns whether any fields on the model have a "dynamic alias", i.e., an alias that cannot be determined during static analysis. TNF)rr)rrIrs rVrz1PydanticModelTransformer.is_dynamic_alias_presentusZ   E& tt     ;&44'urXN) rrrrrr1r_r^rRr[)rRr)rRr[)rRr9)r;r9rrrRrX)rRrrRrh)rmrrRrh)rRrr;r9rrorRrp)ror&rrQrrrRr) rrrr9r%rrrrRr[)rrrr1r rrRr[r)rrQrrr<rrRr)rRrrRr)rRrrRr)rRrrRr)rrrrrrrrrrr%rrrrrrRr)rrrr9rRr)rrrIrrRr)rrrrrrrcrr"rrrlr]r^rrr r!rA staticmethodrxryr}r~rrrrrXrVrrsK ' ' '     + + + +""""H22226JJJJXBLBLBLBLHRRRRSSSSG G G G R$$$$L4X4X4X4Xl& & & & PBBBB2!!!!!F222\2*   \ \:\B*/@ 4 4 4 4   \   rXrc,eZdZdZd fd Zd d ZxZS) rz.sHHHA!-1---rX)__dict__r@rs rVr#zModelConfigData.get_values_dicts' IH!4!4!6!6HHHHrXrrr[c|dS|D]\}}t|||dS)z$Update Pydantic model config values.N)r#r@r)rdrrrs rVrBzModelConfigData.updatesV > F**,,2244  DAq D!Q      rXrrQr+rcLt||t|||dSdS)zFSet default value for Pydantic model config if config value is `None`.N)rr)rdrr+s rVrMzModelConfigData.setdefaults2 4   % D#u % % % % % & %rX)NNNNNNNN)rrr rrrr rr rr rrIrrrr)rrrRr[)rrQr+rrRr[)rrrrrcr#rBrMrrXrVr9r9s22%)"'+(,)-(,+/"(IIII    &&&&&&rXr9rr)rc6|tS)zXReturn whether the type info is a root model subclass (or the `RootModel` class itself).)rlROOT_MODEL_FULLNAME)rs rVrrs ==, - --rXz pydantic-ormzInvalid from_attributes callPydanticzpydantic-configzInvalid config valuezpydantic-aliaszDynamic alias disallowedzpydantic-unexpectedzUnexpected behaviorzpydantic-fieldzUntyped field disallowedzInvalid Field defaultsz!Extra field on RootModel subclass model_namerr,rrr[cH|d|d|tdS)zCEmits an error when the model does not have `from_attributes=True`.rz$" does not have from_attributes=TruecodeN)rH ERROR_ORM)rrrs rVrrs-HH A A A A7QZH[[[[[rXrr1cH|d|d|tdS)z0Emits an error when the config value is invalid.zInvalid value for "Config.rrN)rH ERROR_CONFIG)rrrs rVrrs,HH 1$ 1 1 17HNNNNNrXc@|d|tdS)znEmits required dynamic aliases error. This will be called when `warn_required_dynamic_aliases=True`. z#Required dynamic aliases disallowedrN)rH ERROR_ALIASrrs rVrJrJs# HH 2G+HNNNNNrXr8CheckerPluginInterface | SemanticAnalyzerPluginInterfacecbd}d|d}|d|dz }|||tdS)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)rHERROR_UNEXPECTED)rrrlink full_messages rVrrsO DDWVWWWL\T\\\\LHH\7)9H:::::rXc@|d|tdS)z;Emits an error when there is an untyped field in the model.zUntyped fields disallowedrN)rH ERROR_UNTYPEDrs rVrvrvs!HH (' HFFFFFrXc@|d|tdS)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)rHERROR_EXTRA_FIELD_ROOT_MODELrs rVr_r_s"HH A7QmHnnnnnrXF8SemanticAnalyzerPluginInterface | CheckerPluginInterfacerrrrrrrtvar_defTypeVarType | Nonerc&|j}||jvrR|j|} | jr>t| jt r$|jj| jt|tr| d} n| dg} |rE|ptt|}ttd|dt dg} n6|pt|}ttd|dt g} | |z}ggg}} } |D]f}|js Jd| |j| |jj||jgt-| || || |r|gnd}t ||t/t1g}||_t3|||_||_|jdz|z|_|j|_||jvr*t?||j}|j||j|<|rwd|_ t||j}||_|j|_d|_!tE|tGd g|}|j|_tItJ|} ntItJ|} d| _| |j|<|j&jj|dS) zhVery closely related to `mypy.plugins.common.add_method_to_class`, with a few pydantic-specific changes.zbuiltins.functionrNT__pydantic_self__z"All arguments must be fully typed.) variablesrr)'rr/rrjrkrrCrDremover1rnamed_generic_typer>rBrr*rrrrrrr9rr!r3rr8rfrrrC is_decoratedrrr r&rdefn)rrrrrrrrrro function_typefirstrr*rr signaturer7r_namerdecs rVrrs  8D tzj   +Jsx$A$A + HM  * * *#677H':;; ../BBGG O>-*=*=!>!> #f++y$FFG4t!4!4 #122ItWMMN 4r?r@rA mypy.typevarsrB mypy.utilrC mypy.versionrD mypy_versionpydantic._internalrEpydantic.versionrFrrrmrrrrrDATACLASS_FULLNAMEr4rur3MYPY_VERSION_TUPLErrWrUr^ryrrrrr9rrrrrrERROR_FIELD_DEFAULTSrrrrJrrvr_rrrrXrVr0sdd"""""" $$$$$$%%%%%% %%%%%%@@@@@@@@!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!D! +*****555555,,,,,,000000                        ('''''222222444444&&&&&&////// ' .=5R(5K,?BtAu+u((' 55      3@3@3@3@3@V3@3@3@l+C+C+C+C+C+C+C+C\####4PTPTPTPTPTPTPTPTf        2[ [ [ [ [ [ [ [ |     n   (&(&(&(&(&(&(&(&V.... In&Dj Q Q y*,BJOO i(*DjQQ 924I:VV *,F SS  y!13KZXX(y)9;^`jkk\\\\ OOOO OOOO;;;;GGGG oooo"#' U%U%U%U%U%prX