HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/pydantic/v1/__pycache__/mypy.cpython-310.pyc
o

|��g%��@sddlZddlmZddlmZmZmZmZmZm	Z	m
Z
mZm
Z
ddlmZddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm 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-ddl.m/Z/ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7ddl8m9Z9dd	l:m;Z;dd
l<m=Z=ddl>m?Z?m@Z@mAZAmBZBmCZCmDZDmZmEZEmFZFmGZGmHZHmIZImJZJddlKmLZLdd
lMmNZNddlOmPZQddlRmSZSzddl>mTZTWneUy�ddl>mHZTYnwdZVdZWeXdd�ZYeY�d�ZZeY�d�Z[eY�d�Z\eY�d�Z]eY�d�Z^de_de
e`dffdd�ZaeaeQ�Zbebdk�rd nd!Zcd"ZPde_dd#fd$d%�ZdGd&d'�d'e5�ZeGd(d)�d)�Zfd*e4defd+d,�ZgGd-d.�d.�ZhGd/d0�d0�ZiGd1d2�d2�Zjed3d4d5�Zked6d7d5�Zled8d9d5�Zmed:d;d5�Zned<d=d5�Zoed<d>d5�Zpd?e_d@e1dAeddfdBdC�ZqdDe_d@e7dAeddfdEdF�Zrd@e7dAeddfdGdH�ZsdIe_d@e
e1e7fdAeddfdJdK�Ztd@e7dAeddfdLdM�Zud@e1dAeddfdNdO�Zv			P	Pdad*e2dDe_dQeedRedSeedTeeTdUewdVewddfdWdX�ZxdYe
ee(fde_fdZd[�ZydYe
ee(fde_fd\d]�Zzd^e_deee_effd_d`�Z{dS)b�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-mypyzpydantic-mypy-metadata���z.main.BaseModelz.env_settings.BaseSettingsz.main.ModelMetaclassz
.fields.Fieldz.dataclasses.dataclass�version�return.cCsttt|�d�d�d���S)N�+r�.)�tuple�map�int�	partition�split�rH�rR�;/usr/local/lib/python3.10/dist-packages/pydantic/v1/mypy.py�parse_mypy_versionWsrT)ri��builtins�__builtins__�zTypingType[Plugin]cCstS)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).
    )�PydanticPluginrQrRrRrS�pluginbsrYcs�eZdZdeddf�fdd�Zdeddfdd	�Zdedeee	gdffd
d�Z
deddfd
d�Zdedeeege
ffdd�Zdedeee	gdffdd�Zdedeeeffdd�Zde	ddfdd�Zde	ddfdd�Zdeddfdd�Z�ZS)rX�optionsrINcs&t|�|_|j��|_t��|�dS�N)�PydanticPluginConfig�
plugin_config�to_data�_plugin_data�super�__init__)�selfrZ��	__class__rRrSrams
zPydanticPlugin.__init__�fullnamez+Optional[Callable[[ClassDefContext], None]]cCs:|�|�}|rt|jt�rtdd�|jjD��r|jSdS)Ncs��|]	}t|�tkVqdSr[)�get_fullname�BASEMODEL_FULLNAME��.0�baserRrRrS�	<genexpr>v��z5PydanticPlugin.get_base_class_hook.<locals>.<genexpr>)�lookup_fully_qualified�
isinstance�noder'�any�mro�$_pydantic_model_class_maker_callback�rbre�symrRrRrS�get_base_class_hookrs

