o
    ¨Ýj·û  ã                   @  sf  d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
 ddlZddlmZ ddlmZ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/m0Z0m1Z1m2Z2m3Z3 dd
l4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZC ddlDmEZE ddlFmGZG ddlHmIZI ddlJmKZK ddlmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZU ddlVmWZW ddlXmYZY ddlZm[Z\ ddl]m^Z^ ddl_m`Z` dZadZbdZcdZddZedZfdZgd Zhd!Zid"Zjd#Zkd$Zlh d%£Zmemd&h Zne`e\ƒZod'Zpd(Z[d|d-d.„ZqG d/d0„ d0e;ƒZrG d1d2„ d2ƒZsd}d6d7„ZtG d8d9„ d9ƒZuG d:d;„ d;ƒZvG d<d=„ d=ƒZwG d>d?„ d?eIƒZxG d@dA„ dAƒZyd~dEdF„ZzedGdHdIƒZ{edJdKdIƒZ|edLdMdIƒZ}edNdOdIƒZ~edPdQdIƒZedPdRdIƒZ€edPdSdIƒZ�ddZd[„Z‚d€d^d_„Zƒd�d`da„Z„d‚ddde„Z…d�dfdg„Z†dƒdhdi„Z‡			jd„d…dvdw„Zˆd†dzd{„Z‰dS )‡z^This module includes classes and functions designed specifically for use with the mypy plugin.é    )ÚannotationsN)ÚCallableÚIterator)ÚConfigParser)ÚAny)Ú	ErrorCode)Úexpand_typeÚexpand_type_by_instance)!Ú	ARG_NAMEDÚARG_NAMED_OPTÚARG_OPTÚARG_POSÚ	ARG_STAR2ÚGDEFÚ	INVARIANTÚMDEFÚArgumentÚAssignmentStmtÚBlockÚCallExprÚClassDefÚContextÚ	DecoratorÚDictExprÚEllipsisExprÚ
ExpressionÚFuncDefÚIfStmtÚJsonDictÚ
MemberExprÚNameExprÚPassStmtÚPlaceholderNodeÚRefExprÚ	StatementÚStrExprÚSymbolTableNodeÚTempNodeÚ	TypeAliasÚTypeInfoÚVar)ÚOptions)ÚCheckerPluginInterfaceÚClassDefContextÚDynamicClassDefContextÚMethodContextÚPluginÚReportConfigContextÚSemanticAnalyzerPluginInterface)Údeserialize_and_fixup_type)Úset_callable_name)Úhas_placeholder)Úmake_wildcard_trigger)Ústate)ÚTypeTranslator)Úmap_type_from_supertype)
ÚAnyTypeÚCallableTypeÚInstanceÚNoneTypeÚTypeÚ	TypeOfAnyÚTypeTypeÚTypeVarTypeÚ	UnionTypeÚget_proper_type)Úfill_typevars)Úget_unique_redefinition_name)Ú__version__)Ú_fields)Úparse_mypy_versionúpydantic-mypyzpydantic-mypy-metadatazpydantic-mypy-metadata-tagzpydantic.main.BaseModelzpydantic.main.create_modelz#pydantic_settings.main.BaseSettingszpydantic.root_model.RootModelz5pydantic._internal._model_construction.ModelMetaclassz'pydantic.root_model._RootModelMetaclasszpydantic.fields.Fieldzpydantic.dataclasses.dataclassú.pydantic.functional_validators.model_validator>   z.pydantic.functional_validators.field_validatorz*pydantic.functional_serializers.serializerz3pydantic.deprecated.class_validators.root_validatorz.pydantic.deprecated.class_validators.validatorú0pydantic.functional_serializers.model_serializerrJ   rK   Úbuiltinsé   ÚversionÚstrÚreturnútype[Plugin]c                 C  s   t S )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)rN   © rS   úH/var/www/html/chatgpt/venv/lib/python3.10/site-packages/pydantic/mypy.pyÚpluginu   s   rU   c                      sr   e Zd ZdZd"‡ fdd„Zd#dd„Zd#dd„Zd$dd„Zd%dd„Zd&dd„Z	d'dd„Z
d'dd„Zd(d d!„Z‡  ZS ))rR   zThe Pydantic mypy plugin.Úoptionsr+   rP   ÚNonec                   s&   t |ƒ| _| j ¡ | _tƒ  |¡ d S ©N)ÚPydanticPluginConfigÚplugin_configÚto_dataÚ_plugin_dataÚsuperÚ__init__)ÚselfrV   ©Ú	__class__rS   rT   r^   ‡   s   
zPydanticPlugin.__init__ÚfullnamerO   ú(Callable[[ClassDefContext], None] | Nonec                 C  s0   |   |¡}|rt|jtƒr|j t¡r| jS dS )zUpdate Pydantic model class.N)Úlookup_fully_qualifiedÚ
isinstanceÚnoder)   Úhas_baseÚBASEMODEL_FULLNAMEÚ$_pydantic_model_class_maker_callback)r_   rb   ÚsymrS   rS   rT   Úget_base_class_hookŒ   s
   
z"PydanticPlugin.get_base_class_hookc                 C  s   |t tfv r	| jS dS )z,Update Pydantic `ModelMetaclass` definition.N)ÚMODEL_METACLASS_FULLNAMEÚROOT_MODEL_METACLASS_FULLNAMEÚ)_pydantic_model_metaclass_marker_callback©r_   rb   rS   rS   rT   Úget_metaclass_hook•   s   z!PydanticPlugin.get_metaclass_hookú&Callable[[MethodContext], Type] | Nonec                 C  s   |  d¡rtS dS )z-Adjust return type of `from_orm` method call.z	.from_ormN)ÚendswithÚfrom_attributes_callbackro   rS   rS   rT   Úget_method_hook›   s   
zPydanticPlugin.get_method_hookú/Callable[[DynamicClassDefContext], None] | Nonec                 C  s   |t kr| jS dS )zARecognize `create_model()` calls as dynamic BaseModel subclasses.N)ÚCREATE_MODEL_FULLNAMEÚ_pydantic_create_model_callbackro   rS   rS   rT   Úget_dynamic_class_hook¡   s   z%PydanticPlugin.get_dynamic_class_hookÚctxr1   údict[str, Any]c                 C  s   | j S )zjReturn all plugin config data.

        Used by mypy to determine if cache needs to be discarded.
        )r\   )r_   ry   rS   rS   rT   Úreport_config_data§   s   z!PydanticPlugin.report_config_datar-   c                 C  s"   t |j|j|j| jƒ}| ¡  d S rX   )ÚPydanticModelTransformerÚclsÚreasonÚapirZ   Ú	transform)r_   ry   ZtransformerrS   rS   rT   ri   ®   s   z3PydanticPlugin._pydantic_model_class_maker_callbackc                 C  s@   | j jrdS |jjj}|sJ dƒ‚t|jddƒrd|j_dS dS )zÓReset 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)rZ   Údebug_dataclass_transformr}   ÚinfoZdeclared_metaclassÚgetattrÚtyper�   )r_   ry   Zinfo_metaclassrS   rS   rT   rn   ²   s   
