
    %O=d                        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mEZEmFZFmGZGmHZHmIZI d dlJmKZK d dlLmMZM d dlNmOZP d dlQmRZR 	 d dl>mSZS n# eT$ r	 d dl>mGZS Y nw xY wdZUdZVdZWdZXdZYdZZdZ[de\de
e]df         fdZ^ e^eP          Z_e_dk    rdndZ`d ZOde\dd!fd"Za G d# d$e5          Zb G d% d&          Zcd'e4defd(Zd G d) d*          Ze G d+ d,          Zf G d- d.          Zg ed/d0d1          Zh ed2d3d1          Zi ed4d5d1          Zj ed6d7d1          Zk ed8d9d1          Zl ed8d:d1          Zmd;e\d<e1d=eddfd>Znd?e\d<e7d=eddfd@Zod<e7d=eddfdAZpdBe\d<ee1e7f         d=eddfdCZqd<e7d=eddfdDZrd<e1d=eddfdEZs	 	 	 	 dSd'e2d?e\dGee         dHedIee         dJeeS         dKetdLetddfdMZudNeee(f         de\fdOZvdNeee(f         de\fdPZwdQe\deee\ef                  fdRZxdS )T    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TypeVarType	UnionTypeget_proper_type)fill_typevars)get_unique_redefinition_name)__version__)is_valid_field)
TypeVarDef)r>   pydantic-mypyzpydantic-mypy-metadatazpydantic.main.BaseModelz"pydantic.env_settings.BaseSettingszpydantic.main.ModelMetaclasszpydantic.fields.Fieldzpydantic.dataclasses.dataclassversionreturn.c                     t          t          t          |                     d          d                             d                              S )N+r   .)tuplemapint	partitionsplitrG   s    7D:\Sites\api_v1\venv\Lib\site-packages\pydantic/mypy.pyparse_mypy_versionrS   U   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).
    )PydanticPluginrQ   s    rR   pluginrZ   `   s
     rT   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 )rY   optionsrH   Nc                     t          |          | _        | j                                        | _        t	                                          |           d S N)PydanticPluginConfigplugin_configto_data_plugin_datasuper__init__)selfr\   	__class__s     rR   rd   zPydanticPlugin.__init__k   sH    1':: .6688!!!!!rT   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     rR   	<genexpr>z5PydanticPlugin.get_base_class_hook.<locals>.<genexpr>t   s0      UU<%%);;UUUUUUrT   )lookup_fully_qualified
isinstancenoder(   anymro$_pydantic_model_class_maker_callbackre   rg   syms      rR   get_base_class_hookz"PydanticPlugin.get_base_class_hookp   sd    ))(33 	A:ch11 	AUUUUUUU A@@trT   c                 *    |t           k    r| j        S d S r^   )MODEL_METACLASS_FULLNAME)_pydantic_model_metaclass_marker_callbackre   rg   s     rR   get_metaclass_hookz!PydanticPlugin.get_metaclass_hookx   s    ///AAtrT   z+Optional[Callable[[FunctionContext], Type]]c                 b    |                      |          }|r|j        t          k    r| j        S d S r^   )rp   rg   FIELD_FULLNAME_pydantic_field_callbackrv   s      rR   get_function_hookz PydanticPlugin.get_function_hook}   s7    ))(33 	13<>1100trT   c                 >    |                     d          rt          S d S )Nz	.from_orm)endswithfrom_orm_callbackr|   s     rR   get_method_hookzPydanticPlugin.get_method_hook   s#    [)) 	%$$trT   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     rR   get_class_decorator_hookz'PydanticPlugin.get_class_decorator_hook   s)    
 ))).@6.I.I==trT   ctxc                     | j         S )zjReturn all plugin config data.

        Used by mypy to determine if cache needs to be discarded.
        )rb   )re   r   s     rR   report_config_dataz!PydanticPlugin.report_config_data   s    
   rT   c                 X    t          || j                  }|                                 d S r^   )PydanticModelTransformerr`   	transform)re   r   transformers      rR   ru   z3PydanticPlugin._pydantic_model_class_maker_callback   s,    .sD4FGGrT   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)r`   debug_dataclass_transformclsinfodeclared_metaclassgetattrtyper   )re   r   info_metaclasss      rR   r{   z8PydanticPlugin._pydantic_model_metaclass_marker_callback   sn     7 	F8NNNNNN>&(BDII 	@;?N888	@ 	@rT   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^   )rq   r>   )rm   args     rR   ro   z:PydanticPlugin._pydantic_field_callback.<locals>.<genexpr>   s,      HHC:c;77HHHHHHrT   c              3      K   | ]}V  d S r^    )rm   _default_any_types     rR   ro   z:PydanticPlugin._pydantic_field_callback.<locals>.<genexpr>   s$      -M-M1.>-M-M-M-M-M-MrT   )default_return_typecallee_arg_namesr   +error_default_and_default_factory_specifiedapicontext	arg_typesrq   r   r:   r   itemsr7   ret_typer   allrL   )
