
    bMh%                        d dl Z d dlmZ d dlmZmZmZmZmZm	Z	m
Z
mZmZ d dlmZ d dl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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- d dl.m/Z/ d dl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7 d dl8m9Z9 d d	l:m;Z; d d
l<m=Z= d dl>m?Z?m@Z@mAZAmBZBmCZCmDZDmZmEZEmFZFmGZGmHZHmIZImJZJ d dlKmLZL d dlMmNZN d dlOmPZQ d dlRmSZS 	 d dl>mTZT n# eU$ r	 d dl>mHZT Y nw xY wdZVdZWeXdd         ZYeY dZZeY dZ[eY dZ\eY dZ]eY dZ^de_de
e`df         fdZa eaeQ          Zbebdk    rdnd Zcd!ZPde_dd"fd#Zd G d$ d%e5          Ze G d& d'          Zfd(e4defd)Zg G d* d+          Zh G d, d-          Zi G d. d/          Zj ed0d1d2          Zk ed3d4d2          Zl ed5d6d2          Zm ed7d8d2          Zn ed9d:d2          Zo ed9d;d2          Zpd<e_d=e1d>eddfd?Zqd@e_d=e7d>eddfdAZrd=e7d>eddfdBZsdCe_d=ee1e7f         d>eddfdDZtd=e7d>eddfdEZud=e1d>eddfdFZv	 	 	 	 dTd(e2d@e_dHee         dIedJee         dKeeT         dLewdMewddfdNZxdOeee(f         de_fdPZydOeee(f         de_fdQZzdRe_deee_ef                  fdSZ{dS )U    N)ConfigParser)	AnyCallableDictListOptionalSetTupleTypeUnion)	ErrorCode)	ARG_NAMEDARG_NAMED_OPTARG_OPTARG_POS	ARG_STAR2MDEFArgumentAssignmentStmtBlockCallExprClassDefContext	DecoratorEllipsisExprFuncBaseFuncDefJsonDict
MemberExprNameExprPassStmtPlaceholderNodeRefExprStrExpr
SymbolNodeSymbolTableNodeTempNodeTypeInfoTypeVarExprVar)Options)CheckerPluginInterfaceClassDefContextFunctionContextMethodContextPluginReportConfigContextSemanticAnalyzerPluginInterface)dataclasses)set_callable_name)make_wildcard_trigger)AnyTypeCallableTypeInstanceNoneType
Overloaded
ProperTyper   	TypeOfAnyTypeType	TypeVarIdTypeVarType	UnionTypeget_proper_type)fill_typevars)get_unique_redefinition_name)__version__)is_valid_field)
TypeVarDef)r?   pydantic-mypyzpydantic-mypy-metadataz.main.BaseModelz.env_settings.BaseSettingsz.main.ModelMetaclassz.fields.Fieldz.dataclasses.dataclassversionreturn.c                     t          t          t          |                     d          d                             d                              S )N+r   .)tuplemapint	partitionsplitrI   s    P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pydantic/v1/mypy.pyparse_mypy_versionrU   W   s;    S'++C00399#>>??@@@    )r   i  builtins__builtins__   zTypingType[Plugin]c                     t           S )z
    `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).
    )PydanticPluginrS   s    rT   pluginr\   b   s
     rV   c                   "    e Zd Zdeddf fdZdeddfdZdedeee	gdf                  fdZ