ÿz8PydanticPlugin._pydantic_model_metaclass_marker_callbackr.   c                 C  sŽ  t }t|jj|jjdd�D ]N\}}|dkr[t|tƒr[|jdur[t|jtƒr*|jj	}qt|jt
ƒr[t|jjƒ}t|tƒr@|jj	}qt|tƒr[t|jƒ}t|tƒrR dS t|tƒr[|jj	}q|j |¡}|du slt|jtƒs~|j t ¡}|du s|t|jtƒs~dS |j}t|ƒ}	t|	tƒsŒJ ‚|j |j|	|jj¡}
|j|
_|j |jtt|
ƒ¡ d|
j	v rÅ|
j	jddd�\}}tt|
ƒ|jj|jj j|< dS dS )	zFMake variables assigned from `create_model()` usable as types by mypy.T©ÚstrictÚ__base__Nú@Ú.é   )Úmaxsplit) rh   ÚzipÚcallÚ	arg_namesÚargsre   r#   rf   r)   rb   r*   rC   r…   r<   r@   ÚitemrA   r   Zlookup_fully_qualified_or_nonerD   Zbasic_new_typeinfoÚnameÚlineZmetaclass_typeZadd_symbol_table_noder&   r   Úrsplitr   ÚmodulesZ
cur_mod_idÚnames)r_   ry   Zbase_fullnameÚarg_nameZarg_exprZarg_typeZ	item_typeZbase_symZ	base_infoZbase_instancerƒ   Ú_r’   rS   rS   rT   rw   ¿   s>   