re   r   default_argsdefault_factory_argsdefault_typedefault_argdefault_factory_typer   r   r   s
            @rR   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rT   )__name__
__module____qualname__r+   rd   strrx   r   r   r-   r}   r   r/   r   r   r   r1   r   r   r   ru   r{   r.   r   __classcell__)rf   s   @rR   rY   rY   j   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 rT   rY   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 )r_   )init_forbid_extra
init_typedwarn_required_dynamic_aliaseswarn_untyped_fieldsr   r   r   r   r   r   r\   rH   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toolrF   Fz/Configuration value must be a boolean for key: )fallback)config_file
parse_tomlget	__slots__rq   bool
ValueErrorsetattrr   read
getbooleanCONFIGFILE_KEY)re   r\   toml_configconfigkeysettingr`   s          rR   rd   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++++, ,rT   c                 *      fd j         D             S )Nc                 2    i | ]}|t          |          S r   )r   )rm   r   re   s     rR   
<dictcomp>z0PydanticPluginConfig.to_data.<locals>.<dictcomp>  s%    BBBCWT3''BBBrT   )r   re   s   `rR   ra   zPydanticPluginConfig.to_data   s    BBBB4>BBBBrT   )r   r   r   r   r   __annotations__r+   rd   r   r   r   ra   r   rT   rR   r_   r_      s         I #''''####, ,D , , , ,&Cc3h C C C C C CrT   r_   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   rq   r=   itemr7   r   r8   rf   r   error_unexpected_behaviorr   r   r   metadatar   METADATA_KEYerror_from_ormget_name)r   ctx_type
model_typedetailpydantic_metadatar   s         rR   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""rT   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   r`   rH   Nc                 "    || _         || _        d S r^   )_ctxr`   )re   r   r`   s      rR   rd   z!PydanticModelTransformer.__init__'  s    	*rT   c                 v   | j         }| j         j        j        }|                                  |                                 }|                     |          }|D ]9}||j                 j        %|j        j	        s|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
        Nc              3   F   K   | ]}t          |          t          k    V  d S r^   )rj   BASESETTINGS_FULLNAMErl   s     rR   ro   z5PydanticModelTransformer.transform.<locals>.<genexpr>?  s0      ``$,t,,0EE``````rT   FT)r   c                 B    i | ]}|j         |                                S r   )name	serialize)rm   fields     rR   r   z6PydanticModelTransformer.transform.<locals>.<dictcomp>D  s&    IIIuz5??#4#4IIIrT   )fieldsr   )r   r   r   adjust_validator_signaturescollect_configcollect_fieldsr   r   r   final_iterationdeferrs   rt   add_initializeradd_construct_method
set_frozenr   r   set_values_dictr   r   )re   r   r   r   r   r   is_settingss          rR   r   z"PydanticModelTransformer.transform+  sE    iy}!((***$$&&$$V,, 	$ 	$EEJ$,w. $GMMOOO``RVRZ[^\^[^R_`````VV[999!!&)))v'<'E'^Z^I^___II&III,,..'
 '
l###rT   c                 Z   | j         j        j        j                                        D ]\  }}t          |j        t                    rb|j        j        d         }t          |t                    r;t          |j
        t                    r!|j
        j        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#pydantic.class_validators.validatorTN)r   r   r   namesr   rq   rr   r   original_decoratorsr   calleer    rg   funcis_class)re   r   rw   	first_decs       rR   r   z4PydanticModelTransformer.adjust_validator_signaturesH  s     +17799 	2 	2ID##(I.. 2H8;	y(332"9#3X>>2 "(15ZZZ-1CHM*	2 	2rT   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bodyrq   r   r   r   updateget_config_updatehas_alias_generatorr   r`   r   error_required_dynamic_aliasesr   r   rt   r   r   add_plugin_dependencyr5   rj   r   