dedd	fd
Zdedeeegef                  fdZdedeee	gdf                  fdZdedeeef         fdZde	ddfdZde	ddfdZdeddfdZ xZS )r[   optionsrJ   Nc                     t          |          | _        | j                                        | _        t	                                          |           d S N)PydanticPluginConfigplugin_configto_data_plugin_datasuper__init__)selfr^   	__class__s     rT   rf   zPydanticPlugin.__init__m   sH    1':: .6688!!!!!rV   fullnamez+Optional[Callable[[ClassDefContext], None]]c                     |                      |          }|rDt          |j        t                    r*t	          d |j        j        D                       r| j        S d S )Nc              3   F   K   | ]}t          |          t          k    V  d S r`   )get_fullnameBASEMODEL_FULLNAME.0bases     rT   	<genexpr>z5PydanticPlugin.get_base_class_hook.<locals>.<genexpr>v   s0      UU<%%);;UUUUUUrV   )lookup_fully_qualified
isinstancenoder(   anymro$_pydantic_model_class_maker_callbackrg   ri   syms      rT   get_base_class_hookz"PydanticPlugin.get_base_class_hookr   sd    ))(33 	A:ch11 	AUUUUUUU A@@trV   c                 *    |t           k    r| j        S d S r`   )MODEL_METACLASS_FULLNAME)_pydantic_model_metaclass_marker_callbackrg   ri   s     rT   get_metaclass_hookz!PydanticPlugin.get_metaclass_hookz   s    ///AAtrV   z+Optional[Callable[[FunctionContext], Type]]c                 b    |                      |          }|r|j        t          k    r| j        S d S r`   )rr   ri   FIELD_FULLNAME_pydantic_field_callbackrx   s      rT   get_function_hookz PydanticPlugin.get_function_hook   s7    ))(33 	13<>1100trV   c                 >    |                     d          rt          S d S )Nz	.from_orm)endswithfrom_orm_callbackr~   s     rT   get_method_hookzPydanticPlugin.get_method_hook   s#    [)) 	%$$trV   c                 J    |t           k    rt          dk     rt          j        S dS )zMark pydantic.dataclasses as dataclass.

        Mypy version 1.1.1 added support for `@dataclass_transform` decorator.
        )   r   N)DATACLASS_FULLNAMEMYPY_VERSION_TUPLEr3   dataclass_class_maker_callbackr~   s     rT   get_class_decorator_hookz'PydanticPlugin.get_class_decorator_hook   s)    
 ))).@6.I.I==trV   ctxc                     | j         S )zjReturn all plugin config data.

        Used by mypy to determine if cache needs to be discarded.
        )rd   )rg   r   s     rT   report_config_dataz!PydanticPlugin.report_config_data   s    
   rV   c                 X    t          || j                  }|                                 d S r`   )PydanticModelTransformerrb   	transform)rg   r   transformers      rT   rw   z3PydanticPlugin._pydantic_model_class_maker_callback   s,    .sD4FGGrV   c                     | j         j        rdS |j        j        j        }|s
J d            t          |j        dd          rd|j        _        dS dS )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)rb   debug_dataclass_transformclsinfodeclared_metaclassgetattrtyper   )rg   r   info_metaclasss      rT   r}   z8PydanticPlugin._pydantic_model_metaclass_marker_callback   sn     7 	F8NNNNNN>&(BDII 	@;?N888	@ 	@rV   r   c                   	 |j         	|j        d         dk    s
J d            |j        d         dk    s
J d            |j        d         }|j        d         }|r|rt          |j        |j                   	S |r3|j        d         d         }|d         }t          |t                    s|S n|r|j        d         d         }t          |t                    r3t          dk    r|j        d         }n|                                d         }t          |t                    rU|j        }t          |dd	          }|r9t          d
 |D                       r t!          	fd|D                       |_        |S 	S )ax  
        Extract 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.
        r   defaultz0"default" is no longer first argument in Field()r   default_factoryz9"default_factory" is no longer second argument in Field())r   i  argsNc              3   @   K   | ]}t          |t                    V  d S r`   )rs   r?   )ro   args     rT   rq   z:PydanticPlugin._pydantic_field_callback.<locals>.<genexpr>   s,      HHC:c;77HHHHHHrV   c              3      K   | ]}V  d S r`    )ro   _default_any_types     rT   rq   z:PydanticPlugin._pydantic_field_callback.<locals>.<genexpr>   s$      -M-M1.>-M-M-M-M-M-MrV   )default_return_typecallee_arg_namesr   +error_default_and_default_factory_specifiedapicontext	arg_typesrs   r   r:   r   itemsr7   ret_typer   allrN   )
rg   r   default_argsdefault_factory_argsdefault_typedefault_argdefault_factory_typer   r   r   s
            @rT   r   z'PydanticPlugin._pydantic_field_callback   s    2#A&)3335g333#A&*;;;;=x;;;x{"x{ 	$0 	$7MMM## 	 =+A.L&q/K k<88 $##$ " 	 #&=#3A#6  .
;; K%00+?+Ea+H(( ,@+E+E+G+G+J(.== 	 /8 x66 NHH4HHHHH N(--M-M-M-M-M-M-M(M(MrV   )__name__
__module____qualname__r+   rf   strrz   r   r   r-   r   r   r/   r   r   r   r1   r   r   r   rw   r}   r.   r   __classcell__)rh   s   @rT   r[   r[   l   s       " "D " " " " " "
C 4a    3 8HoEVX\E\<]3^    
# 2_     =/SWBW9X0Y    
 (OK\^bKbBc9d    !&9 !d38n ! ! ! !   D        @_ @QU @ @ @ @3 O 3  3  3  3  3  3  3  3  3 rV   r[   c                   r    e Zd ZU dZeed<   eed<   eed<   eed<   eed<   dedd	fd
Zdee	e
f         fdZd	S )ra   )init_forbid_extra
init_typedwarn_required_dynamic_aliaseswarn_untyped_fieldsr   r   r   r   r   r   r^   rJ   Nc                    |j         d S t          |j                   }||                    di                               di           }| j        D ]P}|                    |d          }t	          |t
                    st          d|           t          | ||           Qd S t                      }|	                    |j                    | j        D ]0}|
                    t          |d          }t          | ||           1d S )NtoolrG   Fz/Configuration value must be a boolean for key: )fallback)config_file
parse_tomlget	__slots__rs   bool
ValueErrorsetattrr   read
getbooleanCONFIGFILE_KEY)rg   r^   toml_configconfigkeysettingrb   s          rT   rf   zPydanticPluginConfig.__init__   s$   &F !455" __VR0044_bIIF~ , , **S%00!'400 ^$%\WZ%\%\]]]c7++++	, , )NNMw2333~ , ,'22>3QV2WWc7++++, ,rV   c                 *      fd j         D             S )Nc                 2    i | ]}|t          |          S r   )r   )ro   r   rg   s     rT   
<dictcomp>z0PydanticPluginConfig.to_data.<locals>.<dictcomp>  s%    BBBCWT3''BBBrV   )r   rg   s   `rT   rc   zPydanticPluginConfig.to_data  s    BBBB4>BBBBrV   )r   r   r   r   r   __annotations__r+   rf   r   r   r   rc   r   rV   rT   ra   ra      s         I #''''####, ,D , , , ,&Cc3h C C C C C CrV   ra   r   c                 l   | j         }t          |t                    r|j        }t          |t                    r"t          |j        t                    r|j        }nMt          |t                    r|}n5d| d|j        j         d}t          || j
        | j                   | j        S |j         j                            t                    }|| j        S |                    di                               d          }|dur-t!          t#          |j                   | j
        | j                   | j        S )z3
    Raise an error if orm_mode is not enabled
    z