€
 þz.PydanticPlugin._pydantic_create_model_callback©rV   r+   rP   rW   )rb   rO   rP   rc   )rb   rO   rP   rq   )rb   rO   rP   ru   )ry   r1   rP   rz   )ry   r-   rP   rW   )ry   r.   rP   rW   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r^   rk   rp   rt   rx   r{   ri   rn   rw   Ú__classcell__rS   rS   r`   rT   rR   „   s    

	




rR   c                   @  sJ   e Zd ZU dZdZded< ded< ded< ded< ddd„Zddd„ZdS )rY   aÛ  A 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_typedÚwarn_required_dynamic_aliasesr‚   ÚboolrŸ   r    r¡   r‚   rV   r+   rP   rW   c              	   C  sF  |j d u rd S t|j ƒ}|d urY| di ¡ di ¡}| jD ]}| |d¡}t|tƒs1td|› �ƒ‚t| ||ƒ q| ¡ t	| jƒ }t
|ƒD ]}td|› d|| › �tjd� qEd S tƒ }| |j ¡ | jD ]}|jt|dd�}t| ||ƒ qe| t¡rŸt	| t¡ƒt	| jƒ }t
|ƒD ]}td|› d| t|¡› �tjd� q‹d S d S )	NÚtoolrI   Fz/Configuration value must be a boolean for key: z&[pydantic-mypy]: Unrecognized option: z = )Úfile)Úfallback)Úconfig_fileÚ
parse_tomlÚgetÚ	__slots__re   r¢   Ú
ValueErrorÚsetattrÚkeysÚsetÚsortedÚprintÚsysÚstderrr   ÚreadÚ
getbooleanÚCONFIGFILE_KEYÚhas_sectionrV   )r_   rV   Ztoml_configÚconfigÚkeyZsettingZunknown_keysrZ   rS   rS   rT   r^     s8   



 ÿ

þýzPydanticPluginConfig.__init__rz   c                   s   ‡ fdd„ˆ j D ƒS )z/Returns a dict of config names to their values.c                   s   i | ]}|t ˆ |ƒ“qS rS   )r„   )Ú.0r·   ©r_   rS   rT   Ú
<dictcomp>!  ó    z0PydanticPluginConfig.to_data.<locals>.<dictcomp>)r©   r¹   rS   r¹   rT   r[     ó   zPydanticPluginConfig.to_dataNr™   ©rP   rz   )rš   r›   rœ   r�   r©   Ú__annotations__r^   r[   rS   rS   rS   rT   rY   ì   s   
 

rY   ry   r/   r>   c                 C  sÒ   | j }t|tƒr|j}t|tƒrt|jtƒr|j}nt|tƒr"|}nd|› d|jj› d�}t	|| j
| jƒ | jS |j j t¡}|du rF| jS |j  t¡sO| jS | di ¡ d¡}|durft|j j| j
| jƒ | jS )z1Raise an error if from_attributes is not enabled.z
ctx.type: z
 (of type ú)Nr¶   Úfrom_attributesT)r…   re   r@   r‘   r;   Zret_typer<   ra   rš   Úerror_unexpected_behaviorr   ÚcontextZdefault_return_typeÚmetadatar¨   ÚMETADATA_KEYrg   rh   Úerror_from_attributesr’   )ry   Zctx_typeZ
model_typeÚdetailZpydantic_metadatarÀ   rS   rS   rT   rs   $  s&   

rs   c                   @  sd   e Zd ZdZd4dd„Zd5d d!„Z	"	"d6d7d$d%„Z	"d8d9d'd(„Zd:d*d+„Ze	d;d-d.„ƒZ
d<d1d2„Zd3S )=ÚPydanticModelFieldz5Based on mypy.plugins.dataclasses.DataclassAttribute.r’   rO   Úaliasú
str | NoneÚ	is_frozenr¢   Úhas_dynamic_aliasÚhas_defaultr‡   úbool | Noner“   ÚintÚcolumnr…   úType | Nonerƒ   r)   c                 C  s@   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	d S rX   )
r’   rÈ   rÊ   rË   rÌ   r‡   r“   rÏ   r…   rƒ   )r_   r’   rÈ   rÊ   rË   rÌ   r‡   r“   rÏ   r…   rƒ   rS   rS   rT   r^   A  s   
zPydanticModelField.__init__Úcurrent_infoÚtypedÚmodel_strictÚforce_optionalÚ	use_aliasr   r2   Úforce_typevars_invariantÚis_root_model_rootrP   r   c	                 C  sv   |   ||||¡}	| jdu r|n| j}
|s|
r| j||dd�}nttjƒ}t|	|d|r.td�S |s3| jr7t	d�S t
d�S )zABased on mypy.plugins.dataclasses.DataclassAttribute.to_argument.NT)Úinclude_root_type)ÚvariableÚtype_annotationZinitializerÚkind)Úto_varr‡   r   r:   r?   Úspecial_formr   r   rÌ   r   r
   )r_   rÑ   rÒ   rÓ   rÔ   rÕ   r   rÖ   r×   rÙ   r‡   rÚ   rS   rS   rT   Úto_argumentY  s    
ÿüúúzPydanticModelField.to_argumentFrØ   c                 C  s  |rt | jtƒr| j ¡ }t|_|| _| jdur‡| jjdur‡t 	|j
j¡�Z t|ƒ}t |tƒs1J ‚|rA|jD ]
}t |tƒr@t|_q6t| j| jjj|iƒ}|rvt |tƒrvt|jƒrv|jd j}	|	du rk|W  d  ƒ S t|	|ƒ}
t||
gƒ}|W  d  ƒ S 1 s‚w   Y  | jS )zABased on mypy.plugins.dataclasses.DataclassAttribute.expand_type.NÚroot)re   r…   rA   Úcopy_modifiedr   Zvariancerƒ   Ú	self_typer7   Ústrict_optional_setrV   Ústrict_optionalrD   r<   r�   r   ÚidÚis_root_modelr	   rB   )r_   rÑ   r   rÖ   rØ   Zmodified_typeZfilled_with_typevarsÚargZexpanded_typeZ	root_typeZexpanded_root_typerS   rS   rT   r   v  s2   


€ð
 ízPydanticModelField.expand_typer*   c                 C  s0   |r| j dur| j }n| j}t||  |||¡ƒS )z<Based on mypy.plugins.dataclasses.DataclassAttribute.to_var.N)rÈ   r’   r*   r   )r_   rÑ   r   rÕ   rÖ   r’   rS   rS   rT   rÜ   £  s   zPydanticModelField.to_varr   c              
   C  s8   | j sJ ‚| j| j| j| j| j| j| j| j| j  	¡ dœ	S )ú?Based on mypy.plugins.dataclasses.DataclassAttribute.serialize.)	r’   rÈ   rÊ   rË   rÌ   r‡   r“   rÏ   r…   )
r…   r’   rÈ   rÊ   rË   rÌ   r‡   r“   rÏ   Ú	serializer¹   rS   rS   rT   rè   ²  s   
÷zPydanticModelField.serializeÚdatac                 C  s,   |  ¡ }t| d¡|ƒ}| d||dœ|¤ŽS )úABased on mypy.plugins.dataclasses.DataclassAttribute.deserialize.r…   )r…   rƒ   NrS   )Úcopyr3   Úpop)r}   rƒ   ré   r   ÚtyprS   rS   rT   ÚdeserializeÁ  s   zPydanticModelField.deserializeÚsub_typerW   c                 C  sT   | j dur(t |jj¡� t| j || jƒ| _ W d  ƒ dS 1 s!w   Y  dS dS )zxExpands type vars in the context of a subtype when an attribute is inherited
        from a generic super type.
        N)r…   r7   râ   rV   rã   r9   rƒ   )r_   rï   r   rS   rS   rT   Úexpand_typevar_from_subtypeÈ  s
   
"ÿÿz.PydanticModelField.expand_typevar_from_subtypeN)r’   rO   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¢   r   r2   rÖ   r¢   r×   r¢   rP   r   )FF)
rÑ   r)   r   r2   rÖ   r¢   rØ   r¢   rP   rÐ   ©F)
rÑ   r)   r   r2   rÕ   r¢   rÖ   r¢   rP   r*   ©rP   r   )rƒ   r)   ré   r   r   r2   rP   rÇ   )rï   r)   r   r2   rP   rW   )rš   r›   rœ   r�   r^   rÞ   r   rÜ   rè   Úclassmethodrî   rð   rS   rS   rS   rT   rÇ   >  s    

!û2û
rÇ   c                   @  s0   e Zd ZdZdd„ Zeddd„ƒZdd	d
„ZdS )ÚPydanticModelClassVarz•Based on mypy.plugins.dataclasses.DataclassAttribute.

    ClassVars are ignored by subclasses.

    Attributes:
        name: the ClassVar name
    c                 C  s
   || _ d S rX   ©r’   )r_   r’   rS   rS   rT   r^   Ú  s   
zPydanticModelClassVar.__init__ré   r   rP   c                 C  s   |  ¡ }| di |¤ŽS )rê   NrS   )rë   )r}   ré   rS   rS   rT   rî   Ý  s   z!PydanticModelClassVar.deserializec                 C  s
   d| j iS )rç   r’   rõ   r¹   rS   rS   rT   rè   ã  s   ÿzPydanticModelClassVar.serializeN)ré   r   rP   rô   rò   )rš   r›   rœ   r�   r^   ró   rî   rè   rS   rS   rS   rT   rô   Ñ  s    rô   c                   @  s  e Zd ZU dZh d£Zded< d`dd„Zdadd„Zdbdd„Zdcdd„Z	dddd„Z
ded!d"„Zdfd%d&„Zdgd+d,„Zdhd4d5„Zdid:d;„Zdid<d=„Zdjd?d@„ZdkdldFdG„ZedmdHdI„ƒZedndKdL„ƒZedodNdO„ƒZedmdPdQ„ƒZ	AdkdpdXdY„ZdqdZd[„Zedrd]d^„ƒZd_S )sr|   z¸Transform the BaseModel subclass according to the plugin settings.

    Attributes:
        tracked_config_fields: A set of field configs that the plugin has to track their value.
    >   rÀ   Úpopulate_by_nameÚvalidate_by_aliasÚalias_generatorr‡   Úvalidate_by_nameÚfrozenÚextrazset[str]Útracked_config_fieldsr}   r   r~   úExpression | Statementr   r2   rZ   rY   rP   rW   c                 C  s   || _ || _|| _|| _d S rX   )Ú_clsÚ_reasonÚ_apirZ   )r_   r}   r~   r   rZ   rS   rS   rT   r^   ü  s   
