fdZddlmZddlZddlmZddlmZmZm Z ddl m Z ddl m Z mZddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm 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/dd l0m1Z1dd l2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9dd l:m;Z;dd lm?Z?ddl@mAZAddlBmCZCddlDmEZEddlFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQddlRmSZSddlTmUZUddlVmWZXddlYmZZZddl[m\Z\ ddlFm]Z]dZ_dZ`dZadZbdZcdZddZed Zfd!Zghd"Zhe\eXZieid#k\rd$nd%Zjd&ZWdKd'ZkGd(d)e7ZlGd*d+ZmdLd,ZnGd-d.ZoGd/d0ZpGd1d2ZqGd3d4Zre d5d6d7Zse d8d9d7Zte d:d;d7Zue dd?d7Zwe d>d@d7Zxe d>dAd7ZydMdBZzdNdCZ{dOdDZ| dPdEZ}dOdFZ~dQdGZdQdHZ dR dSdIZdTdJZy#e^$r ddlFmOZ]YwxYw)Uz^This module includes classes and functions designed specifically for use with the mypy plugin.) annotationsN) ConfigParser)AnyCallableIterator) ErrorCode) expand_typeexpand_type_by_instance) ARG_NAMED ARG_NAMED_OPTARG_OPTARG_POS ARG_STAR2 INVARIANTMDEFArgumentAssignmentStmtBlockCallExprClassDefContext DecoratorDictExpr EllipsisExpr ExpressionFuncDefIfStmtJsonDict MemberExprNameExprPassStmtPlaceholderNodeRefExpr StatementStrExprSymbolTableNodeTempNode TypeAliasTypeInfoVar)Options)CheckerPluginInterfaceClassDefContextFunctionContext MethodContextPluginReportConfigContextSemanticAnalyzerPluginInterface) dataclasses)deserialize_and_fixup_type)set_callable_name)make_wildcard_trigger)state)map_type_from_supertype) AnyType CallableTypeInstanceNoneType OverloadedType TypeOfAnyTypeType TypeVarType UnionTypeget_proper_type) fill_typevars)get_unique_redefinition_name) __version__)_fields)parse_mypy_version) TypeVarDef)rA 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_validator0pydantic.functional_serializers.model_serializer3pydantic.deprecated.class_validators.root_validatorrK)ribuiltins __builtins__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)versions V/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/pydantic/mypy.pypluginrXss  cleZdZdZd fd Zd dZddZddZddZddZ ddZ dd Z dd Z dd Z xZS)rUzThe Pydantic mypy plugin.ct||_|jj|_t||yN)PydanticPluginConfig plugin_configto_data _plugin_datasuper__init__)selfoptions __class__s rWrbzPydanticPlugin.__init__s41': ..668 !rYc|j|}|rLt|jtr2t d|jj Dr |j Sy)zUpdate Pydantic model class.c3BK|]}|jtk(ywr\fullnameBASEMODEL_FULLNAME.0bases rW z5PydanticPlugin.get_base_class_hook..sP44==$66PN)lookup_fully_qualified isinstancenoder)anymro$_pydantic_model_class_maker_callbackrcrisyms rWget_base_class_hookz"PydanticPlugin.get_base_class_hooksG))(3 :chh1P388<<PP@@@rYc.|tk(r |jSy)z,Update Pydantic `ModelMetaclass` definition.N)MODEL_METACLASS_FULLNAME)_pydantic_model_metaclass_marker_callbackrcris rWget_metaclass_hookz!PydanticPlugin.get_metaclass_hooks / /AA ArYch|j|}|r|jtk(r |jSy)z/Adjust the return type of the `Field` function.N)rpriFIELD_FULLNAME_pydantic_field_callbackrvs rWget_function_hookz PydanticPlugin.get_function_hooks/))(3 3<<>100 0rYc2|jdrtSy)z-Adjust return type of `from_orm` method call.z .from_ormN)endswithfrom_attributes_callbackr|s rWget_method_hookzPydanticPlugin.get_method_hooks   [ )+ +rYcH|tk(rtdkrtjSy)zMark pydantic.dataclasses as dataclass. Mypy version 1.1.1 added support for `@dataclass_transform` decorator. )rN)DATACLASS_FULLNAMEMYPY_VERSION_TUPLEr3dataclass_class_maker_callbackr|s rWget_class_decorator_hookz'PydanticPlugin.get_class_decorator_hooks$ ) ).@6.I== =rYc|jS)zjReturn all plugin config data. Used by mypy to determine if cache needs to be discarded. )r`)rcctxs rWreport_config_dataz!PydanticPlugin.report_config_datas    rYct|j|j|j|j}|j Sr\)PydanticModelTransformerclsreasonapir^ transform)rcr transformers rWruz3PydanticPlugin._pydantic_model_class_maker_callbacks3.sww CGGTM_M_` $$&&rYc|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)r^debug_dataclass_transformrinfodeclared_metaclassgetattrtyper)rcrinfo_metaclasss rWr{z8PydanticPlugin._pydantic_model_metaclass_marker_callbacks^    7 7 88NNN~ >&&(BD I;?N   8 JrYc| |j |jddk(sJd|jddk(sJd|jd}|jd}|r$|r"t|j|j  S|r+|j dd}|d}t|ts|S S|r|j dd}t|tr|jd}t|trH|j}t|dd}|r+td |Drt fd |D|_|S S) aoExtract the type of the `default` argument from the Field function, and use it as the return type. In particular: * Check whether the default and default_factory argument is specified. * Output an error if both are specified. * Retrieve the type of the argument which is specified, and use it as return type for the function. rdefaultz0"default" is no longer first argument in Field()rdefault_factoryz9"default_factory" is no longer second argument in Field()argsNc3<K|]}t|tywr\)rqrA)rlargs rWrnz:PydanticPlugin._pydantic_field_callback..sHC:c;7Hsc3"K|]}ywr\)rl_default_any_types rWrnz:PydanticPlugin._pydantic_field_callback..s-M1.>-Ms )default_return_typecallee_arg_namesr+error_default_and_default_factory_specifiedrcontext arg_typesrqrr=itemsr:ret_typeralltuple) rcr default_argsdefault_factory_args default_type default_argdefault_factory_typerrrs @rWrz'PydanticPlugin._pydantic_field_callbacksM22##A&)3g5gg3##A&*;;x=xx;xx{ "xx{ 0 7 M# # ==+A.L&q/Kk<8##* '"#&==#3A#6 . ;';'A'A!'D$. =/88x6H4HH(--M-M(M rYrdr+returnNone)ristrrz(Callable[[ClassDefContext], bool] | None)rirrz(Callable[[ClassDefContext], None] | None)rirrz(Callable[[FunctionContext], Type] | None)rirrz&Callable[[MethodContext], Type] | None)rr1rdict[str, Any])rr-rbool)rr-rr)rr.rr>)__name__ __module__ __qualname____doc__rbrxr}rrrrrur{r __classcell__)res@rWrUrUs9#"   !' @. rYrUcNeZdZUdZdZded<ded<ded<ded<d dZd d Zy ) 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_aliasesrrrrrrc|jyt|j}|q|jdijdi}|jD]?}|j|d}t |t st d|t|||Ayt}|j|j|jD]'}|jt|d}t|||)y)NtoolrJFz/Configuration value must be a boolean for key: )fallback) config_file parse_tomlget __slots__rqr ValueErrorsetattrrread getbooleanCONFIGFILE_KEY)rcrd toml_configconfigkeysettingr^s rWrbzPydanticPluginConfig.__init__s    &  !4!45  " __VR044_bIF~~ **S%0!'40$'VWZV[%\]]c7+ & )NM   w22 3~~'22>3QV2Wc7+&rYcV|jDcic]}|t||c}Scc}w)z/Returns a dict of config names to their values.)rr)rcrs rWr_zPydanticPluginConfig.to_data!s&37>>BCWT3''BBBs&Nrrr)rrrrr__annotations__rbr_rrYrWr]r]s3I #''##,&CrYr]c|j}t|tr |j}t|tr't|j t r |j }n]t|t r|}nJd|d|jjd}t||j|j|jS|jjjt}| |jSt!d|jj"Ds |jS|jdijd}|dur5t%|jj&|j|j|jS)z1Raise an error if from_attributes is not enabled.z ctx.type: (of type )c3BK|]}|jtk(ywr\rhrks rWrnz+from_attributes_callback..7sStt}} 22Srorfrom_attributesT)rrqr@itemr:rr;rererror_unexpected_behaviorrrrmetadatar METADATA_KEYrsrterror_from_attributesname)rctx_type model_typedetailpydantic_metadatars rWrr&s5xxH(H%==(L)j9J9JH.U&& Hh ' hZz(2D2D2M2M1NaP!&#''3;;?&&&"0044\B &&& Sz?R?RS S&&&'++Hb9==>OPOd"joo22CGGS[[I  " ""rYceZdZdZ d dZ d dZ d d dZ d ddZddZe ddZ ddZ y )PydanticModelFieldz5Based on mypy.plugins.dataclasses.DataclassAttribute.c ||_||_||_||_||_||_||_||_| |_| |_ yr\) ralias is_frozenhas_dynamic_alias has_defaultstrictlinecolumnrr) rcrrrrrrrrrrs rWrbzPydanticModelField.__init__CsL  "!2&     rYc 0|j||||} |j|n |j} |s| r|j||} nttj } t | | d|r tS|s |jr tStS)zABased on mypy.plugins.dataclasses.DataclassAttribute.to_argument.N)variabletype_annotation initializerkind) to_varrr r9r?explicitrr rr r ) rc current_infotyped model_strictforce_optional use_aliasrforce_typevars_invariantis_root_model_rootrrrs rW to_argumentzPydanticModelField.to_argument[s;;|S)=UV!%!4$++ F"..|SAO%i&8&89O+!   $2T5E5E-   LU   rYcd|rFt|jtr,|jj}t|_||_|jt |jddtj|jj5t|}|r-|jD]}t|tst|_ t|j|jjj |icdddS|jS#1swY|jSxYw)zABased on mypy.plugins.dataclasses.DataclassAttribute.expand_type.N self_type)rqrrA copy_modifiedrvariancerrr7strict_optional_setrdstrict_optionalrDrr rid)rcrrr modified_typefilled_with_typevarsrs rWr zPydanticModelField.expand_typexs $ $))[1 $ 7 7 9 )2 &) 99 WTYY T%J%V **3;;+F+FG ^'4\'B$+388%c;7+4CL 9#499tyy/B/B/E/EG[.\]  ^ ^yy ^yys-DADD/c|r|j |j}n |j}t||j|||S)zextrafrozenralias_generatorrpopulate_by_namezset[str]tracked_config_fieldsc<||_||_||_||_yr\)_cls_reason_apir^)rcrrrr^s rWrbz!PydanticModelTransformer.__init__s!   *rYc|jj}td|jddD}|j }|j ||\}}||y|D]}|j ytd|jddD}|j|||||j|||||j||j|jdu|j|Dcic]}|j|jc}|Dcic]}|j|jc}|jd|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 c3@K|]}t|jvywr\)ROOT_MODEL_FULLNAMErirks rWrnz5PydanticModelTransformer.transform..s/4==@NFc3BK|]}|jtk(ywr\)riBASESETTINGS_FULLNAMErks rWrnz5PydanticModelTransformer.transform..s[T$--+@@[roT)r&)fields class_varsr)r+rrsrtcollect_configcollect_fields_and_class_varsradd_initializeradd_model_construct_method set_frozenr-r&adjust_decorator_signaturesrr get_values_dictrr) rcr is_root_modelrr4r5field is_settings class_vars rWrz"PydanticModelTransformer.transformsSyy~~XXVYWY][[ $$&!?? V >Z/Ezz![TXXVYWY][[  VV[-H '' ]S  &--42GH ((*CIIuzz5??#44IR\]Y9>>9+>+>+@@],,.'  l#  J]s :"E*""E/c&|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_namesrqr%value)rlir first_decs rWrnzGPydanticModelTransformer.adjust_decorator_signatures../sO  &3&//2f<rCQXAYr^a^g^gkr^rr sAATN)r+rnamesvaluesrqrrroriginal_decoratorsrcalleer riDECORATOR_FULLNAMESMODEL_VALIDATOR_FULLNAMErs enumeraterfuncis_class)rcrwrHs @rWr;z4PydanticModelTransformer.adjust_decorator_signaturess99>>''..0C#((I.HH88; y(3"9#3#3X>!((115HH"((115MM *3INN*C .2CHHMM*#1rYc |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|rF|rD|j0r8|j2s,|j4j6rt9|j,||j:j<d dD]}t>|j@vr|j,jCtE|jF|j@t>d jD]\}}|jI|||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 kwargsrr)%r+ModelConfigDatakeywordsrget_config_updateupdatedefsbodyrqrrlvaluesr rrvaluerziprErrr%rFr-failhas_alias_generatorr(r^rerror_required_dynamic_aliasesrrtrradd_plugin_dependencyr6ri setdefault)rcrrhas_config_kwargshas_config_from_namespacerexpr config_datastmtlhsarg_namerkey_expr value_exprsubstmtrrFs rWr6z'PydanticModelTransformer.collect_config8sii "!$)!,,,,.JD$00t?$/ll1o!#x0CHH4Ndkk84),T[[-B-BDKKDTDT)U ##+$ d&<& !//!,C%c84 MM$"8"87>>"RS .! o(, %M"P  9..//&&DD.tyy$?HHLL$D4==0 II + +,A$--,P Q#}}\:8DJJL e!!$. M % rYc|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| ||}t#|trb| j2d}|r&|j4dk7rt7|j | ]| j9|j4|||j4<t#|t(s| j2d}| j9|j4|||j4<t;|j=t;|j=fS)zACollects the fields for the model, accounting for parent classes.rr1r4z7BaseModel field may only be overridden by another fieldr5rroot)r+reversedrrtrrr-rbr6rirrrrrIrrrrqr*r_rset%_get_assignment_statements_from_blockrZ$collect_field_or_class_var_from_stmtr\r error_extra_fields_on_root_modeladdlistrJ)rcrSr=r found_fieldsfound_class_varsrrrr>sym_nodecurrent_field_namescurrent_class_vars_namesrh maybe_fieldris rWr7z6PydanticModelTransformer.collect_fields_and_class_varssHii79 =?SXX\\!B/0D4==0 II + +,A$--,P Q"mmL9(CIIK d*66tT499M 11#((DIIF%* T"88>>--d3 jPS6TIINNQ L #mmL9,GMMO d)>)J)J4)P &P51<),-0U >>sxxHDCCD,XhiK+'9:ll1o SXX%74TYYE'++CHH5-8L*K)>?ll1o(,,SXX6-8 *IL'')*D1A1H1H1J,KKKrYc#K|jD](}|jr|j|Ed{*|j;|jjs$|j|jEd{yyy7N7 wr\)r[is_unreachablerr else_body)rcrhr[s rW,_get_assignment_statements_from_if_statementzEPydanticModelTransformer._get_assignment_statements_from_if_statementstIID&&EEdKKK >> %dnn.K.KAA$..Q Q Q/L %L Qs'BBBAB:B;BBc#K|jD]A}t|tr|t|ts)|j |Ed{Cy7wr\)r[rqrrr)rcblockrhs rWrrz>PydanticModelTransformer._get_assignment_statements_from_blocksGJJD$/ D&)LLTRRR Ss5AA A Ac |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|_|jI|\} } | r8|jJs,|jLjNrtQ|j||jS|}|jU||j |}tW|j | | | | ||jX|jZ||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`. rrSNzFType 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\rqr rGis_valid_field_namer new_syntaxr]rrLrirMerror_untyped_fieldsr-rrIrrrr"r(r_r* is_classvarrrCrr;get_has_default get_strictr is_inferredanalyze_simple_literal_typer9r? from_errorget_alias_infor(r^rrais_field_frozen_infer_dataclass_attr_init_typerrr)rcrhrSr5rrirwrr node_typerrrrrr init_types rWrsz=PydanticModelTransformer.collect_field_or_class_var_from_stmtsiill1o#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 #'#6#6t#<  \%B%BtGYGYGwGw *499d ;((. 88chhM !/#;;  rYc8|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__rSz(Unsupported signature for "__set__" in ""zUnsupported "__set__" in ")rimplicitrCrqr;rrrrget_containing_type_infor8r9r? unannotatedr: arg_kindsrr rr-r_r) rcrwrrrtsetter super_info setter_types rWrz8PydanticModelTransformer._infer_dataclass_attr_init_typeTsG (( <<N CHH % !X&NI& &++w/VV< 3;3H3H3KQOOIINN%Maffkk]Z[#\^ef !;AFFKK=JGTrYc d|jjjvr.|jjjdjsy|jj }t |j}|jdu}t |jxr |j }|j|||||||d} |r3tdkr*| djtk(rtnt| d_ |r|j j#t$j&} d| jvr| jdj&} | | j(| j(} t+| j,D]}\} }|j/ds|j/ds)|j j1| j2| }t5||}| j7t9||dt|j;||sCt5d }| j7t9|t=t>j@dtBtE|j |jd| tG 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. rbNT)rrrequires_dynamic_aliasesrr?r=r)rrrr__rkwargs)r return_type)$r+rrIplugin_generatedr^rrrr(r`get_field_argumentsrrr rr r-rpr3rrrrOrE startswith anal_typerr*appendrshould_init_forbid_extrar9r?rr add_methodr<)rcr4rr?r=rrrrrbase_settings_nodebase_settings_init_node func_typearg_idxrjanalyzed_variable_typervars rWr8z(PydanticModelTransformer.add_initializerzs -- -diinn6J6J:6V6g6g ""--FMM* ++47 #'(B(B(b6KbKbGb#c '' %%=#'%)(   /9<'+1glli&?7WDGL !%!A!ABW!X!]!] /555*<*B*B:*N*S*S'*6;R;W;W;c 7 < ryrvar_strrs rWr:z#PydanticModelTransformer.set_frozens) yy~~Ezz~~ejj1H#mmc3'&,&?CO_5dii>W>WIIOO%,"%c( /wiz#--PQRF-fdiiKll4l>"( $  3chh > '6tS'A 388$/%,"&s),s8 E&&E=<E=c||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) Nr%forbid) forbid_extrar'T builtins.NoneF)r`) builtins.Truebuiltins.Falserr) r)rqr%rFrrerror_invalid_config_valuer-rVr ri)rcrrrTrr`s rWrXz*PydanticModelTransformer.get_config_updates t11 1 7?#w'"yyH4 C,"xx83  /tTYYD" = = $ $"& #x(S\\_-L&+#"7JK K c8 $9\)\"MdCLLO,K%LM M"4C8rYc|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.Frrr)r]rqr'rrLr#rirr^rrErerr rhrfrrs rWrz(PydanticModelTransformer.get_has_defaults{{ dH % dH %*T[['*Jt{{OcOcguOu !DNN; T<49#4== <<,, *3 9 ]cllo>]^^ < dL111rYcl|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]rqrrLr#rirr^rrEr rs rWrz#PydanticModelTransformer.get_strict+s{{ dH %*T[['*Jt{{OcOcguOu DNN; T8#c8,||6#)99$<rYct|j}t|tryt|tr7t|jt r|jj tk(syt|jD];\}}|dk7r |j|}t|tr|jdfcSyy)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. )NFrF)NT) r]rqr'rrLr#rirrOrErr%rFrhrfrGrjrs rWrz'PydanticModelTransformer.get_alias_info;s{{ dH % tX &:dkk7+KPTP[P[PdPdhvPv$T^^4KAx7"))A,C#w'yy%''!5rYcv|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. Fr&r) r]rqr'rrLr#rirrOrErr rs rWrz(PydanticModelTransformer.is_field_frozenWs{{ dH % tX &:dkk7+KPTP[P[PdPdhvPv$T^^4KAx8#iil!#x0TS\\_5TT5rYc |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. ro)rrrrrrr)r+rrrr-r) rcr4rrrrr?r=rrr> argumentss rWrz,PydanticModelTransformer.get_field_argumentspsyy~~   %"9"9   )7F;#II)A#0#IUZZ65I       sA A,c|js&|j|t|jry|jry|j j S)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(is_dynamic_alias_presentrr`rr^r)rcr4rs rWrz1PydanticModelTransformer.should_init_forbid_extrasI &&,,VT&:T:T5UV   !!333rYc\|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)r4r`r>s rWrz1PydanticModelTransformer.is_dynamic_alias_presents; E&& ;;& rYN) rrrzExpression | Statementrr2r^r]rr)rr)rr)rrV)rSrVr=rrzJtuple[list[PydanticModelField] | None, list[PydanticModelClassVar] | None])rhrrIterator[AssignmentStmt])rrrr)rhrrSrVr5z dict[str, PydanticModelClassVar]rz1PydanticModelField | PydanticModelClassVar | None)rwr&rrrrrr) r4list[PydanticModelField]rrVr?rr=rrr)r4rrr2r&rrrr)rrrrrTrrModelConfigData | None)rhrrr)rhrrr)rhrrztuple[str | None, bool])r4rrrrrrrrrr?rr=rrrrlist[Argument])r4rrrVrr)r4rr`rrr)rrrrr)rrbrr;r6r7rrrrsrr8r9r:rX staticmethodrrrrrrrrrYrWrrs '8 +  +' +- + , +  +"H26JX?L+?L<@?L S?LBRS " 2A Oo : B$L/X./X8G/XVZ/Xko/X /Xb& (&  &  &  &  & PB>!F22*  6B*/(    #' #' @ 4  rYrcTeZdZdZ d ddZd dZd dZd dZy) rVz(Pydantic mypy plugin model config class.NcX||_||_||_||_||_||_yr\)rr&rr(r`r)rcrr&rr(r`rs rWrbzModelConfigData.__init__s2) . 0#6  rYcp|jjDcic] \}}| || c}}Scc}}w)zReturns a dict of Pydantic model config names to their values. It includes the config if config value is not `None`. )__dict__r)rckvs rWr<zModelConfigData.get_values_dicts1 "&!4!4!6HA!-1HHHs 22cp|y|jjD]\}}t|||y)z$Update Pydantic model config values.N)r<rr)rcrrrs rWrYzModelConfigData.updates6 > **,224DAq D!Q 5rYc8t||t|||yy)zFSet default value for Pydantic model config if config value is `None`.N)rr)rcrrFs rWrczModelConfigData.setdefaults 4  % D#u % &rY)NNNNNN) rrr&rrrr(rr`rrrr)rrrr)rrrFrrr)rrrrrbr<rYrcrrYrWrVrVsh2%)"'+(,+/"!%  &  )  I &rYrVz 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`.rz$" does not have from_attributes=TruecodeN)r_ ERROR_ORM) model_namerrs rWrrsHHq @ A7QZH[rYc<|jd|d|ty)z0Emits an error when the config value is invalid.zInvalid value for "Config.rrN)r_ ERROR_CONFIG)rrrs rWrrsHH)$q 17HNrYc4|jd|ty)znEmits required dynamic aliases error. This will be called when `warn_required_dynamic_aliases=True`. z#Required dynamic aliases disallowedrN)r_ ERROR_ALIASrrs rWraras HH 2G+HNrYcVd}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)rrrlink full_messages rWrrsA DDLVHTVWLField default and default_factory cannot be specified togetherrN)r_ERROR_FIELD_DEFAULTSrs rWrrsHH Mw]qHrrYcD|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|g|_t ||t1t3g}||_t5|||_||_|j:dz|z|_|j>|_||jvr2tA||j}|j||j|<|rud|_!t||j6}||_|j<|_d|_"tG|tIdg|}|j>|_tKtL|} ntKtL|} d| _| |j|<|jNj 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.rr)(rrIrrqrrrrZr[remover2rnamed_generic_typer@rDrr*rrrrrrr: variablesrr!r5rrQrirrrE is_decoratedrrr r&rdefn)rrrrrrtvar_defrrrw function_typefirstrrErr signaturerPr_namerdecs rWrrs 88D tzzjj   Jsxx$A HHMM  *#67':; ../BBG >-*=!> #f+y$FG4t!4 #12ItWMN 4)rrrr,rrrr)rrrr2rrrr)rr2rrrr)rrrz8CheckerPluginInterface | SemanticAnalyzerPluginInterfacerrrr)rr,rrrr)NNF)rz8SemanticAnalyzerPluginInterface | CheckerPluginInterfacerrrrrrrr>rrrzTypeVarDef | Nonerrrr)rrrzdict[str, Any] | None)r __future__rr configparserrtypingrrrmypy.errorcodesrmypy.expandtyper r mypy.nodesr r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r* mypy.optionsr+ mypy.pluginr,r-r.r/r0r1r2 mypy.pluginsr3mypy.plugins.commonr4 mypy.semanalr5mypy.server.triggerr6 mypy.stater7 mypy.typeopsr8 mypy.typesr9r:r;r<r=r>r?r@rArBrC mypy.typevarsrD mypy.utilrE mypy.versionrF mypy_versionpydantic._internalrGpydantic.versionrHrIr rrrjr3r0rzrrrNrMrrrXrUr]rrrrrVrrrrrrrrrrarrrtrrrrrYrWr(sd" %**%@!!!!!!!!!D!%+50    (24&/5% !' .=5R(5K( 50H< .   s Vs l+C+C\#4@T@TF  2M M `$&$&N n&Dj Q *,BJO (*DjQ 24I:V*,F S  !13KZX()9;^`jk\ O O; ;N;Y`; ;G o s""& U% AU% U% U%  U%  U%  U% U%U% U%pW(5445s$G G/.G/