ctx.type: 
 (of type )Nr   orm_modeT)r   rs   r=   itemr7   r   r8   rh   r   error_unexpected_behaviorr   r   r   metadatar   METADATA_KEYerror_from_ormget_name)r   ctx_type
model_typedetailpydantic_metadatar   s         rT   r   r     s)   
 xH(H%% !=(L)) 'j9JH.U.U '&

	Hh	'	' '

PhPP(2D2MPPP!&#'3;???&&"044\BB && $$Xr2266zBBHtx
00#'3;GGG""rV   c                      e Zd ZU h dZee         ed<   dededdfdZ	d&dZ
d&d	Zd'dZdd
ded         fdZded         dd
deddfdZded         ddfdZded         deddfdZdeded
         fdZededededefd            Zedee         defd            Zededeee         ef         fd            Zded         ded ed!edee         f
d"Zded         dd
defd#Z eded         d$edefd%            Z!dS )(r   >   extrafrozenr   allow_mutationalias_generatorallow_population_by_field_nametracked_config_fieldsr   rb   rJ   Nc                 "    || _         || _        d S r`   )_ctxrb   )rg   r   rb   s      rT   rf   z!PydanticModelTransformer.__init__)  s    	*rV   c                    | j         }|j        j        }|                                  |                                 }|                     |          }t          d |j        dd         D                       }|                     |||           | 	                    |           | 
                    ||j        du p|j        du            d |D             |                                d|j        t          <   dS )	a  
        Configures 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 allow_mutation = False or frozen = True
        * stores the fields, config, and if the class is settings in the mypy metadata for access by subclasses
        c              3   F   K   | ]}t          |          t          k    V  d S r`   )rl   BASESETTINGS_FULLNAMErn   s     rT   rq   z5PydanticModelTransformer.transform.<locals>.<genexpr>=  s0      ``$,t,,0EE``````rV   NFT)r   c                 B    i | ]}|j         |                                S r   )name	serialize)ro   fields     rT   r   z6PydanticModelTransformer.transform.<locals>.<dictcomp>B  s&    IIIuz5??#4#4IIIrV   )fieldsr   )r   r   r   adjust_validator_signaturescollect_configcollect_fieldsru   rv   add_initializeradd_construct_method
set_frozenr   r   set_values_dictr   r   )rg   r   r   r   r   is_settingss         rT   r   z"PydanticModelTransformer.transform-  s    iw|((***$$&&$$V,,``RVRZ[^\^[^R_`````VV[999!!&)))v'<'E'^Z^I^___II&III,,..'
 '
l###rV   c                 j   | j         j        j        j                                        D ]\  }}t          |j        t                    rj|j        j        d         }t          |t                    rCt          |j
        t                    r)|j
        j        t           dk    rd|j        j        _        dS )a[  When we decorate a function `f` with `pydantic.validator(...), 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()` call as a classmethod.
        r   z.class_validators.validatorTN)r   r   r   namesr   rs   rt   r   original_decoratorsr   calleer    ri   