z!PydanticModelTransformer.__init__r¢   c                 C  s
  | j j}|j ti ¡ t|ƒ}|  ¡ }|  ||¡\}}|du s#|du r.| jj	s,| j 
¡  dS |D ]}|jdu s<t|jƒrH| jj	sE| j 
¡   dS q0| t¡}|  ||||¡ |  ||||¡ | j|| j|jdu d� |  ¡  dd„ |D ƒd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 frozen = True
        * stores the fields, config, and if the class is settings in the mypy metadata for access by subclasses
        NFT)rú   c                 S  ó   i | ]}|j | ¡ “qS rS   ©r’   rè   ©r¸   ÚfieldrS   rS   rT   rº   1  r»   z6PydanticModelTransformer.transform.<locals>.<dictcomp>c                 S  r  rS   r  )r¸   Z	class_varrS   rS   rT   rº   2  r»   )ÚfieldsÚ
class_varsr¶   )rþ   rƒ   rÃ   Ú
setdefaultÚMETADATA_TAG_KEYrå   Úcollect_configÚcollect_fields_and_class_varsr   Úfinal_iterationÚdeferr…   r5   rg   ÚBASESETTINGS_FULLNAMEÚadd_initializerÚadd_model_construct_methodÚ
set_frozenrú   Úadjust_decorator_signaturesÚget_values_dictrÄ   )r_   rƒ   Zis_a_root_modelr¶   r  r  r  Úis_settingsrS   rS   rT   r€   	  s2   


ú
ýz"PydanticModelTransformer.transformc                   s„   | j jj ¡ D ]8}t|jtƒr?|jjd ‰ tˆ tƒr?tˆ j	t
ƒr?ˆ j	jtv r?ˆ j	jtkr:t‡ fdd„tˆ jƒD ƒƒs?d|jj_qdS )a¿  When 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`.
        r   c                 3  s6   � | ]\}}ˆ j | d kot|tƒo|jdkV  qdS )ÚmodeÚafterN)r�   re   r%   Úvalue)r¸   Úiræ   ©Z	first_decrS   rT   Ú	<genexpr>J  s
   €  ÿ
ÿzGPydanticModelTransformer.adjust_decorator_signatures.<locals>.<genexpr>TN)rþ   rƒ   r–   Úvaluesre   rf   r   Zoriginal_decoratorsr   Úcalleer    rb   Ú(IMPLICIT_CLASSMETHOD_DECORATOR_FULLNAMESÚMODEL_VALIDATOR_FULLNAMEÚanyÚ	enumerater�   ÚfuncÚis_class)r_   rj   rS   r  rT   r  8  s    ÿ
þþÿ
€ïz4PydanticModelTransformer.adjust_decorator_signaturesÚModelConfigDatac              	   C  s*  | j }tƒ }d}d}|j ¡ D ]\}}|  ||¡}|r"d}| |¡ qd}|jjD ]¡}t|t	t
fƒs3q)t|t	ƒr�|jd }	t|	tƒrG|	jdkrHq)t|jtƒrot|jj|jjdd�D ]\}
}|
du rbqY| | j|
|dd�¡ qYnNt|jtƒrŽ|jjD ]\}}t|tƒsƒqy| |  |j|¡¡ qyn.t|t
ƒr½|jdkršq)|jjD ]}t|t	ƒs¦qž|jd }	t|	tƒs±qž| |  |	j|j¡¡ qž|rÈ| j d	|¡  nd}q)|sÏ|rä|rä|jrä|jsä|jsä| jjrät| j|ƒ |jjd
d… D ]&}t |j!vrôqì| j "t#|j$ƒ¡ |j!t  d  ¡ D ]\}}| %||¡ �qqì|S )zhCollects the values of the config attributes that are used by the plugin, accounting for parent classes.FTNr   Úmodel_configr†   )Ú	lax_extraZConfigzYSpecifying config in two places is ambiguous, use either Config attribute or class kwargsr‹   r¶   )&rþ   r"  ÚkeywordsÚitemsÚget_config_updateÚupdateÚdefsÚbodyre   r   r   Úlvaluesr    r’   Úrvaluer   r�   r�   r�   r   r%   r  r   ÚfailÚhas_alias_generatorrù   rö   rZ   r¡   Úerror_required_dynamic_aliasesrƒ   ÚmrorÄ   rÃ   Úadd_plugin_dependencyr6   rb   r  )r_   r}   r¶   Zhas_config_kwargsZhas_config_from_namespacer’   ÚexprZconfig_dataÚstmtÚlhsr—   ræ   Zkey_exprZ
value_exprZsubstmtrƒ   r  rS   rS   rT   r	  S  s†   
€

ý
€




þÿþýýü
ÿz'PydanticModelTransformer.collect_configr#  rå   úJtuple[list[PydanticModelField] | None, list[PydanticModelClassVar] | None]c                 C  sÈ  | j }i }i }t|jjdd… ƒD ]p}t|jvr%t|jv r$| jjs$ dS q| j 	t
|jƒ¡ |jt d  ¡ D ]4\}}t ||| j¡}	|	 |j| j¡ |	||< |jj |¡}
|
rk|
jrkt|
jttfƒsk| j d|
j¡ q7|jt d  ¡ D ]\}}t |¡||< quqtƒ }tƒ }|  |j¡D ]I}|  |||¡}|du rœqŽ|jd }t|tƒs¨J ‚t|tƒrÇ|r»|jd	kr»t| j|ƒ qŽ|  |j¡ |||j< qŽt|tƒr×|  |j¡ |||j< qŽt!| "¡ ƒt!| "¡ ƒfS )
zACollects the fields for the model, accounting for parent classes.r‹   éÿÿÿÿ)NNr  z7BaseModel field may only be overridden by another fieldr  Nr   rß   )#rþ   Úreversedrƒ   r0  rÄ   rÃ   r  r   r  r1  r6   rb   r&  rÇ   rî   rð   r–   r¨   rf   re   r*   r"   r-  rô   r­   Ú%_get_assignment_statements_from_blockr)  Ú$collect_field_or_class_var_from_stmtr+  r    r’   Ú error_extra_fields_on_root_modelÚaddÚlistr  )r_   r#  rå   r}   Zfound_fieldsZfound_class_varsrƒ   r’   ré   r  Úsym_nodeZcurrent_field_namesZcurrent_class_vars_namesr3  Zmaybe_fieldr4  rS   rS   rT   r
  Ÿ  sR   
þ€ÿ



€z6PydanticModelTransformer.collect_fields_and_class_varsr3  r   úIterator[AssignmentStmt]c                 c  sT   � |j D ]}|js|  |¡E d H  q|jd ur&|jjs(|  |j¡E d H  d S d S d S rX   )r*  Zis_unreachabler8  Z	else_body)r_   r3  r*  rS   rS   rT   Ú,_get_assignment_statements_from_if_statementæ  s   €
€ÿzEPydanticModelTransformer._get_assignment_statements_from_if_statementÚblockr   c                 c  s>   � |j D ]}t|tƒr|V  qt|tƒr|  |¡E d H  qd S rX   )r*  re   r   r   r?  )r_   r@  r3  rS   rS   rT   r8  í  s   €


€üz>PydanticModelTransformer._get_assignment_statements_from_blockr   r  ú dict[str, PydanticModelClassVar]ú1PydanticModelField | PydanticModelClassVar | Nonec                 C  sN  | j }|jd }t|tƒrt |j¡r|jdkrdS |jsKt|jt	ƒr<t|jj
t	ƒr<t|jj
j
tƒr<|jj
j
jtv r<dS |j|v rCdS t| j|ƒ dS |jd }t|tƒsWdS t |j¡rb|jdkrddS |jj |j¡}|du rrdS |j}t|tƒr|dS t|tƒrŠ| j d|¡ dS t|tƒs‘dS |jr™t|jƒS t|jƒ}t|tƒr°|jjdkr°| j d|¡ |  |¡}	|  |¡}
|jdu rá|jrá|jrá| jj |jdd�}|rÔ||_n| j d	|¡ t!t"j#ƒ|_|jrë|	rët|jƒS |  $|¡\}}|�r|j%�s|j&�s| j'j(�rt)| j|ƒ |  *|¡}|  +||j|¡}t,|j||	|
|||j-|j.||jd
�
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`.
        r   r#  NzFType aliases inside BaseModel definitions are not supported at runtimezdataclasses.InitVarz%InitVar is not supported in BaseModelT)Úis_finalzGNeed type argument for Final[...] with non-literal default in BaseModel)