setdefault)	re   r   r   r   stmtsubstmtr   r   values	            rR   r   z'PydanticModelTransformer.collect_configZ  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!!$..../rT   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   )rm   ar   s     rR   ro   z:PydanticModelTransformer.collect_fields.<locals>.<genexpr>  s)      HHa4HHrT   )+r   r   setr  r	  rq   r   lvaluesr    rD   r   
new_syntaxr`   r   error_untyped_fieldsr   r   r   r   rr   r"   r*   is_classvarget_is_requiredget_alias_infor   r   r  appendr  r  r  addcopyrt   r   r   r  r5   rj   r   deserializeremove)re   r  r   r   r   known_fieldsr  lhsrw   rr   r  r  r  
all_fieldsr   superclass_fieldsdatar   r   s                     @rR   r   z'PydanticModelTransformer.collect_fieldsy  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rT   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kwargsNrd   )r   r`   r   r   r   r  get_field_argumentsshould_init_forbid_extrar*   r%  r   r6   r<   explicitr   r   r   r   
add_methodr9   )
re   r   r   r   r   r1  r3  r2  init_argumentsvars
             rR   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/rT   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g |          }
t          ||	g |          }t          t          |          |j
        j        j        |<   t%          |
t&                    r|
}nt'          |
          }t)          |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_setNTFr0  z.object_PydanticBaseModelrK   r   	construct)return_type	self_typetvar_defis_classmethod)r   r   
named_typeBUILTINS_NAMEr?   r9   r   r*   r   r5  r   rg   rE   r)   r&   r   r   r   rq   r>   r8  )re   r   r   set_stroptional_set_strfields_set_argumentconstruct_argumentsobj_typeself_tvar_nametvar_fullnametvdself_tvar_exprr@  s                rR   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.?BII$^]BQQ-<T>-R-R>* c;'' 	)II#C((I!	
 	
 	
 	
 	
 	
rT   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)r3  rK   )r   r   r   r   r   r   rr   rq   r*   is_propertyr"   r   r   r   r   	TypeErrorreprrf   r   to_varrj   r   	_fullnamer&   r   )
re   r   r   r   r   r   sym_noder:  var_strr   s
             rR   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.FalserY  r   )r  rq   r    r   r   rvaluer$   r  r   error_invalid_config_valuer   r   r  rg   )re   r  r+  rX  r  s        rR   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trT   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)rZ  rq   r'   r@   r   r   r   r   type_has_implicit_defaultr   r  r#   rg   r   zipr   	arg_namesrf   r   )r   r  r+  expr
value_typer   r   s          rR   r#  z(PydanticModelTransformer.get_is_requiredE  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$---rT   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^   )rq   r9   r6   )rm   r   s     rR   ro   zEPydanticModelTransformer.type_has_implicit_default.<locals>.<genexpr>i  sL       0
 0
HLJtX&&C*T7*C*C0
 0
 0
 0
 0
 0
rT   F)rq   r6   r?   rs   r   )rb  s    rR   r]  z2PydanticModelTransformer.type_has_implicit_default_  si     eW%% 	4eY'' 	C 0
 0
PUP[0
 0
 0
 -
 -
 	 4urT   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)rZ  rq   r'   r   r  r#   rg   r   	enumerater_  r   r$   r  )r  r`  iarg_namer   s        rR   r$  z'PydanticModelTransformer.get_alias_infop  s     {dH%% 	; tX&&	+5dk7+K+K	PTP[PdhvPvPv ;$T^44 	" 	"KAx7"")A,C#w'' "y%''''!zz{rT   r1  r2  r3  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 ))r1  force_optionalr3  )r  to_argument)rm   r   r2  r   r1  r3  s     rR   
<listcomp>z@PydanticModelTransformer.get_field_arguments.<locals>.<listcomp>  sU     
 
 

 #("9
d%@R^ghh
 
 
rT   )r   r   r   )re   r   r1  r2  r3  	argumentsr   s     ``` @rR   r5  z,PydanticModelTransformer.get_field_arguments  sS     y}!
 
 
 
 
 
 

 
 
	
 rT   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  rX  r`   r   )re   r   r   s      rR   r6  z1PydanticModelTransformer.should_init_forbid_extra  sS     4 	,,VT&:T5U5UVV u 	4!33rT   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      rR   rp  z1PydanticModelTransformer.is_dynamic_alias_present  sZ      	 	E& tt 	     ;&44 'urT   )rH   N)rH   r  )"r   r   r   r   r	   r   r   r-   r_   rd   r   r   r   r   r   r   r   r   r   r   r   r  staticmethodr   r    r#  r;   r]  r
   r$  r   r5  r6  rp  r   rT   rR   r   r     s        ' ' '3s8   +O +<P +UY + + + +
 
 
 