_NAMESPACEfuncis_class)rg   r   ry   	first_decs       rT   r   z4PydanticModelTransformer.adjust_validator_signaturesF  s     +17799 	2 	2ID##(I.. 2H8;	y(332"9#3X>>2 "(1
5_5_5___-1CHM*	2 	2rV   ModelConfigDatac                    | j         }|j        }t                      }|j        j        D ]}t          |t                    s|j        dk    r||j        j        D ]@}t          |t                    s|	                    | 
                    |                     A|j        r(|j        s!| j        j        rt          |j        |           |j        j        dd         D ]}t&          |j        vr|j                            t-          t/          |                               |j        t&                   d                                         D ]\  }}|                    ||           |S )zz
        Collects the values of the config attributes that are used by the plugin, accounting for parent classes.
        Configr   Nr   )r   r   r  defsbodyrs   r   r   r   updateget_config_updatehas_alias_generatorr   rb   r   error_required_dynamic_aliasesr   r   rv   r   r   add_plugin_dependencyr5   rl   r   
setdefault)	rg   r   r   r   stmtsubstmtr   r   values	            rT   r   z'PydanticModelTransformer.collect_configX  s    ig ""HM 	B 	BDdH-- yH$$#y~ C CG%g~>> ! MM$"8"8"A"ABBBB.B"AB *HB
 337DAAAHL$ 	/ 	/D4=00 G))*?T@R@R*S*STTT#}\:8DJJLL / /e!!$..../rV   model_configPydanticModelFieldc                    | j         }| j         j        }g }t                      }|j        j        D ]}t          |t                    s|j        d         }t          |t                    rt          |j
                  sP|j        s!| j        j        rt          |j        |           |j        j                            |j
                  }||j        }	t          |	t(                    rt          |	t*                    s|	j        r|                     |||          }
|                     |          \  }}|r(|j        s!| j        j        rt7          |j        |           |                    t;          |j
        |
|||j        |j                             |                     |j
                   |!                                }|j        j"        dd         D ]}tF          |j$        vrg }|j        %                    tM          tO          |                               |j$        tF                   d         (                                D ]\  }|vrFt:          )                    ||          }|                                |                    |           Ofd|D             \  }|*                    |           |                    |           ||z   }|S )zR
        Collects the fields for the model, accounting for parent classes
        r   Nr   is_requiredaliashas_dynamic_aliaslinecolumnr   r   c              3   2   K   | ]}|j         k    |V  d S r`   )r   )ro   ar   s     rT   rq   z:PydanticModelTransformer.collect_fields.<locals>.<genexpr>  s)      HHa4HHrV   )+r   r   setr	  r
  rs   r   lvaluesr    rE   r   
new_syntaxrb   r   error_untyped_fieldsr   r   r   r   rt   r"   r*   is_classvarget_is_requiredget_alias_infor   r   r  appendr  r  r  addcopyrv   r   r   r  r5   rl   r   deserializeremove)rg   r  r   r   r   known_fieldsr  lhsry   rt   r  r  r  
all_fieldsr   superclass_fieldsdatar   r   s                     @rT   r   z'PydanticModelTransformer.collect_fieldsw  s   
 iimuuHM 5	' 5	'DdN33 ,q/Cc8,, N384L4L ? 4t'9'M 4$SWd333
 (.$$SX..C{ 8D$00  dC((    ..sD#>>K'+':':4'@'@$E$!>$C> &D>
 /sw===MM" +&7;  	 	 	 SX&&&&[[]]
HL$ 	8 	8D4=00 "G))*?T@R@R*S*STTT"mL9(CIIKK 4 4
d|++.::4FFE $$T***%,,U3333HHHH:HHHHU%%e,,,%,,U3333*Z7JJrV   r   r   r   c                    | j         }| j        j        }|j        du}|pt	          |j        o|j                   }|                     ||||          }|                     ||          sPt          d          }	|	                    t          |	t          t          j                  dt                               d|j        j        j        vr t%          |d|t'                                 dS dS )z
        Adds a fields-aware `__init__` method to the class.

        The added `__init__` will be annotated with types vs. all `Any` depending on the plugin settings.
        Ttypedforce_all_optional	use_aliaskwargsNrf   )r   rb   r   r   r   r  get_field_argumentsshould_init_forbid_extrar*   r&  r   r6   r<   explicitr   r   r   r   
add_methodr9   )
rg   r   r   r   r   r2  r4  r3  init_argumentsvars
             rT   r   z(PydanticModelTransformer.add_initializer  s     i"-9E	( 
D&Tv/T+T-
 -
 11%4FR[ 2 
 
 ,,VV<< 	_h--C!!(3	8J0K0KTS\"]"]^^^SW\///sJ

CCCCC 0/rV   c           
      
   | j         }|j                            t           d|j                            t           d          g          }t	          |t                      g          }t          t          d|          |dt                    }| 	                    |ddd          }|g|z   }|j                            t           d          }d	}|j
        j        d
z   |z   }	t          dk    rt          ||	t          dk    rt          d|j
        j        dz             nt          d          g |t          t           j                            }
t%          ||	g |t          t           j                            }n%t'          ||	dg |          }
t%          ||	g |          }t)          t*          |          |j
        j        j        |<   t1          |
t                    r|
}nt          |
          }t3          |d||||
d           dS )z
        Adds a fully typed `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_setNTFr1  z.object_PydanticBaseModelrM   )r      )r      r   z