r’   rË   rÌ   r‡   rÈ   rÊ   r“   rÏ   r…   rƒ   )/rþ   r+  re   r    rG   Zis_valid_field_namer’   Z
new_syntaxr,  r   r  rb   ÚDECORATOR_FULLNAMESÚerror_untyped_fieldsr   rƒ   r–   r¨   rf   r"   r(   r-  r*   Zis_classvarrô   rC   r…   r<   Úget_has_defaultÚ
get_strictrC  Zis_inferredZanalyze_simple_literal_typer:   r?   Z
from_errorÚget_alias_inforù   rö   rZ   r¡   r/  Úis_field_frozenÚ_infer_dataclass_attr_init_typerÇ   r“   rÏ   )r_   r3  r#  r  r}   r4  rj   rf   Z	node_typerÌ   r‡   rí   rÈ   rË   rÊ   Z	init_typerS   rS   rT   r9  ô  s¢   
 
ÿþý




þ


þ

þ

ÿþþý
öz=PydanticModelTransformer.collect_field_or_class_var_from_stmtrj   r&   r’   rO   rÂ   r   rÐ   c           	      C  sä   |j }|jr|S t|j ƒ}t|tƒs|S |j  d¡}|rpt|jtƒrc|j  d¡}|s,J ‚|j r:tt	|j |j |ƒƒ}nt
tjƒS t|tƒrT|jtttgkrTt|jd |ƒS | j d|j j› d�|¡ |S | j d|j j› d�|¡ |S )zvInfer __init__ argument type for an attribute.

        In particular, possibly use the signature of __set__.
        Ú__set__rM   z(Unsupported signature for "__set__" in "ú"zUnsupported "__set__" in ")r…   ZimplicitrC   re   r<   r¨   rf   r   Zget_containing_type_infor9   r:   r?   Zunannotatedr;   Ú	arg_kindsr   r	   Ú	arg_typesr   r-  r’   )	r_   rj   r’   rÂ   ÚdefaultÚtÚsetterZ
super_infoZsetter_typerS   rS   rT   rJ  }  s0   


ýþz8PydanticModelTransformer._infer_dataclass_attr_init_typer  úlist[PydanticModelField]r¶   r  c              
   C  sº  d| j jjv r| j jjd js| j jtkrdS | jj}t|j	ƒ}|j
p%|j o+|jdu}t|jo3|j
 ƒ}| j|||||||dd�}	|r¸| j t¡j}
t|
tƒsRJ ‚d|
jv r¸|
jd j}t|tƒsdJ ‚|dur¸|jdur¸|j}t|tƒswJ ‚t|jƒD ];\}}|du sŽ| d¡sŽ| d¡s�q|| j |j| ¡}|dur¨|dv r¨| ttj ƒ¡}t!||ƒ}|	 "t#||dt$ƒ¡ q||  %||¡sÏt!d	ƒ}|	 "t#|t&tj'ƒdt(ƒ¡ t)| j| j d|	t*ƒ d
� 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.
        r^   NFT)rÒ   rÓ   Úrequires_dynamic_aliasesrÕ   r  rå   rÖ   Ú__r˜   )Z_cli_settings_sourceZ_build_sourcesÚkwargs)r�   Úreturn_type)+rþ   rƒ   r–   Úplugin_generatedrb   ÚROOT_MODEL_FULLNAMErZ   r    r¢   r‡   rù   rö   r÷   r.  Úget_field_argumentsr   rd   r  rf   re   r)   r   r…   r;   r  r�   Ú