z"PydanticPlugin.get_base_class_hookcCs|tkr|jSdSr[)�MODEL_METACLASS_FULLNAME�)_pydantic_model_metaclass_marker_callback�rbrerRrRrS�get_metaclass_hookzsz!PydanticPlugin.get_metaclass_hookz+Optional[Callable[[FunctionContext], Type]]cCs"|�|�}|r|jtkr|jSdSr[)rnre�FIELD_FULLNAME�_pydantic_field_callbackrtrRrRrS�get_function_hooks
z PydanticPlugin.get_function_hookcCs|�d�rtSdS)Nz	.from_orm)�endswith�from_orm_callbackryrRrRrS�get_method_hook�s
zPydanticPlugin.get_method_hookcCs|tkrtdkrtjSdS)z�Mark pydantic.dataclasses as dataclass.

        Mypy version 1.1.1 added support for `@dataclass_transform` decorator.
        )�r�N)�DATACLASS_FULLNAME�MYPY_VERSION_TUPLEr2�dataclass_class_maker_callbackryrRrRrS�get_class_decorator_hook�sz'PydanticPlugin.get_class_decorator_hook�ctxcC�|jS)zjReturn all plugin config data.

        Used by mypy to determine if cache needs to be discarded.
        )r_)rbr�rRrRrS�report_config_data�sz!PydanticPlugin.report_config_datacCst||j�}|��dSr[)�PydanticModelTransformerr]�	transform)rbr��transformerrRrRrSrs�sz3PydanticPlugin._pydantic_model_class_maker_callbackcCs@|jjrdS|jjj}|sJd��t|jdd�rd|j_dSdS)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)r]�debug_dataclass_transform�cls�info�declared_metaclass�getattr�typer�)rbr��info_metaclassrRrRrSrx�s
�z8PydanticPlugin._pydantic_model_metaclass_marker_callbackr
c	s|j�|jddksJd��|jddksJd��|jd}|jd}|r0|r0t|j|j��S|rF|jdd}|d}t|t�sD|S�S|r�|jdd}t|t	�rdt
dkr^|jd}n|��d}t|t�r�|j
}t|dd	�}|r�td
d�|D��r�t�fd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())ri��argsNcss�|]}t|t�VqdSr[)ror>)rj�argrRrRrSrl�s�z:PydanticPlugin._pydantic_field_callback.<locals>.<genexpr>c3s�|]}�VqdSr[rR)rj�_��default_any_typerRrSrl�s�)�default_return_type�callee_arg_namesr��+error_default_and_default_factory_specified�api�context�	arg_typesrorr9r��itemsr6�ret_typer��allrL)	rbr��default_args�default_factory_args�default_type�default_arg�default_factory_typer�r�rRr�rSr|�s8	


�

z'PydanticPlugin._pydantic_field_callback)�__name__�
__module__�__qualname__r*ra�strrvrrr,rzr}r.r
r�r�r0rrr�rsrxr-r|�
__classcell__rRrRrcrSrXls   	
rXc@sbeZdZUdZeed<eed<eed<eed<eed<dedd	fd
d�Zdee	e
ffdd
�Zd	S)r\)�init_forbid_extra�
init_typed�warn_required_dynamic_aliases�warn_untyped_fieldsr�r�r�r�r�r�rZrINcCs�|jdurdSt|j�}|dur:|�di��di�}|jD]}|�|d�}t|t�s1td|����t|||�qdSt�}|�	|j�|jD]}|j
t|dd�}t|||�qFdS)N�toolrFFz/Configuration value must be a boolean for key: )�fallback)�config_file�
parse_toml�get�	__slots__ro�bool�
ValueError�setattrr�read�
getboolean�CONFIGFILE_KEY)rbrZ�toml_config�config�key�settingr]rRrRrSra�s"



�
�zPydanticPluginConfig.__init__cs�fdd��jD�S)Ncsi|]}|t�|��qSrR)r�)rjr��rbrRrS�
<dictcomp>�z0PydanticPluginConfig.to_data.<locals>.<dictcomp>)r�r�rRr�rSr^�zPydanticPluginConfig.to_data)r�r�r�r�r��__annotations__r*rarr�rr^rRrRrRrSr\�s
r\r�cCs�|j}t|t�r|j}t|t�rt|jt�r|j}nt|t�r"|}nd|�d|jj�d�}t	||j
|j�|jS|jj
�t�}|durF|jS|�di��d�}|dur^tt|j�|j
|j�|jS)z3
    Raise an error if orm_mode is not enabled
    z