.construct)	namespace	construct)return_type	self_typetvar_defis_classmethod)r   r   
named_typeBUILTINS_NAMEr@   r9   r   r*   r   r6  r   ri   r   r?   r>   r6   r<   from_omitted_genericsr)   rF   r&   r   r   r   rs   r9  )rg   r   r   set_stroptional_set_strfields_set_argumentconstruct_argumentsobj_typeself_tvar_nametvar_fullnametvdself_tvar_exprrD  s                rT   r   z-PydanticModelTransformer.add_construct_method  s    i'$$%;%;%;cg>P>PTaQgQgQg>h>h=ijj$gxzz%:;;&s=:J'K'KM]_celmm"66vT^cot6uu236II7%%&?&?&?@@-(3.?'' *W44 bCG,<|,KLLLL"2	788 C )	788 NN ^]BHMMC(HUUN-<T>-R-R>* c;'' 	)II#C((I!	
 	
 	
 	
 	
 	
rV   r   c                    | j         }|j        j        }|D ]S}|j                            |j                  }||j        }t          |t                    r||_	        Ht          |t                    r&|j        j        s|j                                         	 t          |          }n# t          $ r t!          |          }Y nw xY wd| d|j         d}	t%          |	|j        |j                   |                    |d          }||_        ||_	        t)          |          dz   t+          |          z   |_        t/          t0          |          |j        t+          |          <   UdS )z
        Marks 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.
        Nzsym_node.node: r   r   F)r4  rM   )r   r   r   r   r   r   rt   rs   r*   is_propertyr"   r   final_iterationdeferr   	TypeErrorreprrh   r   to_varrl   r   	_fullnamer&   r   )
rg   r   r   r   r   r   sym_noder;  var_strr   s
             rT   r   z#PydanticModelTransformer.set_frozen  ss    iw| 	G 	GEz~~ej11H#mc3'' H&,COO_55 Hcg>U HGMMOOOO,"%c(($ , , ,"&s)), SwRR#-RRRF-fcgswGGGGll45l99"( ,T 2 2S 88C== H,;D#,F,F
8C==))/	G 	Gs   B**CCr  c                    |j         d         }t          |t                    r|j        | j        v sdS |j        dk    rt          |j        t                    r|j        j        dk    }nMt          |j        t                    r|j        j        dk    }n"t          |j        | j
        j        |           dS t          |          S |j        dk    r>d}t          |j        t                    r|j        j        dk    rd	}t          |
          S t          |j        t                    r/|j        j        dv r!t          di |j        |j        j        dk    iS t          |j        | j
        j        |           dS )z
        Determines the config update due to a single statement in the Config class definition.

        Warns if a tracked config attribute is set to a value the plugin doesn't know how to interpret (e.g., an int)
        r   Nr   forbid)forbid_extrar   Tzbuiltins.NoneF)r  )builtins.Truezbuiltins.Falser`  r   )r   rs   r    r   r   rvaluer$   r  r   error_invalid_config_valuer   r   r  ri   )rg   r  r,  r_  r  s        rT   r  z*PydanticModelTransformer.get_config_update<  sr    oa 3)) 	ch$:T.T.T48w'.'22 &~3x?GNJ77 &~2h>*38TY]GLLLt"====8((("&'.(33 ,8OSb8b8b&+#"7JKKKKgnh// 	]GN4KOr4r4r"\\ch0G?0Z%[\\\"38TY]GDDDtrV   r   r  r,  c                 j   |j         }t          |t                    r?t          | j        |j                 j                  }t                              |           S t          |t                    rt          |j
        t                    r|j
        j        t          k    rt          |j        |j                  D ]&\  }}||dk    r|j        t$          u c S |dk    r dS 't          | j        |j                 j                  }t                              |           S t          |t$                    S )zg
        Returns a boolean indicating whether the field defined in `stmt` is a required field.
        Nr   r   F)ra  rs   r'   rA   r   r   r   r   type_has_implicit_defaultr   r  r#   ri   r   zipr   	arg_namesrh   r   )r   r  r,  expr
value_typer   r   s          rT   r$  z(PydanticModelTransformer.get_is_requiredX  s$   
 {dH%% 	V(#();)@AAJ/II*UUUUdH%% 	V*T['*J*J 	Vt{OcguOuOu !DN;; ! !	T<49#4#4=L8888,,, 55 - )#();)@AAJ/II*UUUU$---rV   type_c                     t          | t                    rdS t          | t                    r t          d | j        D                       rdS dS )z
        Returns True if the passed type will be given an implicit default value.

        In pydantic v1, this is the case for Optional types and Any (with default value None).
        Tc              3   j   K   | ].}t          |t                    pt          |t                    V  /d S r`   )rs   r9   r6   )ro   r   s     rT   rq   zEPydanticModelTransformer.type_has_implicit_default.<locals>.<genexpr>|  sL       0
 0