startswithZ	anal_typerN  ÚacceptÚChangeExplicitTypeOfAnyr?   Zfrom_omitted_genericsr*   Úappendr   r   Úshould_init_forbid_extrar:   rÝ   r   Ú
add_methodr=   )r_   r  r¶   r  rå   rÒ   rÓ   rÕ   rS  r�   Zbase_settings_nodeZbase_settings_init_nodeÚ	func_typeZarg_idxr—   Zanalyzed_variable_typerÙ   ÚvarrS   rS   rT   r  £  sT   ÿ
ø
ÿ
z(PydanticModelTransformer.add_initializerc           
   
   C  sþ   | j  t› d�| j  t› d�¡g¡}t|tƒ gƒ}ttd|ƒ|dtƒ}t 	| j j
j¡� | j|dt|jƒdd||d�}W d  ƒ n1 sEw   Y  |  ||¡satdƒ}	| t|	ttjƒdtƒ¡ |rh||g n|g| }t| j | jd	|t| jjƒdd
� dS )zäAdds a fully typed `model_construct` classmethod to the class.

        Similar to the fields-aware __init__ method, but always uses the field names (not aliases),
        and does not treat settings fields as optional.
        z.setz.strZ_fields_setNTF)rÒ   rÓ   rS  rÕ   r  rå   rU  Zmodel_construct)r�   rV  Úis_classmethod)r   Ú
named_typeÚBUILTINS_NAMErB   r=   r   r*   r   r7   râ   rV   rã   rY  r¢   r‡   r^  r]  r:   r?   rÝ   r   r_  rþ   rD   rƒ   )
r_   r  r¶   r  rå   Zset_strZoptional_set_strZfields_set_argumentr�   ra  rS   rS   rT   r  â  s4   $ùÿ


úz3PydanticModelTransformer.add_model_construct_methodrú   c                 C  s¨   | j j}|D ]K}|j |j¡}|dur1|j}t|tƒr"|p|j|_	qt|t
ƒr0| jjs0| j ¡  q|j||dd�}||_||_	|jd |j |_tt|ƒ|j|j< qd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.
        NF)rÕ   rŠ   )rþ   rƒ   r–   r¨   r’   rf   re   r*   rÊ   Zis_propertyr"   r   r  r  rÜ   rb   Ú	_fullnamer&   r   )r_   r  r   rú   rƒ   r  r=  ra  rS   rS   rT   r  
  s    

€ïz#PydanticModelTransformer.set_frozenFræ   r   r$  úModelConfigData | Nonec                 C  sÎ   || j vrdS |dkr1t|tƒr|jdk}nt|tƒr!|jdk}n|s*t|| j|ƒ dS t|d�S |dkrHd}t|t	ƒrC|j
dkrCd}t|d	�S t|t	ƒr^|j
d
v r^tdi ||j
dki¤ŽS t|| j|ƒ dS )zÐDetermines 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û   Zforbid)Úforbid_extrarø   Túbuiltins.NoneF)r.  )úbuiltins.Trueúbuiltins.Falseri  rS   )rü   re   r%   r  r   r’   Úerror_invalid_config_valuer   r"  r    rb   )r_   r’   ræ   r$  rg  r.  rS   rS   rT   r'  #  s(   


	

z*PydanticModelTransformer.get_config_updatec                 C  s¢   | j }t|tƒr
dS t|tƒrKt|jtƒrK|jjtkrKt|j	|j
dd�D ]$\}}|du s0|dkr7|jtu  S |dkrHt|tƒoD|jdk   S q$dS t|tƒ S )zUReturns a boolean indicating whether the field defined in `stmt` is a required field.FTr†   NrO  Údefault_factoryrh  )r,  re   r'   r   r  r#   rb   ÚFIELD_FULLNAMEr�   r�   r�   ra   r   r    ©r3  r2  ræ   r’   rS   rS   rT   rF  F  s   
"ÿz(PydanticModelTransformer.get_has_defaultrÍ   c                 C  s€   | j }t|tƒr>t|jtƒr>|jjtkr>t|j|j	dd�D ] \}}|dkr&qt|t
ƒr;|jdkr3 dS |jdkr; dS  dS dS )zCReturns the `strict` value of a field if defined, otherwise `None`.Tr†   r‡   ri  rj  FN)r,  re   r   r  r#   rb   rm  r�   r�   r�   r    rn  rS   rS   rT   rG  \  s   "


z#PydanticModelTransformer.get_strictútuple[str | None, bool]c                 C  s’   | j }t|tƒr
dS t|tƒrt|jtƒr|jjtksdS d|jv r,|j	|j 
d¡ }nd|jv r;|j	|j 
d¡ }ndS t|tƒrG|jdf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.
        )NFZvalidation_aliasrÈ   F)NT)r,  re   r'   r   r  r#   rb   rm  r�   r�   Úindexr%   r  )r3  r2  ræ   rS   rS   rT   rH  l  s"   
ÿ
ÿ



z'PydanticModelTransformer.get_alias_infoc                 C  s|   | 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ƒo8|jdk  S q"dS )al  Returns 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_name> = Field(frozen=True)`
        sense; this does not determine whether the field is frozen because the entire model is frozen; that is
        handled separately.
        Frú   ri  )r,  re   r'   r   r  r#   rb   rm  r  r�   r�   r    )r3  r2  r  r—   ræ   rS   rS   rT   rI  Š  s   