ctx.type: �
 (of type �)Nr��orm_modeT)r�ror<�itemr6r�r7rdr��error_unexpected_behaviorr�r�r��metadatar��METADATA_KEY�error_from_orm�get_name)r��ctx_type�
model_type�detail�pydantic_metadatar�rRrRrSrs"

rc@s�eZdZUhd�Zeeed<dededdfdd�Z	d5d	d
�Z
d5dd�Zd6dd�Zdd
de
dfdd�Zde
ddd
deddfdd�Zde
dddfdd�Zde
ddeddfdd�Zdeded
fdd �Zed!ed"ed#edefd$d%��Zed&eedefd'd(��Zed"edeeeeffd)d*��Zde
dd+ed,ed-ede
ef
d.d/�Zde
ddd
defd0d1�Z ede
dd2edefd3d4��Z!dS)7r�>�extra�frozenr��allow_mutation�alias_generator�allow_population_by_field_name�tracked_config_fieldsr�r]rINcCs||_||_dSr[)�_ctxr])rbr�r]rRrRrSra)s
z!PydanticModelTransformer.__init__cCs�|j}|jj}|��|��}|�|�}tdd�|jdd�D��}|�|||�|�	|�|j
||jdup:|jdud�dd	�|D�|�
�d
�|jt<dS)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
        csrfr[)rg�BASESETTINGS_FULLNAMErirRrRrSrl=rmz5PydanticModelTransformer.transform.<locals>.<genexpr>N���FT)r�cSsi|]}|j|���qSrR)�name�	serialize�rj�fieldrRrRrSr�Br�z6PydanticModelTransformer.transform.<locals>.<dictcomp>)�fieldsr�)r�r�r��adjust_validator_signatures�collect_config�collect_fieldsrqrr�add_initializer�add_construct_method�
set_frozenr�r��set_values_dictr�r�)rbr�r�r�r��is_settingsrRrRrSr�-s


�z"PydanticModelTransformer.transformcCsh|jjjj��D])\}}t|jt�r1|jjd}t|t	�r1t|j
t�r1|j
jt
�d�kr1d|jj_qdS)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.
        rz.class_validators.validatorTN)r�r�r��namesr�rorpr�original_decoratorsr�calleerre�
_NAMESPACE�func�is_class)rbr�ru�	first_decrRrRrSr�Fs�
�
��z4PydanticModelTransformer.adjust_validator_signatures�ModelConfigDatac	Cs�|j}|j}t�}|jjD]2}t|t�sq
|jdkr?|jjD]}t|t�s&q|�	|�
|��q|jr?|js?|j
jr?t|j|�q
|jjdd�D]&}t|jvrPqH|j�tt|���|jtd��D]
\}}|�||�qcqH|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�bodyrorr�r�update�get_config_update�has_alias_generatorr�r]r��error_required_dynamic_aliasesr�r�rrr�r��add_plugin_dependencyr4rgr��
setdefault)	rbr�r�r��stmt�substmtr�r��valuerRrRrSr�Xs6


����
�z'PydanticModelTransformer.collect_config�model_config�PydanticModelFieldcs�|j}|jj}g}t�}|jjD]x}t|t�sq|jd}t|t�r't	|j
�s(q|js5|jj
r5t|j|�|jj�|j
�}|durBq|j}	t|	t�rKqt|	t�sQq|	jrUq|�|||�}
|�|�\}}|rr|jsr|jjrrt|j|�|�t|j
|
|||j|jd��|� |j
�q|�!�}
|jj"dd�D]O}t#|j$vr�q�g}|j�%t&t'|���|j$t#d�(�D]-\�}�|vr�t�)||�}|� ��|�|�q��fdd�|
D�\}|
�*|�|�|�q�||
}
q�|
S)zR
        Collects the fields for the model, accounting for parent classes
        rN�r��is_required�alias�has_dynamic_alias�line�columnr�r�c3s�|]
}|j�kr|VqdSr[�r�)rj�arrRrSrl�s�z:PydanticModelTransformer.collect_fields.<locals>.<genexpr>)+r�r��setr�r�ror�lvaluesrrDr��
new_syntaxr]r��error_untyped_fieldsr�r�r�r�rpr!r)�is_classvar�get_is_required�get_alias_infor�r�r��appendr�rr�add�copyrrr�r�r�r4rgr��deserialize�remove)rbr�r�r�r��known_fieldsr��lhsrurprrr�
all_fieldsr��superclass_fields�datar�rRrrSr�wst