HLJtX&&C*T7*C*C0
 0
 0
 0
 0
 0
rV   F)rs   r6   r@   ru   r   )ri  s    rT   rd  z2PydanticModelTransformer.type_has_implicit_defaultr  si     eW%% 	4eY'' 	C 0
 0
PUP[0
 0
 0
 -
 -
 	 4urV   c                 n   | j         }t          |t                    rdS t          |t                    r/t          |j        t
                    r|j        j        t          k    sdS t          |j	                  D ];\  }}|dk    r|j
        |         }t          |t                    r|j        dfc S  dS dS )a   
        Returns 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.
        )NFr  F)NT)ra  rs   r'   r   r  r#   ri   r   	enumeraterf  r   r$   r  )r  rg  iarg_namer   s        rT   r%  z'PydanticModelTransformer.get_alias_info  s     {dH%% 	; tX&&	+5dk7+K+K	PTP[PdhvPvPv ;$T^44 	" 	"KAx7"")A,C#w'' "y%''''!zz{rV   r2  r3  r4  c                 R    | j         j        j        fd|D             }|S )z
        Helper function used during the construction of the `__init__` and `construct` method signatures.

        Returns a list of mypy Argument instances for use in the generated signatures.
        c                 T    g | ]$}r|j         |                               %S ))r2  force_optionalr4  )r  to_argument)ro   r   r3  r   r2  r4  s     rT   
<listcomp>z@PydanticModelTransformer.get_field_arguments.<locals>.<listcomp>  sU     
 
 

 #("9