ÿ
ÿ
þz(PydanticModelTransformer.is_field_frozenrÒ   rÓ   rÕ   rS  rÖ   úlist[Argument]c	           
   	     s.   ˆj j‰‡ ‡‡‡‡‡‡‡‡f	dd„|D ƒ}	|	S )zÈHelper function used during the construction of the `__init__` and `model_construct` method signatures.

        Returns a list of mypy Argument instances for use in the generated signatures.
        c                   s@   g | ]}ˆr	|j s|jˆˆˆˆpˆˆˆjˆ ˆo|jd kd�‘qS )rß   )rÒ   rÓ   rÔ   rÕ   r   rÖ   r×   )rË   rÞ   r   r’   r  ©	rÖ   rƒ   rå   r  rÓ   rS  r_   rÒ   rÕ   rS   rT   Ú
<listcomp>³  s"    ôôøÿz@PydanticModelTransformer.get_field_arguments.<locals>.<listcomp>)rþ   rƒ   )
r_   r  rÒ   rÓ   rÕ   rS  r  rå   rÖ   Ú	argumentsrS   rr  rT   rY  £  s
   õz,PydanticModelTransformer.get_field_argumentsc                 C  s4   |j s|js|  |t|jƒ¡rdS |jrdS | 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ù   rö   Úis_dynamic_alias_presentr¢   r.  rg  rZ   rŸ   )r_   r  r¶   rS   rS   rT   r^  Ã  s   z1PydanticModelTransformer.should_init_forbid_extrar.  c                 C  s8   | D ]}|j r
 dS q|r| D ]
}|jdu r dS q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  rS   rS   rT   ru  Ð  s   ÿ
ÿz1PydanticModelTransformer.is_dynamic_alias_presentN)
r}   r   r~   rý   r   r2   rZ   rY   rP   rW   )rP   r¢   )rP   rW   )rP   r"  )r#  r"  rå   r¢   rP   r5  )r3  r   rP   r>  )r@  r   rP   r>  )r3  r   r#  r"  r  rA  rP   rB  )rj   r&   r’   rO   rÂ   r   rP   rÐ   )
r  rR  r¶   r"  r  r¢   rå   r¢   rP   rW   )r  rR  r   r2   rú   r¢   rP   rW   rñ   )r’   rO   ræ   r   r$  r¢   rP   rf  )r3  r   rP   r¢   )r3  r   rP   rÍ   )r3  r   rP   ro  )r  rR  rÒ   r¢   rÓ   r¢   rÕ   r¢   rS  r¢   r  r¢   rå   r¢   rÖ   r¢   rP   rq  )r  rR  r¶   r"  rP   r¢   )r  rR  r.  r¢   rP   r¢   )rš   r›   rœ   r�   rü   r¾   r^   r€   r  r	  r
  r?  r8  r9  rJ  r  r  r  r'  ÚstaticmethodrF  rG  rH  rI  rY  r^  ru  rS   rS   rS   rT   r|   ê  s<   
 


/

L
G

 


&
?
(#!÷
 r|   c                      s,   e Zd ZdZd‡ fdd„Zddd„Z‡  ZS )r\  z<A type translator used to change type of Any's, if explicit.Útype_of_anyrÎ   rP   rW   c                   s   || _ tƒ  ¡  d S rX   )Ú_type_of_anyr]   r^   )r_   rw  r`   rS   rT   r^   â  s   z ChangeExplicitTypeOfAny.__init__rP  r:   r>   c                 C  s   |j tjkr|j| jd�S |S )N)rw  )rw  r?   Zexplicitrà   rx  )r_   rP  rS   rS   rT   Ú	visit_anyæ  s   z!ChangeExplicitTypeOfAny.visit_any)rw  rÎ   rP   rW   )rP  r:   rP   r>   )rš   r›   rœ   r�   r^   ry  rž   rS   rS   r`   rT   r\  ß  s    r\  c                   @  sJ   e Zd ZdZ								dddd„Zddd„Zd dd„Zd!dd„ZdS )"r"  z(Pydantic mypy plugin model config class.Nrg  rÍ   rú   rÀ   rö   r÷   rù   r.  r‡   c	           	      C  s4   || _ || _|| _|| _|| _|| _|| _|| _d S rX   )rg  rú   rÀ   rö   r÷   rù   r.  r‡   )	r_   rg  rú   rÀ   rö   r÷   rù   r.  r‡   rS   rS   rT   r^   ð  s   
zModelConfigData.__init__rP   rz   c                 C  s   dd„ | j  ¡ D ƒS )z†Returns a dict of Pydantic model config names to their values.

        It includes the config if config value is not `None`.
        c                 S  s   i | ]\}}|d ur||“qS rX   rS   )r¸   ÚkÚvrS   rS   rT   rº   	  s    z3ModelConfigData.get_values_dict.<locals>.<dictcomp>)Ú__dict__r&  r¹   rS   rS   rT   r    ó   zModelConfigData.get_values_dictr¶   rf  rW   c                 C  s2   |du rdS |  ¡  ¡ D ]
\}}t| ||ƒ qdS )z$Update Pydantic model config values.N)r  r&  r«   )r_   r¶   rz  r{  rS   rS   rT   r(    s
   ÿzModelConfigData.updater·   rO   r  r   c                 C  s"   t | |ƒdu rt| ||ƒ dS dS )zFSet default value for Pydantic model config if config value is `None`.N)r„   r«   )r_   r·   r  rS   rS   rT   r    s   ÿzModelConfigData.setdefault)NNNNNNNN)rg  rÍ   rú   rÍ   rÀ   rÍ   rö   rÍ   r÷   rÍ   rù   rÍ   r.  rÍ   r‡   rÍ   r½   )r¶   rf  rP   rW   )r·   rO   r  r   rP   rW   )rš   r›   rœ   r�   r^   r  r(  r  rS   rS   rS   rT   r"  í  s    ÷

r"  rƒ   r)   r¢   c                 C  s
   |   t¡S )zXReturn whether the type info is a root model subclass (or the `RootModel` class itself).)rg   rX  )rƒ   rS   rS   rT   rå     s   