�����




z'PydanticModelTransformer.collect_fieldsr�r�r�c
Cs�|j}|jj}|jdu}|pt|jo|j�}|j||||d�}|�||�s7td�}	|�	t
|	ttj
�dt��d|jjjvrHt|d|t��dSdS)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�kwargsNra)r�r]r�r�r�r��get_field_arguments�should_init_forbid_extrar)rrr5r;�explicitrr�r�r��
add_methodr8)
rbr�r�r�r�rrr�init_arguments�varrRrRrSr��s
���z(PydanticModelTransformer.add_initializerc
	CsJ|j}|j�t�d�|j�t�d��g�}t|t�g�}ttd|�|dt�}|j	|dddd�}|g|}|j�t�d��}d	}|j
jd
|}	tdkrst
||	tdkr\td
|j
jdd�ntd
�g|ttj��}
t||	g|ttj��}nt||	d
g|�}
t||	g|�}tt|�|j
jj|<t|
t
�r�|
}nt
|
�}t|d||||
dd�dS)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_setNTFrz.object�_PydanticBaseModelrK)r��)r��r�z
.construct)�	namespace�	construct)�return_type�	self_type�tvar_def�is_classmethod)r�r��
named_type�
BUILTINS_NAMEr?r8rr)rrr�rer�r>r=r5r;�from_omitted_genericsr(rEr%rr�r�ror!)
rbr�r��set_str�optional_set_str�fields_set_argument�construct_arguments�obj_type�self_tvar_name�
tvar_fullname�tvd�self_tvar_exprr+rRrRrSr��sT$
���

�z-PydanticModelTransformer.add_construct_methodr�c
	Cs�|j}|jj}|D]q}|j�|j�}|durX|j}t|t�r"||_	q	t|t
�r1|jjs1|j�
�q	zt|�}Wn
tyDt|�}Ynwd|�d|j�d�}	t|	|j|j�q	|j|dd�}||_||_	t|�dt|�|_tt|�|jt|�<q	dS)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.
        Nzsym_node.node: r�r�F)rrK)r�r�r�r�r�r�rpror)�is_propertyr!r��final_iteration�deferr��	TypeError�reprrdr��to_varrgr��	_fullnamer%r)
rbr�r�r�r�r��sym_noder#�var_strr�rRrRrSr�s.
��z#PydanticModelTransformer.set_frozenr�cCs|jd}t|t�r|j|jvsdS|jdkrAt|jt�r$|jjdk}nt|jt�r1|jjdk}nt	|j|j
j|�dSt|d�S|jdkr[d}t|jt�rV|jj
dkrVd	}t|d
�St|jt�ru|jj
dvrutd
i|j|jj
dki��St	|j|j
j|�dS)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)
        rNr��forbid)�forbid_extrar�Tz
builtins.NoneF)r�)�
builtins.Truezbuiltins.FalserErR)r	rorr�r��rvaluer#r�r�error_invalid_config_valuer�r�r�re)rbr�rrDr�rRrRrSr�<s(




z*PydanticModelTransformer.get_config_updater�r�rcCs�|j}t|t�rt|j|jj�}t�|�St|t	�rYt|j
t�rY|j
jt
krYt|j|j�D]\}}|dus;|dkrB|jtuS|dkrIdSq/t|j|jj�}t�|�St|t�S)zg
        Returns a boolean indicating whether the field defined in `stmt` is a required field.
        Nr�r�F)rFror&r@r�r�r�r��type_has_implicit_defaultrr�r"rer{�zipr��	arg_namesrdr)r�r�r�expr�
value_typer�r�rRrRrSr
Xs
"�
z(PydanticModelTransformer.get_is_required�type_cCs4t|t�rdSt|t�rtdd�|jD��rdSdS)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).
        Tcss$�|]
}t|t�p
t|t�VqdSr[)ror8r5)rjr�rRrRrSrl|s�
�zEPydanticModelTransformer.type_has_implicit_default.<locals>.<genexpr>F)ror5r?rqr�)rMrRrRrSrHrs
�z2PydanticModelTransformer.type_has_implicit_defaultcCs�|j}t|t�r
dSt|t�rt|jt�r|jjtksdSt|j	�D]\}}|dkr+q"|j
|}t|t�r<|jdfSdSdS)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.
        )NFrF)NT)
rFror&rr�r"rer{�	enumeraterJr�r#r�)r�rK�i�arg_namer�rRrRrSr�s"
�
�

z'PydanticModelTransformer.get_alias_inforrrcs&|jjj�����fdd�|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.
        cs(g|]}�r	|js|j����d��qS))r�force_optionalr)r�to_argumentr��rr�rrrRrS�
<listcomp>�s���z@PydanticModelTransformer.get_field_arguments.<locals>.<listcomp>)r�r�r�)rbr�rrr�	argumentsrRrSrSr�s

�z,PydanticModelTransformer.get_field_argumentscCs.|js|�|t|j��rdS|jrdS|jjS)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�rDr]r�)rbr�r�rRrRrSr�sz1PydanticModelTransformer.should_init_forbid_extrar�cCs8|D]}|jr
dSq|r|D]
}|jdurdSqdS)z�
        Returns whether any fields on the model have a "dynamic alias", i.e., an alias that cannot be
        determined during static analysis.
        TNF)rr)r�r�r�rRrRrSrV�s�
�z1PydanticModelTransformer.is_dynamic_alias_present)rIN)rIr�)"r�r�r�r�rr�r�r,r\rar�r�r�rr�r�r�r�r�rrr��staticmethodrrr
r:rHr	rrrrrVrRrRrRrSr�s>
	


T:! ����
� r�c@s�eZdZdededeedededefdd�Zd	ed
ede	fdd
�Z
d	ededed
edef
dd�Zde
fdd�Zed	ede
ddfdd��ZdS)r�r�rrrrrcC�(||_||_||_||_||_||_dSr[r)rbr�rrrrrrRrRrSra�s
zPydanticModelField.__init__r�rrIcCs,|j}|r
|jdur
|j}t|||jj�Sr[)r�rr)r�)rbr�rr�rRrRrSr?�szPydanticModelField.to_varrrQcCsV|r||jjdur||jj}nttj�}t|�||�|d|s#|js'td�St	d�S)N)�variable�type_annotation�initializer�kind)
r�r�r5r;r rr?rrr
)rbr�rrQrrZrRrRrSrR�s