d%@R^ghh
 
 
rV   )r   r   r   )rg   r   r2  r3  r4  	argumentsr   s     ``` @rT   r6  z,PydanticModelTransformer.get_field_arguments  sS     y}!
 
 
 
 
 
 

 
 
	
 rV   c                     |j         s*|                     |t          |j                            rdS |j        rdS | j        j        S )aH  
        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_presentr   r  r_  rb   r   )rg   r   r   s      rT   r7  z1PydanticModelTransformer.should_init_forbid_extra  sS     4 	,,VT&:T5U5UVV u 	4!33rV   r  c                 F    | D ]}|j         r dS |r| D ]}|j         dS dS )z
        Returns whether any fields on the model have a "dynamic alias", i.e., an alias that cannot be
        determined during static analysis.
        TNF)r  r  )r   r  r   s      rT   rw  z1PydanticModelTransformer.is_dynamic_alias_present  sZ      	 	E& tt 	     ;&44 'urV   )rJ   N)rJ   r  )"r   r   r   r   r	   r   r   r-   ra   rf   r   r   r   r   r   r   r   r   r   r   r   r  staticmethodr   r    r$  r;   rd  r
   r%  r   r6  r7  rw  r   rV   rT   r   r     s        ' ' '3s8   +O +<P +UY + + + +
 
 
 
22 2 2 2$   >R+< RFZA[ R R R RhDd+?&@ DJ[ Djn Dsw D D D D,8
40D+E 8
$ 8
 8
 8
 8
tG&:!; GT Gd G G G GB HEV<W    8 .X .^ .( .t . . . \.2 *)= $    \  ^ hsmT6I0J    \8/09=SWdh	h    4t4H/I 4Sd 4im 4 4 4 4 .B)C Z^ cg    \  rV   r   c                       e Zd Zdededee         dededefdZded	ed
e	fdZ
dededed	ed
ef
dZd
efdZededed
d fd            ZdS )r  r   r  r  r  r  r  c                 Z    || _         || _        || _        || _        || _        || _        d S r`   r  )rg   r   r  r  r  r  r  s          rT   rf   zPydanticModelField.__init__  s4     	&
!2	rV   r   r4  rJ   c                 p    | j         }|r| j        | j        }t          ||| j                  j                  S r`   )r   r  r*   r   )rg   r   r4  r   s       rT   rY  zPydanticModelField.to_var  s8    y 	/:D4di-...rV   r2  rr  c                     |r%|| j                  j        || j                  j        }nt          t          j                  }t          |                     ||          |d |s| j        st          nt                    S )N)variabletype_annotationinitializerkind)
r   r   r6   r<   r8  r   rY  r  r   r   )rg   r   r2  rr  r4  r  s         rT   rs  zPydanticModelField.to_argument  sz     	:T$)_)5"49o2OO%i&899O[[y11+"0W8HWi	
 
 
 	
rV   c                     | j         S r`   )__dict__r   s    rT   r   zPydanticModelField.serialize  s
    }rV   r/  c                      | di |S )Nr   r   )r   r   r/  s      rT   r)  zPydanticModelField.deserialize  s    s{{T{{rV   N)r   r   r   r   r   r   rP   rf   r(   r*   rY  r   rs  r   r   classmethodr)  r   rV   rT   r  r    s       &*3;C=UYadnq   /8 / / / / / /

 

 

t 

X\ 

ai 

 

 

 

8     x x <P    [  rV   r  c                       e Zd Z	 	 	 	 	 	 ddee         dee         dee         dee         dee         dee         fdZd	eeef         fd
Z	ded          d	dfdZ
deded	dfdZdS )r  Nr_  r   r   r   r   r  c                 Z    || _         || _        || _        || _        || _        || _        d S r`   )r_  r   r   r   r   r  )rg   r_  r   r   r   r   r  s          rT   rf   zModelConfigData.__init__  s8     ), .L+#6   rV   rJ   c                 H    d | j                                         D             S )Nc                     i | ]
\  }}|||S r`   r   )ro   kvs      rT   r   z3ModelConfigData.set_values_dict.<locals>.<dictcomp>  s    HHHA!-1---rV   )r  r   r   s    rT   r   zModelConfigData.set_values_dict  s$    HH!4!4!6!6HHHHrV   r   c                     |d S |                                                                 D ]\  }}t          | ||           d S r`   )r   r   r   )rg   r   r  r  s       rT   r  zModelConfigData.update  sV    >F**,,2244 	  	 DAqD!Q	  	 rV   r   r  c                 L    t          | |          t          | ||           d S d S r`   )r   r   )rg   r   r  s      rT   r  zModelConfigData.setdefault  s2    4%D#u%%%%% &%rV   )NNNNNN)r   r   r   r   r   rf   r   r   r   r   r  r  r   rV   rT   r  r    s        (,)-!%#'9=.27 7tn7 !7 	7
 4.7 )17 &d^7 7 7 7 Ic3h I I I I X&78  T        &c &# &$ & & & & & &rV   r  zpydantic-ormzInvalid from_orm callPydanticzpydantic-configzInvalid config valuezpydantic-aliaszDynamic alias disallowedzpydantic-unexpectedzUnexpected behaviorzpydantic-fieldzUntyped field disallowedzInvalid Field defaults
model_namer   r   c                 H    |                     d|  d|t                     d S )N"z" does not have orm_mode=Truecode)fail	ERROR_ORM)r  r   r   s      rT   r   r     s,    HH::::G)HTTTTTrV   r   c                 H    |                     d|  d|t                     d S )NzInvalid value for "Config.r  r  )r  ERROR_CONFIG)r   r   r   s      rT   rb  rb    s,    HH1$1117HNNNNNrV   c                 @    |                      d|t                     d S )Nz#Required dynamic aliases disallowedr  )r  ERROR_ALIASr   r   s     rT   r  r  "  s!    HH2G+HNNNNNrV   r   c                 b    d}d|  d}|d| dz  }|                     ||t                     d S )Nz6https://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!r  )r  ERROR_UNEXPECTED)r   r   r   linkfull_messages        rT   r   r   &  sO     DDWVWWWL\T\\\\LHH\7)9H:::::rV   c                 @    |                      d|t                     d S )NzUntyped fields disallowedr  )r  ERROR_UNTYPEDr  s     rT   r"  r"  0  s!    HH('HFFFFFrV   c                 @    |                      d|t                     d S )Nz>Field default and default_factory cannot be specified togetherr  )r  ERROR_FIELD_DEFAULTSr  s     rT   r   r   4  s"    HHMw]qHrrrrrrV   Fr   rC  rD  rE  rF  is_newc                 .   | j         j        }||j        v rW|j        |         }	|	j        rCt	          |	j        t                    r)| j         j        j        	                    |	j                   |pt          |          }|s|r8t          t          d          t          j        |          dt                    g}
n6|pt          |          }t          t          d          |dt                    g}
|
|z   }g g g }}}|D ]n}|j        s
J d            |                    |j                   |                    t%          |j                             |                    |j                   o| j                            t.           d          }t1          |||||          }|r|g|_        t          ||t5          t7                      g                    }||_        t9          ||          |_        ||_        t?          |          dz   |z   |_         |j!        |_!        ||j        v r*tE          ||j                  }|j        |         |j        |<   |rwd|_#        t          ||j                  }||_        |j         |_         d|_$        tK          |tM          d          g|          }|j!        |_!        tO          tP          |          }	ntO          tP          |          }	d|	_        |	|j        |<   |j)        j        j                            |           dS )	z}
    Adds a new method to a class.

    This can be dropped if/when https://github.com/python/mypy/issues/7301 is merged
    _clsN__pydantic_self__z"All arguments must be fully typed.z	.functionrM   Tr  )*r   r   r   plugin_generatedrs   rt   r   r	  r
  r*  rB   r   r*   r=   make_normalizedr   r  r&  r   r~  r  r   rG  rH  r7   	variablesr   r!   r4   r   r  rl   rZ  r  rC   is_decoratedrF  r   r    r&   r   defn)r   r   r   rC  rD  rE  rF  r  r   ry   firstr   rf  	arg_kindsr   function_type	signaturer  r_namer  decs                        rT   r9  r9  8  s     7<D tzj 	/Jsx$A$A 	/GL$$SX...0]400I O O#f++x'?	'J'JDRYZZ[ 4t!4!4	#122ItWMMN4<D&("b)yI # #"HH$HHHH,---#,//000""""G&&-'B'B'BCCMY	9k=YYI )'j	4uhjj\2233DDI!)T22DI"DM!$''#-4DN	DI tz-dDJ??!Z-