rå   zpydantic-ormzInvalid from_attributes callZPydanticzpydantic-configzInvalid config valuezpydantic-aliaszDynamic alias disallowedzpydantic-unexpectedzUnexpected behaviorzpydantic-fieldzUntyped field disallowedzInvalid Field defaultsz!Extra field on RootModel subclassÚ
model_namer   r,   rÂ   r   rW   c                 C  ó   |j d| › d�|td� dS )zCEmits an error when the model does not have `from_attributes=True`.rL  z$" does not have from_attributes=True©ÚcodeN)r-  Ú	ERROR_ORM)r~  r   rÂ   rS   rS   rT   rÅ   &  ó   rÅ   r’   r2   c                 C  r  )z0Emits an error when the config value is invalid.zInvalid value for "Config.rL  r€  N)r-  ÚERROR_CONFIG)r’   r   rÂ   rS   rS   rT   rk  +  rƒ  rk  c                 C  ó   | j d|td� dS )znEmits required dynamic aliases error.

    This will be called when `warn_required_dynamic_aliases=True`.
    z#Required dynamic aliases disallowedr€  N)r-  ÚERROR_ALIAS©r   rÂ   rS   rS   rT   r/  0  r}  r/  rÆ   ú8CheckerPluginInterface | SemanticAnalyzerPluginInterfacec                 C  s4   d}d| › d�}|d|› d�7 }|j ||td� dS )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!r€  N)r-  ÚERROR_UNEXPECTED)rÆ   r   rÂ   ÚlinkZfull_messagerS   rS   rT   rÁ   8  s   rÁ   c                 C  r…  )z;Emits an error when there is an untyped field in the model.zUntyped fields disallowedr€  N)r-  ÚERROR_UNTYPEDr‡  rS   rS   rT   rE  C  r¼   rE  c                 C  r…  )z]Emits an error when there is more than just a root field defined for a subclass of RootModel.z2Only `root` is allowed as a field of a `RootModel`r€  N)r-  ÚERROR_EXTRA_FIELD_ROOT_MODELr‡  rS   rS   rT   r:  H  r¼   r:  Fú8SemanticAnalyzerPluginInterface | CheckerPluginInterfacer}   r   r�   rq  rV  rá   rÐ   Útvar_defúTypeVarType | Nonerb  c                 C  s  |j }||jv r|j| }	|	jrt|	jtƒr|jj |	j¡ t| t	ƒr)|  
d¡}
n|  dg ¡}
|rE|p8tt|ƒƒ}ttdƒ|dtdƒg}n|pJt|ƒ}ttdƒ|dtƒg}|| }g g g }}}|D ]}|jslJ dƒ‚| |j¡ | |jj¡ | |j¡ qct|||||
|r‹|gndd�}t||ttƒ gƒƒ}||_ t||ƒ|_||_|jd | |_|j|_||jv rÄt||jƒ}|j| |j|< |rìd|_ t||jƒ}||_ |j|_d|_!t"|t#d	ƒg|ƒ}|j|_t$t%|ƒ}	nt$t%|ƒ}	d|	_|	|j|< |j&jj |¡ dS )
zhVery closely related to `mypy.plugins.common.add_method_to_class`, with a few pydantic-specific changes.zbuiltins.functionrþ   NTZ__pydantic_self__z"All arguments must be fully typed.)Ú	variablesrŠ   ró   )'rƒ   r–   rW  re   rf   r   r)  r*  Úremover2   rc  Znamed_generic_typer@   rD   r   r*   r   rÚ   r]  rÙ   r’   rÛ   r;   r   r!   r4   r…   r!  rb   re  r“   rE   Zis_decoratedrb  r   r    r&   r   Zdefn)r   r}   r’   r�   rV  rá   r�  rb  rƒ   rj   Zfunction_typeÚfirstrN  r�   rM  ræ   Ú	signaturer   Zr_namer{  ÚdecrS   rS   rT   r_  M  sZ   


ÿ


r_  r¦   údict[str, Any] | Nonec                 C  s’   |   d¡sdS tjdkrddl}nzddl}W n ty,   ddl}|jddd� Y dS w t| dƒ�}| 	|¡W  d  ƒ S 1 sBw   Y  dS )	z…Returns a dict of config keys to values.

    It reads configs from toml file and returns `None` if the file is not a toml file.
    z.tomlN)é   é   r   zJNo TOML parser installed, cannot read configuration from `pyproject.toml`.rM   )Ú
stacklevelÚrb)
rr   r°   Úversion_infoÚtomllibÚtomliÚImportErrorÚwarningsÚwarnÚopenÚload)r¦   Ztoml_rŸ  ÚrfrS   rS   rT   r§   ¥  s   


ü$ÿr§   )rN   rO   rP   rQ   )ry   r/   rP   r>   )rƒ   r)   rP   r¢   )r~  rO   r   r,   rÂ   r   rP   rW   )r’   rO   r   r2   rÂ   r   rP   rW   )r   r2   rÂ   r   rP   rW   )rÆ   rO   r   rˆ  rÂ   r   rP   rW   )r   r,   rÂ   r   rP   rW   )NNF)r   rŽ  r}   r   r’   rO   r�   rq  rV  r>   rá   rÐ   r�  r�  rb  r¢   rP   rW   )r¦   rO   rP   r–  )Šr�   Ú
__future__r   r°   Úcollections.abcr   r   Úconfigparserr   Útypingr   Z
mypy.typesZmypyZmypy.errorcodesr   Zmypy.expandtyper   r	   Z
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&   r'   r(   r)   r*   Zmypy.optionsr+   Zmypy.pluginr,   r-   r.   r/   r0   r1   r2   Zmypy.plugins.commonr3   Zmypy.semanalr4   Zmypy.semanal_sharedr5   Zmypy.server.triggerr6   Z
mypy.stater7   Zmypy.type_visitorr8   Zmypy.typeopsr9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   Zmypy.typevarsrD   Z	mypy.utilrE   Zmypy.versionrF   Zmypy_versionZpydantic._internalrG   Zpydantic.versionrH   r´   rÄ   r  rh   rv   r  rX  rl   rm   rm  ZDATACLASS_FULLNAMEr  rD  r  ZMYPY_VERSION_TUPLErd  rU   rR   rY   rs   rÇ   rô   r|   r\  r"  rå   r‚  r„  r†  rŠ  rŒ  ZERROR_FIELD_DEFAULTSr�  rÅ   rk  r/  rÁ   rE  r:  r_  r§   rS   rS   rS   rT   Ú<module>   s˜    Œ#$	0

h
8      z
+





øX