��zPydanticModelField.to_argumentcCr�r[)�__dict__r�rRrRrSr��szPydanticModelField.serializercCs|di|��S)NrRrR)r�r�rrRrRrSr�szPydanticModelField.deserializeN)r�r�r�r�r�rrNrar'r)r?rrRrr��classmethodrrRrRrRrSr��s&�����
�
r�c@s�eZdZ						ddeedeedeedeedeedeefdd	�Zd
eeeffdd�Z	d
edd
dfdd�Z
deded
dfdd�ZdS)r�NrDr�r�r�r�r�cCrXr[)rDr�r�r�r�r�)rbrDr�r�r�r�r�rRrRrSra�s	
zModelConfigData.__init__rIcCsdd�|j��D�S)NcSsi|]\}}|dur||�qSr[rR)rj�k�vrRrRrSr�sz3ModelConfigData.set_values_dict.<locals>.<dictcomp>)r]r�r�rRrRrSr�r�zModelConfigData.set_values_dictr�cCs2|durdS|����D]
\}}t|||�qdSr[)r�r�r�)rbr�r_r`rRrRrSr�s
�zModelConfigData.updater�r�cCs"t||�durt|||�dSdSr[)r�r�)rbr�r�rRrRrSr�
s�zModelConfigData.setdefault)NNNNNN)r�r�r�rr�rarr�rr�r�r�rRrRrRrSr��s.������
�r�zpydantic-ormzInvalid from_orm call�Pydanticzpydantic-configzInvalid config valuezpydantic-aliaszDynamic alias disallowedzpydantic-unexpectedzUnexpected behaviorzpydantic-fieldzUntyped field disallowedzInvalid Field defaults�
model_namer�r�cC�|jd|�d�|td�dS)N�"z" does not have orm_mode=True��code)�fail�	ERROR_ORM)rbr�r�rRrRrSr��r�r�cCrc)NzInvalid value for "Config.rdre)rg�ERROR_CONFIG)r�r�r�rRrRrSrGrirGcC�|jd|td�dS)Nz#Required dynamic aliases disallowedre)rg�ERROR_ALIAS�r�r�rRrRrSr�"r�r�r�cCs4d}d|�d�}|d|�d�7}|j||td�dS)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!re)rg�ERROR_UNEXPECTED)r�r�r��link�full_messagerRrRrSr�&sr�cCrk)NzUntyped fields disallowedre)rg�
ERROR_UNTYPEDrmrRrRrSr0r�rcCrk)Nz>Field default and default_factory cannot be specified togetherre)rg�ERROR_FIELD_DEFAULTSrmrRrRrSr�4r�r�Fr�r*r+r,r-�is_newcCs|jj}||jvr |j|}	|	jr t|	jt�r |jjj�	|	j�|p%t
|�}|s*|r8ttd�t
�|�dt�g}
n|p=t
|�}ttd�|dt�g}
|
|}ggg}}}
|D]}|js_Jd��|�|j�|�t|j��|
�|j�qV|j�t�d��}t||
|||�}|r�|g|_t||tt�g��}||_t||�|_||_t|�d||_ |j!|_!||jvr�t"||j�}|j||j|<|r�d|_#t||j�}||_|j |_ d|_$t%|t&d�g|�}|j!|_!t't(|�}	nt't(|�}	d|	_|	|j|<|j)jj�|�dS)	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	.functionrKTr^)*r�r�r��plugin_generatedrorprr�r�rrArr)r<�make_normalizedrrZrr�rYr\r�r.r/r6�	variablesrr r3r�r�rgr@rrB�is_decoratedr-rrr%r�defn)r�r�r�r*r+r,r-rtr�ru�firstr�rJ�	arg_kindsr��
function_type�	signaturer��r_namer`�decrRrRrSr!8sV




r!�xcC�|j}t|�r
|�S|S�zc
    Used for compatibility with mypy 0.740; can be dropped once support for 0.740 is dropped.
    )re�callable�r��fnrRrRrSrg��rgcCr�r�)r�r�r�rRrRrSr��r�r�r�cCs�|�d�sdSd}tjdkrddl}n-zddl}Wn&ty?d}zddl}Wnty<ddl}|�d�YYdSwYnwt	||��
}|�
|�Wd�S1sUwYdS)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��rfrRrRrSr��s*



���$�r�)NNFF)|r��configparserr�typingrrrrrrr	r
�
TypingTyper�mypy.errorcodesr�
mypy.nodesr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)�mypy.optionsr*�mypy.pluginr+r,r-r.r/r0r1�mypy.pluginsr2�mypy.semanalr3�mypy.server.triggerr4�
mypy.typesr5r6r7r8r9r:r;r<r=r>r?r@�
mypy.typevarsrA�	mypy.utilrB�mypy.versionrC�mypy_version�pydantic.v1.utilsrDrEr�r�r�r�r�rhr�rwr{r�r�rNrTr�r/rYrXr\rr�r�r�rhrjrlrorrrsr�rGr�r�rr�r�r!rgr�r�rRrRrRrS�<module>s�,|$	<�





u%2%�
��
�
	���������

�S
"