6 * di  nx667;;
 9dC((dD))CDJtINt$$$$$rV   xc                 F    | j         }t          |          r
 |            S |S zc
    Used for compatibility with mypy 0.740; can be dropped once support for 0.740 is dropped.
    )ri   callabler  fns     rT   rl   rl     s)     
B|| rttIrV   c                 F    | j         }t          |          r
 |            S |S r  )r   r  r  s     rT   r   r     s)     
B|| rttIrV   r   c                 n   |                      d          sd S d}t          j        dk    rdd l}nI	 dd l}nC# t
          $ r6 d}	 dd l}n+# t
          $ r dd l}|                    d           Y Y d S w xY wY nw xY wt          | |          5 }|
                    |          cd d d            S # 1 swxY w Y   d S )Nz.tomlrb)   r@  r   rzJNo TOML parser installed, cannot read configuration from `pyproject.toml`.)r   sysversion_infotomllibtomliImportErrortomlwarningswarnopenload)r   	read_modetoml_r  rfs        rT   r   r     sO   (( tI
7""	!!!!! 		 		 		I$$$$$   jkkkttt	 %$			 
k9	%	% zz"~~                 sE   5 A5AA5#A/*A5.A//A54A5B**B.1B.)NNFF)|r  configparserr   typingr   r   r   r   r   r	   r
   r   
TypingTyper   mypy.errorcodesr   
mypy.nodesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   mypy.optionsr+   mypy.pluginr,   r-   r.   r/   r0   r1   r2   mypy.pluginsr3   mypy.semanalr4   mypy.server.triggerr5   
mypy.typesr6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   mypy.typevarsrB   	mypy.utilrC   mypy.versionrD   mypy_versionpydantic.v1.utilsrE   rF   r  r   r   r   r  rm   r   r|   r   r   r   rP   rU   r   rH  r\   r[   ra   r   r   r  r  r  r  r  r  r  r  r   rb  r  r   r"  r   r   r9  rl   r   r   r   rV   rT   <module>r     s`   



 % % % % % % ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] % % % % % %                                                             > !                            % $ $ $ $ $ * * * * * * 5 5 5 5 5 5                              ( ' ' ' ' ' 2 2 2 2 2 2 4 4 4 4 4 4 , , , , , ,5%%%%%%% 5 5 5444444445 !'crc]
"333 %AAA (>>> ---"::: A Ac3h A A A A ('55 0H<<

. C 0    r  r  r  r  r V r  r  r j"C "C "C "C "C "C "C "CJ#= #T # # # #2l l l l l l l l^" " " " " " " "J& & & & & & & &> In&=zJJ	y*,BJOOi(*DjQQ924I:VV 	*,F
SS y!13KZXX Us U)? U' UVZ U U U UOS O/N OY` Oei O O O OO(G ORY O^b O O O O;;24SST;_f;	; ; ; ;G= G GTX G G G Gs5K sV] sbf s s s s !%%) P% P%	P%
P% x.P% 	P%
 ~P% z"P% P% P% 
P% P% P% P%fE(J./ C    h
*+     C HT#s(^$<      s   C CC