:2 2 2 2$   >R+< RFZA[ R R R RhDd+?&@ DJ[ Djn Dsw D D D D,#
40D+E #
$ #
 #
 #
 #
J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    \  rT   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  )re   r   r  r  r  r  r  s          rR   rd   zPydanticModelField.__init__  s4     	&
!2	rT   r   r3  rH   c                 p    | j         }|r| j        | j        }t          ||| j                  j                  S r^   )r   r  r*   r   )re   r   r3  r   s       rR   rR  zPydanticModelField.to_var  s8    y 	/:D4di-...rT   r1  rk  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<   r7  r   rR  r  r   r   )re   r   r1  rk  r3  rx  s         rR   rl  zPydanticModelField.to_argument  sz     	:T$)_)5"49o2OO%i&899O[[y11+"0W8HWi	
 
 
 	
rT   c                     | j         S r^   )__dict__r   s    rR   r   zPydanticModelField.serialize  s
    }rT   r.  c                      | di |S )Nr   r   )r   r   r.  s      rR   r(  zPydanticModelField.deserialize  s    s{{T{{rT   N)r   r   r   r   r   r   rN   rd   r(   r*   rR  r   rl  r   r   classmethodr(  r   rT   rR   r  r    s       &*3;C=UYadnq   /8 / / / / / /

 

 

t 

X\ 

ai 

 

 

 

8     x x <P    [  rT   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  NrX  r   r   r   r   r  c                 Z    || _         || _        || _        || _        || _        || _        d S r^   )rX  r   r   r   r   r  )re   rX  r   r   r   r   r  s          rR   rd   zModelConfigData.__init__  s8     ), .L+#6   rT   rH   c                 H    d | j                                         D             S )Nc                     i | ]
\  }}|||S r^   r   )rm   kvs      rR   r   z3ModelConfigData.set_values_dict.<locals>.<dictcomp>  s    HHHA!-1---rT   )r|  r   r   s    rR   r   zModelConfigData.set_values_dict  s$    HH!4!4!6!6HHHHrT   r   c                     |d S |                                                                 D ]\  }}t          | ||           d S r^   )r   r   r   )re   r   r  r  s       rR   r
  zModelConfigData.update  sV    >F**,,2244 	  	 DAqD!Q	  	 rT   r   r  c                 L    t          | |          t          | ||           d S d S r^   )r   r   )re   r   r  s      rR   r  zModelConfigData.setdefault  s2    4%D#u%%%%% &%rT   )NNNNNN)r   r   r   r   r   rd   r   r   r   r   r
  r  r   rT   rR   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 &# &$ & & & & & &rT   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      rR   r   r     s,    HH::::G)HTTTTTrT   r   c                 H    |                     d|  d|t                     d S )NzInvalid value for "Config.r  r  )r  ERROR_CONFIG)r   r   r   s      rR   r[  r[    s,    HH1$1117HNNNNNrT   c                 @    |                      d|t                     d S )Nz#Required dynamic aliases disallowedr  )r  ERROR_ALIASr   r   s     rR   r  r    s!    HH2G+HNNNNNrT   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        rR   r   r     sO     DDWVWWWL\T\\\\LHH\7)9H:::::rT   c                 @    |                      d|t                     d S )NzUntyped fields disallowedr  )r  ERROR_UNTYPEDr  s     rR   r!  r!    s!    HH('HFFFFFrT   c                 @    |                      d|t                     d S )Nz>Field default and default_factory cannot be specified togetherr  )r  ERROR_FIELD_DEFAULTSr  s     rR   r   r   !  s"    HHMw]qHrrrrrrT   Fr   r?  r@  rA  rB  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	.functionrK   Tr~  )*r   r   r   plugin_generatedrq   rr   r   r  r	  r)  rA   r   r*   r=   make_normalizedr   rx  r%  r   rw  rz  r   rC  rD  r7   	variablesr   r!   r4   r   r  rj   rS  r  rB   is_decoratedrB  r   r    r&   r   defn)r   r   r   r?  r@  rA  rB  r  r   rw   firstr   r_  	arg_kindsr   function_type	signaturer  r_namer  decs                        rR   r8  r8  %  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$$$$$rT   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.
    )rg   callabler  fns     rR   rj   rj   x  s)     
B|| rttIrT   c                 F    | j         }t          |          r
 |            S |S r  )r   r  r  s     rR   r   r     s)     
B|| rttIrT   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   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        rR   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)yr  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@   mypy.typevarsrA   	mypy.utilrB   mypy.versionrC   mypy_versionpydantic.utilsrD   rE   r  r   r   rk   r   rz   r   r   r   rN   rS   r   rD  rZ   rY   r_   r   r   r  r  r  r  r  r  r  r  r   r[  r  r   r!  r   r   r8  rj   r   r   r   rT   rR   <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 !'. < 9 (5 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 # # # #2[ [ [ [ [ [ [ [|" " " " " " " "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